You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run ember serve, then edit a file to cause a rebuild.
Result
The rebuild fails with this error:
ERROR Summary:
- broccoliBuilderErrorStack: TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Compiler'
--- property 'root' closes the circle
at JSON.stringify (<anonymous>)
at stringify (/private/tmp/test-app/node_modules/fs-extra/node_modules/jsonfile/utils.js:3:20)
at outputJsonSync (/private/tmp/test-app/node_modules/fs-extra/lib/json/output-json-sync.js:7:15)
at AppBuilder.addResolverConfig (/private/tmp/test-app/node_modules/@embroider/core/src/app.js:966:35)
at AppBuilder.build (/private/tmp/test-app/node_modules/@embroider/core/src/app.js:887:10)
at async WaitForTrees.buildHook (/private/tmp/test-app/node_modules/@embroider/core/src/build-stage.js:33:13)
- code: [undefined]
- codeFrame: Converting circular structure to JSON
--> starting at object with constructor 'Compiler'
--- property 'root' closes the circle
- errorMessage: Converting circular structure to JSON
--> starting at object with constructor 'Compiler'
--- property 'root' closes the circle
at WaitForTrees (@embroider/compat/app)
-~- created here: -~-
at new Plugin (/private/tmp/test-app/node_modules/@embroider/core/node_modules/broccoli-plugin/dist/index.js:47:36)
at new WaitForTrees (/private/tmp/test-app/node_modules/@embroider/core/src/wait-for-trees.js:30:9)
at CompatApp.get tree (/private/tmp/test-app/node_modules/@embroider/core/src/build-stage.js:25:16)
at CompatApp.<anonymous> (/private/tmp/test-app/node_modules/typescript-memoize/dist/memoize-decorator.js:132:52)
at new PackagerRunner (/private/tmp/test-app/node_modules/@embroider/core/src/to-broccoli-plugin.js:11:26)
at Object.defaultPipeline (/private/tmp/test-app/node_modules/@embroider/compat/src/default-pipeline.js:50:12)
at module.exports (/private/tmp/test-app/ember-cli-build.js:12:39)
at Builder.readBuildFile (/private/tmp/test-app/node_modules/ember-cli/lib/models/builder.js:48:20)
at async Builder.setupBroccoliBuilder (/private/tmp/test-app/node_modules/ember-cli/lib/models/builder.js:68:17)
at async Builder.ensureBroccoliBuilder (/private/tmp/test-app/node_modules/ember-cli/lib/models/builder.js:56:7)
Analysis
When the webpack-bundle-analyzer plugin's apply() is called, it caches a copy of the compiler object on itself. That object contains a reference back to the plugin, creating a circular reference. When embroider tries to write out the resolver config on a rebuild, it fails because the config options now contain a circular reference and are not JSON stringifiable.
In general, I think it looks like the webpack config is not guaranteed to be JSON stringifiable, so trying to stringify the whole configuration isn't a safe thing to do. Perhaps CompatAppAdapter.resolverConfig() should not be returning its entire CompatResolverOptions, but instead filtering them down to only the fields needed to implement the module resolver options? Or addResolverConfig() should prune down the object it receives to just the set of fields that match the interface?
The text was updated successfully, but these errors were encountered:
Reproduction
$ npx ember-cli new test-app $ cd test-app/ $ yarn add --dev @embroider/core @embroider/compat @embroider/webpack webpack webpack-bundle-analyzer
edit
ember-cli-build.js
to look like:run
ember serve
, then edit a file to cause a rebuild.Result
The rebuild fails with this error:
Analysis
When the
webpack-bundle-analyzer
plugin'sapply()
is called, it caches a copy of the compiler object on itself. That object contains a reference back to the plugin, creating a circular reference. When embroider tries to write out the resolver config on a rebuild, it fails because the config options now contain a circular reference and are not JSON stringifiable.In general, I think it looks like the webpack config is not guaranteed to be JSON stringifiable, so trying to stringify the whole configuration isn't a safe thing to do. Perhaps
CompatAppAdapter.resolverConfig()
should not be returning its entireCompatResolverOptions
, but instead filtering them down to only the fields needed to implement the module resolver options? OraddResolverConfig()
should prune down the object it receives to just the set of fields that match the interface?The text was updated successfully, but these errors were encountered: