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

/* webpackChunkName: "name" */ is working without the exact name. #996

Closed
SidKwok opened this issue Oct 20, 2017 · 5 comments
Closed

/* webpackChunkName: "name" */ is working without the exact name. #996

SidKwok opened this issue Oct 20, 2017 · 5 comments
Labels

Comments

@SidKwok
Copy link
Contributor

SidKwok commented Oct 20, 2017

My async route:

const MainView = () => import(/* webpackChunkName: "group-foo" */ '@/components/MainView')
const OneView = () => import(/* webpackChunkName: "group-foo" */ '@/components/OneView')
const TwoView = () => import(/* webpackChunkName: "group-foo" */ '@/components/TwoView')

After I run build:
1508482209806

The bundle name is 0 rather than group-foo.

SidKwok added a commit to SidKwok/webpack that referenced this issue Oct 20, 2017
@LinusBorg
Copy link
Contributor

LinusBorg commented Oct 20, 2017

Hm, that generally happens when comments are stripped, usually but babel.

We had a "comments: false" setting in .babelrc for a long time(before webpack introduced this feature) which stripped comments from transpiled code and consequently broke this webpack feature.

But I removed this from the template back on June 22nd (8563cdb), so that should work, assuming you created your project after this date.

Could you verify that your .babelrc does not contain this setting?

Edit: Oh, I see you submitted a PR that changes something else. Nice, will check it out!

@SidKwok
Copy link
Contributor Author

SidKwok commented Oct 20, 2017

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "stage-2"
  ],
  "plugins": ["transform-runtime"],
  "env": {
    "test": {
      "presets": ["env", "stage-2"],
      "plugins": ["istanbul"]
    }
  }
}

The .babelrc seems fine. And if comments: false setting in .babelrc, the magic comments are not supposed to work. I send a PR and it should solve this issue.

@LinusBorg
Copy link
Contributor

Thanks for the PR, will merge it as soon as I found time to take it for a quick spin.

@LinusBorg LinusBorg added the bug label Oct 21, 2017
LinusBorg pushed a commit that referenced this issue Nov 16, 2017
…server. (#1072)

* replace `id` with `name` in chunk files, Fix #996

* fix typo

* remove env in `.babelrc` when not using unit or e2e

* remove `webpack.test.conf.js` when not using unit or e2e

* remove extra space in `.babelrc`

* enable `compress` in devServer by default

* remove `webpack.test.conf.js` when not using unit(karma) or e2e
@c0defre4k
Copy link
Contributor

c0defre4k commented Nov 17, 2017

Hi, I don't see this as a bug. In production this shouldn't matter because the chunk is named properly as you can see in the Chunk names column. Only the file is named numeric.

Please also note that using name instead of id generates bigger manifest since the mapping for name to id has to be stored somewhere. See here

Note that these filenames need to be generated at runtime to send the requests for chunks. Because of this, placeholders like [name] and [chunkhash] need to add a mapping from chunk id to placeholder value to the output bundle with the webpack runtime. This increases the size and may invalidate the bundle when placeholder value for any chunk changes.

In this case I'd like to undo this change.

edit: add quote

@SidKwok
Copy link
Contributor Author

SidKwok commented Nov 20, 2017

I see, it does have some side effects with [name]. And I agree that it shouldn't matter what the chunk name is in production, if the chunks are group together properly.

I think it's better to undo this change. @LinusBorg

@LinusBorg LinusBorg reopened this Nov 20, 2017
LinusBorg added a commit that referenced this issue Nov 21, 2017
* develop:
  bump v1.2.4
  revert #996 chunk names to minify prodution JS (#1086)
  fix missing comma
  Batman!
  add missing cacheBusting option
  make jest ignore the e2e test folder because its likely to contain files matching the jest's filename pattern
  Improved Jest config (#1074)
  Fix # 1070 When index.html has a positional variable, the error can be printed correctly (#1071)
  [enhancement]Remove useless files and performance enhancement in dev server. (#1072)
c0defre4k pushed a commit to neonblack-at/webpack that referenced this issue Nov 30, 2017
* vuejs-templates/master:
  bump v1.2.4
  Simplify elementCount custom assertions (vuejs-templates#898)
  revert vuejs-templates#996 chunk names to minify prodution JS (vuejs-templates#1086)
  fix missing comma
  Batman!
  add missing cacheBusting option
  make jest ignore the e2e test folder because its likely to contain files matching the jest's filename pattern
  Improved Jest config (vuejs-templates#1074)
  Fix # 1070 When index.html has a positional variable, the error can be printed correctly (vuejs-templates#1071)
  [enhancement]Remove useless files and performance enhancement in dev server. (vuejs-templates#1072)
frandiox pushed a commit to OnsenUI/vue-cordova-webpack that referenced this issue Dec 25, 2017
…server. (vuejs-templates#1072)

* replace `id` with `name` in chunk files, Fix vuejs-templates#996

* fix typo

* remove env in `.babelrc` when not using unit or e2e

* remove `webpack.test.conf.js` when not using unit or e2e

* remove extra space in `.babelrc`

* enable `compress` in devServer by default

* remove `webpack.test.conf.js` when not using unit(karma) or e2e
shenron pushed a commit to shenron/webpack that referenced this issue Mar 20, 2018
shenron pushed a commit to shenron/webpack that referenced this issue Mar 20, 2018
…server. (vuejs-templates#1072)

* replace `id` with `name` in chunk files, Fix vuejs-templates#996

* fix typo

* remove env in `.babelrc` when not using unit or e2e

* remove `webpack.test.conf.js` when not using unit or e2e

* remove extra space in `.babelrc`

* enable `compress` in devServer by default

* remove `webpack.test.conf.js` when not using unit(karma) or e2e
shenron pushed a commit to shenron/webpack that referenced this issue Mar 20, 2018
* develop:
  bump v1.2.4
  revert vuejs-templates#996 chunk names to minify prodution JS (vuejs-templates#1086)
  fix missing comma
  Batman!
  add missing cacheBusting option
  make jest ignore the e2e test folder because its likely to contain files matching the jest's filename pattern
  Improved Jest config (vuejs-templates#1074)
  Fix # 1070 When index.html has a positional variable, the error can be printed correctly (vuejs-templates#1071)
  [enhancement]Remove useless files and performance enhancement in dev server. (vuejs-templates#1072)
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