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

Support for dynamic imports #700

Closed
gpoitch opened this issue Dec 22, 2016 · 8 comments
Closed

Support for dynamic imports #700

gpoitch opened this issue Dec 22, 2016 · 8 comments

Comments

@gpoitch
Copy link

gpoitch commented Dec 22, 2016

https://github.com/tc39/proposal-dynamic-import (stage 3)

import(`./foo/${bar}`).then(module => {
    // ...
})

This is currently recognized as invalid syntax: Parsing error: Unexpected token import.

Also probably need to add a rule similar to no-dynamic-require as well.

@ljharb
Copy link
Member

ljharb commented Dec 22, 2016

The babel-eslint parser is required for it to be parsed properly (syntax parsing is not the job of an eslint plugin).

I agree that no-dynamic-import is a good rule to have.

@gpoitch
Copy link
Author

gpoitch commented Dec 22, 2016

Thanks. Using babel-eslint resolved my issue. I incorrectly assumed that using the webpack resolver would apply the babel config it contains.

Leaving open as a request to support a new no-dynamic-import rule.

@benmosher
Copy link
Member

benmosher commented Jul 6, 2017

just making a note: would also like to add to the moduleVisitor so that static paths imported dynamically (think code splitting) can be linted by no-unresolved, no-absolute-path, etc.

@vikr01
Copy link
Contributor

vikr01 commented Oct 22, 2018

no-dynamic-import is a confusing name since import() is called dynamic import.

Also, why make a new rule for this when we can nest it as an option under no-dynamic-require?

@ljharb
Copy link
Member

ljharb commented Oct 22, 2018

I think it's pretty easy to ban import() with no-restricted-syntax, so we probably don't need a rule for that.

@vikr01
Copy link
Contributor

vikr01 commented Oct 22, 2018

@ljharb Do you mean banning with an expression in it?

const foopath = './foo';
const foo = await import(foopath);

@ljharb
Copy link
Member

ljharb commented Oct 22, 2018

sure, you could do that too.

@benmosher
Copy link
Member

#1093 added import(...) to the moduleVisitor 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants