requirejs - config to extract a property from the returned module
up vote
0
down vote
favorite
I currently have a project that uses both es6 modules and requirejs AMD modules. The problem that I have is, that if I export from an es6 module with default exports, I receive an object with the default prop in the requirejs callback.
requirejs(['myscript'], function (myscript) {
var xyz = myscript.default
// use xyz
})
I have quite a few scripts though, so I don't want to add .default everywhere. Can I configure this in requirejs, or is there a babel plugin that allows me to extract the default prop of the exported module?
es6 module:
export default obj
script with requirejs call:
requirejs(['obj'], function (obj) {
console.log(obj)
/* prints: {
default: {
a: ...,
b: ...,
c: ...
}
} */
})
What I need is:
requirejs(['obj'], function (obj) {
console.log(obj)
/* prints: {
a: ...,
b: ...,
c: ...
} */
})
ecmascript-6 requirejs es6-modules
add a comment |
up vote
0
down vote
favorite
I currently have a project that uses both es6 modules and requirejs AMD modules. The problem that I have is, that if I export from an es6 module with default exports, I receive an object with the default prop in the requirejs callback.
requirejs(['myscript'], function (myscript) {
var xyz = myscript.default
// use xyz
})
I have quite a few scripts though, so I don't want to add .default everywhere. Can I configure this in requirejs, or is there a babel plugin that allows me to extract the default prop of the exported module?
es6 module:
export default obj
script with requirejs call:
requirejs(['obj'], function (obj) {
console.log(obj)
/* prints: {
default: {
a: ...,
b: ...,
c: ...
}
} */
})
What I need is:
requirejs(['obj'], function (obj) {
console.log(obj)
/* prints: {
a: ...,
b: ...,
c: ...
} */
})
ecmascript-6 requirejs es6-modules
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I currently have a project that uses both es6 modules and requirejs AMD modules. The problem that I have is, that if I export from an es6 module with default exports, I receive an object with the default prop in the requirejs callback.
requirejs(['myscript'], function (myscript) {
var xyz = myscript.default
// use xyz
})
I have quite a few scripts though, so I don't want to add .default everywhere. Can I configure this in requirejs, or is there a babel plugin that allows me to extract the default prop of the exported module?
es6 module:
export default obj
script with requirejs call:
requirejs(['obj'], function (obj) {
console.log(obj)
/* prints: {
default: {
a: ...,
b: ...,
c: ...
}
} */
})
What I need is:
requirejs(['obj'], function (obj) {
console.log(obj)
/* prints: {
a: ...,
b: ...,
c: ...
} */
})
ecmascript-6 requirejs es6-modules
I currently have a project that uses both es6 modules and requirejs AMD modules. The problem that I have is, that if I export from an es6 module with default exports, I receive an object with the default prop in the requirejs callback.
requirejs(['myscript'], function (myscript) {
var xyz = myscript.default
// use xyz
})
I have quite a few scripts though, so I don't want to add .default everywhere. Can I configure this in requirejs, or is there a babel plugin that allows me to extract the default prop of the exported module?
es6 module:
export default obj
script with requirejs call:
requirejs(['obj'], function (obj) {
console.log(obj)
/* prints: {
default: {
a: ...,
b: ...,
c: ...
}
} */
})
What I need is:
requirejs(['obj'], function (obj) {
console.log(obj)
/* prints: {
a: ...,
b: ...,
c: ...
} */
})
ecmascript-6 requirejs es6-modules
ecmascript-6 requirejs es6-modules
asked Nov 22 at 10:41
Johannes
428720
428720
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429102%2frequirejs-config-to-extract-a-property-from-the-returned-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown