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

webpackExclude doesn't work #9963

Closed
volkanunsal opened this issue Nov 12, 2019 · 4 comments
Closed

webpackExclude doesn't work #9963

volkanunsal opened this issue Nov 12, 2019 · 4 comments
Labels

Comments

@volkanunsal
Copy link

Reposting with corrected code

Bug report

What is the current behavior?

Given a dynamic import like this:

const CompanyEdit = universal(import(
/* webpackExclude: /(__generated__|__tests__)/ */ 
'comps/Company/Edit'));

It does not exclude the files matching the pattern from the chunk generation. Here is a sample output from the manifest.json of the files that match the following pattern and are generated by this import

public/__generated__-GetKey.chunk-647967baa76de181db7c.js
public/__generated__-GetKey.chunk-647967baa76de181db7c.js.map
public/__generated__-RegenKey.chunk-4f4202d851a015422d6d.js
public/__generated__-RegenKey.chunk-4f4202d851a015422d6d.js.map
public/__generated__-updateCompany.chunk-c3ad3a2c0a71b001bb29.js
public/__generated__-updateCompany.chunk-c3ad3a2c0a71b001bb29.js.map
public/__tests__-AccessKeyManager-test.chunk-bed6e34b29ee6fbd5d72.js
public/__tests__-AccessKeyManager-test.chunk-bed6e34b29ee6fbd5d72.js.map
public/__tests__-__snapshots__-AccessKeyManager-test-js-snap.chunk-07f6461ec4547a0878ef.js
public/__tests__-__snapshots__-AccessKeyManager-test-js-snap.chunk-07f6461ec4547a0878ef.js.map

What is the expected behavior?

It is expected to exclude these files from the manifest.

Other relevant information:
webpack version: 4.41.0
Node.js version: 8.x.x
Operating System: Mac OS

@sokra
Copy link
Member

sokra commented Nov 13, 2019

const CompanyEdit = universal(import(
/* webpackExclude: /(__generated__|__tests__)/ */ 
'comps/Company/Edit'));

Your code only includes comps/Company/Edit so webpackExclude doesn't apply here. These chunks are generated by some other import()

@volkanunsal
Copy link
Author

I think you're right. There is only one other place where I use a dynamic import. That is a sister component to Company/Edit. They are both imported from Company/index.js. This is what that import looks like:

const Loader = universal(
  // $FlowFixMe
  (props: { path: string }) =>
    import(
      `./${props.path}`
    ),
  {
    minDelay: 0,
    loading: () => <i className="fa fa-spinner fa-spin" />,
  }
);

This was generating the following warning in my console:

WARNING in ./assets/comps/Company/__generated__/updateCompany.js 9:7
Module parse failed: Unexpected token (9:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

And when I put the import in the argument, rather than inside the function, the warnings went away.

const Loader = universal(
  import(
    `./${props.path}`
  ),
  {
    minDelay: 0,
    loading: () => <i className="fa fa-spinner fa-spin" />,
  }
);

@webpack-bot
Copy link
Contributor

This issue had no activity for at least three months.

It's subject to automatic issue closing if there is no activity in the next 15 days.

@webpack-bot
Copy link
Contributor

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

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

No branches or pull requests

3 participants