Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Use assetEmitted hook to mitigate futureEmitAssets = true #122

Merged
merged 1 commit into from
Dec 18, 2019

Conversation

qnighy
Copy link
Contributor

@qnighy qnighy commented Dec 10, 2019

Status

READY

Description

Webpack 4.39 introduced a new flag called futureEmitAssets which forbids referencing asset contents after emitting.

With futureEmitAssets = true, we observe the following error:

% yarn build
yarn run v1.19.2
$ react-app-rewired build --scripts-version react-scripts
Creating an optimized production build...
./node_modules/webpack/lib/Compiler.js:713
		throw this._error();
		^

Error: Content and Map of this Source is no longer available (only size() is supported)
    at SizeOnlySource._error (./node_modules/webpack/lib/Compiler.js:699:10)
    at SizeOnlySource.source (./node_modules/webpack/lib/Compiler.js:713:14)
    at HoneybadgerSourceMapPlugin.uploadSourceMap (./node_modules/honeybadger-webpack/dist/HoneybadgerSourceMapPlugin.js:168:67)
    at ./node_modules/honeybadger-webpack/node_modules/async/dist/async.js:2158:44
    at eachOfArrayLike (./node_modules/async/dist/async.js:504:13)
    at eachOf (./node_modules/async/dist/async.js:555:16)
    at awaitable(eachOf) (./node_modules/async/dist/async.js:208:32)
    at Object.eachLimit (./node_modules/async/dist/async.js:2220:16)
    at Object.awaitable(eachLimit) (./node_modules/async/dist/async.js:208:32)
    at HoneybadgerSourceMapPlugin.uploadSourceMaps (./node_modules/honeybadger-webpack/dist/HoneybadgerSourceMapPlugin.js:184:23)
    at HoneybadgerSourceMapPlugin.afterEmit (./node_modules/honeybadger-webpack/dist/HoneybadgerSourceMapPlugin.js:81:12)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (./node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook (./node_modules/tapable/lib/Hook.js:154:20)
    at ./node_modules/webpack/lib/Compiler.js:482:27
    at ./node_modules/neo-async/async.js:2818:7
    at done (./node_modules/neo-async/async.js:3522:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

futureEmitAssets = true will be forced in Webpack 5. create-react-app 3.x already configures futureEmitAssets = true.

Fortunately, webpack 4.41 introduced another hook to retrieve emitted assets. This PR uses this functionality to keep asset contents accessible.

Related PRs

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

@joshuap joshuap merged commit 4aa758d into honeybadger-io:master Dec 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants