-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for new ES dynamic import()
#143
Conversation
Codecov Report
|
Thanks for your contribution! Currently the plugin has some problems that have to be fixed, so probably before your feature can be merged those bugs have to be addressed first. It should be a matter of a few days. |
Sounds good, the 2.6-issue surely is more pressing after all |
@leoselig I think this should go on the beta branch. I'll give you heads up when it will be good to rebase this! Sorry for the confusion, but we want to avoid the situation from 2 weeks ago. |
@fatfisz No problem |
@leoselig Hi, the beta branch is in a good state now, so it's safe for you to rebase :) Please be sure to select Notice how a few things have changed with regards to how the method calls are handled. If you have any questions, I'm here to help! |
Had to close and re-open to fix appveyor issue (probably this one) |
- adds support for resolving module options on calls to the stage 3 proposal for `import()` (for details, see draft at https://github.com/tc39/proposal-dynamic-import) - this is very similar to the `Systom.import()`-implementation - we need to add `babel-preset-stage-2` in order to parse the `import()`-calls in our tests
@fatfisz (It did fit in quite well with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fatfisz Anything to add?
package.json
Outdated
@@ -55,7 +56,7 @@ | |||
"pretest": "npm run lint", | |||
"test": "jest --coverage", | |||
"test:suite": "jest", | |||
"test:watch": "jest --watch", | |||
"test:watch": "jest --watch test/dynamicImport.test.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert? ;)
src/transformers/call.js
Outdated
|
||
if (patterns.some(pattern => matchesPattern(state.types, calleePath, pattern))) { | ||
if (isNormalCall) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should group these 2 conditions
package.json
Outdated
@@ -42,6 +42,7 @@ | |||
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.0", | |||
"babel-plugin-transform-object-rest-spread": "^6.23.0", | |||
"babel-preset-env": "^1.2.2", | |||
"babel-preset-stage-2": "^6.22.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you only use the required plugin instead?
- this replaces the `stage-2` preset that was pulling in way more than needed
I think this looks good :) I'd only make the paths & the test names consistent with the ones in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm all good once these small things are changed
package.json
Outdated
@@ -55,7 +56,6 @@ | |||
"pretest": "npm run lint", | |||
"test": "jest --coverage", | |||
"test:suite": "jest", | |||
"test:watch": "jest --watch", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still want to keep test:watch
;)
Sorry if this wasn't clear
test/dynamicImport.test.js
Outdated
}); | ||
|
||
it('should handle an empty path', () => { | ||
const code = 'import(\'\').then(() => {}).catch(() => {});'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is what @fatfisz mentioned. Use ""
instead of \'\'
test/dynamicImport.test.js
Outdated
], | ||
}; | ||
|
||
it('CFG should resolve the path based on the root config', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CFG
not needed. Usually we start all tests with should...
. Because it should...
:)
Finally got around to fix the remarks |
Thanks a lot @leoselig. |
stage 3 proposal for
import()
(for details, see draft athttps://github.com/tc39/proposal-dynamic-import)
Systom.import()
-implementationbabel-preset-stage-2
in order to parse theimport()
-calls in our tests