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 import() expressions #205

Merged
merged 12 commits into from
Aug 13, 2018
Merged

Add support for import() expressions #205

merged 12 commits into from
Aug 13, 2018

Conversation

haggholm
Copy link
Contributor

Add support for lazy import() calls as used by System.import() and lazy Webpack chunks.

Modelled on the require.resolve() PR (#196). Not too familiar with the test framework, but copying tests, it seems to work (and mutating tests does properly break…).

Perhaps this should be optional/disabled by default, but the options (esp. w.r.t. the tests) are a bit opaque to me: feedback extremely welcome.

@codecov
Copy link

codecov bot commented May 25, 2017

Codecov Report

Merging #205 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #205      +/-   ##
==========================================
+ Coverage   98.04%   98.04%   +<.01%     
==========================================
  Files          28       29       +1     
  Lines         460      461       +1     
==========================================
+ Hits          451      452       +1     
  Misses          9        9
Impacted Files Coverage Δ
src/cli.js 100% <ø> (ø) ⬆️
src/constants.js 100% <ø> (ø) ⬆️
src/detector/importCallExpression.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e90f20...6746273. Read the comment docs.

Copy link
Member

@lijunle lijunle left a comment

Choose a reason for hiding this comment

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

Hi, @haggholm Thank you for your PR. Sorry that I review the code late. I left some comments, could you please help to take a look?

@@ -0,0 +1 @@
System.import('anyone');
Copy link
Member

Choose a reason for hiding this comment

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

I suppose the System.import has been deprecated and we don't need to support it.

@@ -0,0 +1 @@
import('optimist');
Copy link
Member

Choose a reason for hiding this comment

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

Could you please try the webpack named chunk feature (aka, the magic comment):

import(/* webpackChunkName: 'chunk' */ 'chunk')

@haggholm
Copy link
Contributor Author

I guess I was about as quick to reply as you were! I’m not 100% what you mean; do these changes reflect what you wanted?

@lijunle
Copy link
Member

lijunle commented Oct 20, 2017

@haggholm Webpack's import() has a feature named magic comment to specify the chunk name with the following syntax:

import(/* webpackChunkName: "my-chunk-name" */ 'module');

We should check if we are supporting it.

@haggholm
Copy link
Contributor Author

Right. I added a test that verifies that it still detects the import­ -- I think that’s what you meant? I also cleaned up some cruft I’d accidentally introduced.

@mnkhouri mnkhouri added this to the 0.6.10 milestone Aug 13, 2018
Copy link
Member

@LinusU LinusU left a comment

Choose a reason for hiding this comment

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

Nice 👍

@mnkhouri mnkhouri merged commit 42ac2b8 into depcheck:master Aug 13, 2018
@mnkhouri
Copy link
Member

Thank you for the contribution, @haggholm ! 🎉

mnkhouri added a commit that referenced this pull request Aug 28, 2018
* master:
  Upgrade all dependencies (#276)
  Fix error when Typescript is not installed (#282)
  Enable ES6/7 syntax in Typescript (#258)
  Update NPM tokens for deploy from Travis (#278)
  Recognize object arrays in Webpack module.rules.loaders (#233)
  Add support for import() expressions (#205)
  Bump Mocha to 5.x (#274)
  Fix ignore-bin-package default in ReadMe (#252)
  Fix typo: pasers -> parsers
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.

4 participants