Skip to content
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

Merged
merged 6 commits into from Apr 23, 2017
Merged

Conversation

leoselig
Copy link
Contributor

  • 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

@codecov
Copy link

codecov bot commented Mar 29, 2017

Codecov Report

Merging #143 into beta will not change coverage.
The diff coverage is 100%.

Impacted Files Coverage Δ
src/utils.js 100% <100%> (ø) ⬆️
src/transformers/call.js 100% <100%> (ø) ⬆️
src/getRealPath.js 100% <0%> (ø) ⬆️
src/normalizeOptions.js 100% <0%> (ø) ⬆️

@fatfisz
Copy link
Contributor

fatfisz commented Mar 30, 2017

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.

@leoselig
Copy link
Contributor Author

Sounds good, the 2.6-issue surely is more pressing after all
I'll merge master back in once you say so

@fatfisz
Copy link
Contributor

fatfisz commented Apr 8, 2017

@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.

@leoselig
Copy link
Contributor Author

leoselig commented Apr 8, 2017

@fatfisz No problem
If we really need it before we get it into beta/stable I'll use the fork instead
Thanks for your work on this anyway

@fatfisz
Copy link
Contributor

fatfisz commented Apr 14, 2017

@leoselig Hi, the beta branch is in a good state now, so it's safe for you to rebase :) Please be sure to select beta instead of master.

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!

@leoselig leoselig changed the base branch from master to beta April 14, 2017 20:29
@leoselig leoselig closed this Apr 14, 2017
@leoselig leoselig reopened this Apr 14, 2017
@leoselig
Copy link
Contributor Author

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
@leoselig
Copy link
Contributor Author

@fatfisz
Done

(It did fit in quite well with the transformers/call.js but I could not add it as one of the pattern because the callee of a dynamic es6 import is actually an Import-type node)

Copy link
Owner

@tleunen tleunen left a 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",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert? ;)


if (patterns.some(pattern => matchesPattern(state.types, calleePath, pattern))) {
if (isNormalCall) {
Copy link
Owner

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",
Copy link
Owner

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?

Leo Selig added 3 commits April 18, 2017 09:26
@fatfisz
Copy link
Contributor

fatfisz commented Apr 18, 2017

I think this looks good :)

I'd only make the paths & the test names consistent with the ones in call.test.js, e.g. remove the "CFG", consistently use "" instead of \'\' for an empty path.

Copy link
Owner

@tleunen tleunen left a 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",
Copy link
Owner

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

});

it('should handle an empty path', () => {
const code = 'import(\'\').then(() => {}).catch(() => {});';
Copy link
Owner

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 \'\'

],
};

it('CFG should resolve the path based on the root config', () => {
Copy link
Owner

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... :)

@leoselig
Copy link
Contributor Author

Finally got around to fix the remarks
Thanks for reviewing

@tleunen
Copy link
Owner

tleunen commented Apr 23, 2017

Thanks a lot @leoselig.
I'll soon release a new beta version with this.

@tleunen tleunen merged commit 56848d2 into tleunen:beta Apr 23, 2017
tleunen pushed a commit that referenced this pull request Apr 23, 2017
tleunen pushed a commit that referenced this pull request Apr 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants