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

New rules to forbid webpack require.ensure() and System.import() #743

Closed
tharakawj opened this issue Feb 12, 2017 · 4 comments
Closed

New rules to forbid webpack require.ensure() and System.import() #743

tharakawj opened this issue Feb 12, 2017 · 4 comments

Comments

@tharakawj
Copy link

Webpack 2 is going to deprecate require.ensure() and System.import() in favor of import() for code splitting. import() syntax isn't specific to Webpack and it's currently an ES proposal at stage 3. So some projects might want to disallow usage of require.ensure() and System.import(), then they can easily switch to another module bundler or native implementation in the future. Currently, such requirement being discussed in the create-react-app project and there is an open issue facebook/create-react-app#1524.

So I'm thinking about two new rules like no-webpack-require-ensure andno-webpack-system-import to support this. But I would like to know everyone's thoughts on this before sending a PR.

@tharakawj tharakawj changed the title New rules to forbid webpack require.ensure() and System.import New rules to forbid webpack require.ensure() and System.import() Feb 12, 2017
@ljharb
Copy link
Member

ljharb commented Feb 12, 2017

eslint core already has no-restricted-properties, which can be set to block both of those. There's no need for a separate rule for it.

@sebastienbarre
Copy link

@tharakawj @ljharb Sorry to piggyback, but this seems related. I'm struggling trying to find which ESLint option would get rid of this error:

  7:36  error  Parsing error: Unexpected token import

the line is:

const Page1 = asyncComponent(() => import('./components/Page1')
  .then(module => module.default), { name: 'Page 1' });

Any hint would be appreciated.

@ljharb
Copy link
Member

ljharb commented Apr 8, 2017

You need to enable parsing of import() as well as add a transform plugin for it; for eslint, you need babel-eslint - core can't handle it yet.

@sebastienbarre
Copy link

That did the trick, thanks for the lightning-fast answer.

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

No branches or pull requests

3 participants