Skip to content

Add support for new ES dynamic import()#143

Merged
tleunen merged 6 commits intotleunen:betafrom
leoselig:master
Apr 23, 2017
Merged

Add support for new ES dynamic import()#143
tleunen merged 6 commits intotleunen:betafrom
leoselig:master

Conversation

@leoselig
Copy link
Copy Markdown
Contributor

@codecov
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

Comment thread package.json Outdated
"test": "jest --coverage",
"test:suite": "jest",
"test:watch": "jest --watch",
"test:watch": "jest --watch test/dynamicImport.test.js",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

revert? ;)

Comment thread src/transformers/call.js Outdated
const isNormalCall = patterns.some(pattern => matchesPattern(state.types, calleePath, pattern));

if (patterns.some(pattern => matchesPattern(state.types, calleePath, pattern))) {
if (isNormalCall) {
Copy link
Copy Markdown
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

Comment thread package.json Outdated
"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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread package.json
"pretest": "npm run lint",
"test": "jest --coverage",
"test:suite": "jest",
"test:watch": "jest --watch",
Copy link
Copy Markdown
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

Comment thread test/dynamicImport.test.js Outdated
});

it('should handle an empty path', () => {
const code = 'import(\'\').then(() => {}).catch(() => {});';
Copy link
Copy Markdown
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 \'\'

Comment thread test/dynamicImport.test.js Outdated
],
};

it('CFG should resolve the path based on the root config', () => {
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Finally got around to fix the remarks
Thanks for reviewing

@tleunen
Copy link
Copy Markdown
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.

3 participants