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

Source maps missing for non-entry chunks after rebuild #4086

Closed
richvdh opened this issue Jan 23, 2017 · 7 comments
Closed

Source maps missing for non-entry chunks after rebuild #4086

richvdh opened this issue Jan 23, 2017 · 7 comments

Comments

@richvdh
Copy link

richvdh commented Jan 23, 2017

Do you want to request a feature or report a bug?
Looks like a bug.

What is the current behavior?
Using webpack-dev-server, on a rebuild, non-entry chunks are regenerated with a new compliation hash in the filename, but the sourcemaps are not regenerated.

If the current behavior is a bug, please provide the steps to reproduce.

  1. In a project using code-splitting:
  2. In config:
  • Include [hash] in output.chunkFilename
  • set devtool: 'source'
  1. Start webpack-dev-server
  2. Modify content of entry chunk
  3. Try to load source-map for secondary chunk.

See https://github.com/richvdh/webpack-bug-demo for a minimal repo demonstrating this problem.

What is the expected behavior?
Webpack should serve the sourcemap for the secondary chunk with the new filename.

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
Webpack 1.14.0; webpack-dev-server 1.16.2; node 5.0.0; Linux.

@richvdh
Copy link
Author

richvdh commented Jan 23, 2017

The output from the rebuild is something like:

webpack: bundle is now INVALID.
Hash: 1b1122737f7c1628ed4f
Version: webpack 1.14.0
Time: 19ms
                    Asset       Size  Chunks             Chunk Names
                bundle.js    3.96 kB       0  [emitted]  main
1b1122737f7c1628ed4f/1.js  117 bytes       1  [emitted]  
            bundle.js.map    4.02 kB       0  [emitted]  main
chunk    {0} bundle.js, bundle.js.map (main) 165 bytes [rendered]
    [0] ./main.js 165 bytes {0} [built]
chunk    {1} 1b1122737f7c1628ed4f/1.js, c62c1f97e3af83189928/1.js, c62c1f97e3af83189928/1.js.map 32 bytes {0}
     + 1 hidden modules
webpack: bundle is now VALID.

Note that chunk 1 is being generated for both the old and new hashes (c62c1f97e3af83189928 and 1b1122737f7c1628ed4f, respectively), but the sourcemap is only generated for the old hash.

@sokra
Copy link
Member

sokra commented Jan 25, 2017

I have a fix, but no time to write tests for this currently.

@sokra
Copy link
Member

sokra commented Jan 25, 2017

Using [hash] in chunkFilename is maybe a bad choice...

@richvdh
Copy link
Author

richvdh commented Jan 25, 2017

Using [hash] in chunkFilename is maybe a bad choice...

I'd be interested to hear if you have better suggestions. The thinking behind putting [hash] there went as follows:

  • When we deploy a new version of our application to our production server, we want people using the old version of the app not to see errors.
  • That means we need to keep the old versions of the chunks available as well as the new ones.
  • But we don't want our production server to fill up with hundreds of old chunk files.
  • By putting [hash] in the filenames, we can clean out directories corresponding to old versions of the app once we are satisfied that nobody is using them.

@richvdh
Copy link
Author

richvdh commented Jan 25, 2017

tbh we worked around this by using a hardcoded string instead of [hash] when running the dev server - but obviously it's preferable to minimise differences between production and dev, and this took me somewhat by surprise.

@sokra
Copy link
Member

sokra commented Jan 26, 2017

[chunkhash] is the better option, as it reused old cached chunks when only a small part of the app changes.

@sokra
Copy link
Member

sokra commented Jan 26, 2017

Anyway, you should be able to do it the [hash] way. If you want to you can finish my PR with tests and we can merge it.

@sokra sokra closed this as completed in 546fe6d Apr 4, 2017
sokra added a commit that referenced this issue Apr 4, 2017
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

No branches or pull requests

2 participants