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

replace after emit logic for webpack v4.29+ #61

Closed
whollacsek opened this issue Jan 30, 2019 · 10 comments · Fixed by #314
Closed

replace after emit logic for webpack v4.29+ #61

whollacsek opened this issue Jan 30, 2019 · 10 comments · Fixed by #314

Comments

@whollacsek
Copy link

Webpack v4.29.0 introduced output.futureEmitAssets which breaks this plugin. From the release:

  • assets are replaced with SizeOnlySources
  • reading assets after emitting is no longer allowed

https://github.com/webpack/webpack/pull/8642/files

@sslotsky
Copy link

sslotsky commented Mar 1, 2019

Running into this issue as well. The stack trace:

/home/sam/manifold-www/node_modules/webpack/lib/Compiler.js:661
		throw this._error();
		^

Error: Content and Map of this Source is no longer available (only size() is supported)
    at SizeOnlySource._error (/home/sam/manifold-www/node_modules/webpack/lib/Compiler.js:647:10)
    at SizeOnlySource.source (/home/sam/manifold-www/node_modules/webpack/lib/Compiler.js:661:14)
    at RollbarSourceMapPlugin.uploadSourceMap (/home/sam/manifold-www/node_modules/rollbar-sourcemap-webpack-plugin/dist/RollbarSourceMapPlugin.js:180:63)
    at /home/sam/manifold-www/node_modules/async/dist/async.js:3110:16
    at eachOfArrayLike (/home/sam/manifold-www/node_modules/async/dist/async.js:1069:9)
    at eachOf (/home/sam/manifold-www/node_modules/async/dist/async.js:1117:5)
    at Object.eachLimit (/home/sam/manifold-www/node_modules/async/dist/async.js:3172:5)
    at RollbarSourceMapPlugin.uploadSourceMaps (/home/sam/manifold-www/node_modules/rollbar-sourcemap-webpack-plugin/dist/RollbarSourceMapPlugin.js:191:23)
    at RollbarSourceMapPlugin.afterEmit (/home/sam/manifold-www/node_modules/rollbar-sourcemap-webpack-plugin/dist/RollbarSourceMapPlugin.js:83:12)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/sam/manifold-www/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook (/home/sam/manifold-www/node_modules/tapable/lib/Hook.js:154:20)
    at asyncLib.forEachLimit.err (/home/sam/manifold-www/node_modules/webpack/lib/Compiler.js:432:27)
    at /home/sam/manifold-www/node_modules/neo-async/async.js:2813:7
    at done (/home/sam/manifold-www/node_modules/neo-async/async.js:3521:9)
    at outputFileSystem.writeFile.err (/home/sam/manifold-www/node_modules/webpack/lib/Compiler.js:400:9)
    at /home/sam/manifold-www/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)
error Command failed with exit code 1.

Anything we can do to work around, or any suggestions for submitting a fix?

@nisargrthakkar
Copy link

Getting same error

var/www/html/bannerbuzz-reactjs/node_modules/webpack/lib/Compiler.js:661
throw this._error();
^
Error: Content and Map of this Source is no longer available (only size() is supported)
at SizeOnlySource._error (/var/www/html/bannerbuzz-reactjs/node_modules/webpack/lib/Compiler.js:647:10)
at SizeOnlySource.source (/var/www/html/bannerbuzz-reactjs/node_modules/webpack/lib/Compiler.js:661:14)
at RollbarSourceMapPlugin.uploadSourceMap (/var/www/html/bannerbuzz-reactjs/node_modules/rollbar-sourcemap-webpack-plugin/dist/RollbarSourceMapPlugin.js:180:63)
at /var/www/html/bannerbuzz-reactjs/node_modules/async/dist/async.js:3110:16
at eachOfArrayLike (/var/www/html/bannerbuzz-reactjs/node_modules/async/dist/async.js:1069:9)
at eachOf (/var/www/html/bannerbuzz-reactjs/node_modules/async/dist/async.js:1117:5)
at Object.eachLimit (/var/www/html/bannerbuzz-reactjs/node_modules/async/dist/async.js:3172:5)
at RollbarSourceMapPlugin.uploadSourceMaps (/var/www/html/bannerbuzz-reactjs/node_modules/rollbar-sourcemap-webpack-plugin/dist/RollbarSourceMapPlugin.js:191:23)
at RollbarSourceMapPlugin.afterEmit (/var/www/html/bannerbuzz-reactjs/node_modules/rollbar-sourcemap-webpack-plugin/dist/RollbarSourceMapPlugin.js:83:12)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/var/www/html/bannerbuzz-reactjs/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:7:1)
at AsyncSeriesHook.lazyCompileHook (/var/www/html/bannerbuzz-reactjs/node_modules/tapable/lib/Hook.js:154:20)
at asyncLib.forEachLimit.err (/var/www/html/bannerbuzz-reactjs/node_modules/webpack/lib/Compiler.js:432:27)
at /var/www/html/bannerbuzz-reactjs/node_modules/neo-async/async.js:2813:7
at done (/var/www/html/bannerbuzz-reactjs/node_modules/neo-async/async.js:3521:9)
at outputFileSystem.writeFile.err (/var/www/html/bannerbuzz-reactjs/node_modules/webpack/lib/Compiler.js:400:9)
at /var/www/html/bannerbuzz-reactjs/node_modules/graceful-fs/graceful-fs.js:45:10
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@stubar
Copy link

stubar commented May 24, 2019

Until this PR get's merged we can use
config.output.futureEmitAssets = false;

@nisargrthakkar
Copy link

Any update on this?

@FoxxMD
Copy link

FoxxMD commented Feb 4, 2020

Helpful tip for anyone stumbling across this you can use patch-package along with code changes in #64 to fix this without using futureEmitAssets

@brandondoran
Copy link
Collaborator

brandondoran commented Feb 8, 2020

I will look into fixing but as I understand it, output.futureEmitAssets is a way to opt in to webpack v5 behavior pre release. And this is disabled by default in v4. So it seems like we have a temp workaround by just leaving this option disabled.

#64 doesn't look like the right fix. I think we can fix by taking a similar approach as in webpack/webpack#8883

@cain
Copy link

cain commented Feb 16, 2020

Also getting this issue with nuxtJS, please keep us updated if a fix goes into a release :)

Is it safe to use output.futureEmitAssets and will it change anything?

brandondoran added a commit that referenced this issue Oct 13, 2020
Webpack v4.29.0 introduced output.futureEmitAssets, which breaks the plugin
when enabled. This is because we no longer have access to sourcemap
contents. To work around this we can tap into the emittedAssets hook and
keeo a map of sourceMaps and the content to be uploaded oncee asseets
are emitted. This should work in webpack 4 and 5 and be end users should
not notice any change in behavior.

fixes #61 and closes #64
@mskelton
Copy link
Contributor

I see that there appears to be some work being done on this recently on the rework-after-emit branch. Any way I can help to push this across the finish line so that webpack 5 users (like me) can start using this plugin again?

@brandondoran
Copy link
Collaborator

brandondoran commented Dec 4, 2020

@mskelton yes rework-after-emit branch was effort to add support for Webpack 4.29+ with futureEmitAssets enabled. The hope was it would just work in v5 but turns out more is needed as its seems there's fairly major changes to the plugin architecture. At the time (just after v5 became "stable") there wasn't really any documentation. It seems that supporting v4 and v5 may in same version of plugin might be tricky. I'll try devote some time to this.

@mskelton
Copy link
Contributor

mskelton commented Dec 4, 2020

@brandondoran Thanks for the update, let me know if I can help in any way. FWIW html-webpack-plugin is taking the same approach of having a new major version that is just for webpack 5 and won't support webpack 4.

jantimon/html-webpack-plugin#1527

brandondoran added a commit that referenced this issue Dec 4, 2020
Webpack 4.29.0 introduced this option, which when enabled, breaks this
plugin. The fix is to read the file contents from disk after emit
instead of depending on the sources being available in the compilation.

closes #61
brandondoran added a commit that referenced this issue Dec 4, 2020
)

Webpack 4.29.0 introduced this option, which when enabled, breaks this
plugin. The fix is to read the file contents from disk after emit
instead of depending on the sources being available in the compilation.

closes #61
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

Successfully merging a pull request may close this issue.

8 participants