dojo / cli-build-app

Command for building Dojo applications
Other
9 stars 32 forks source link

Cyclic dependency errors with @arcgis/core package #450

Closed odoe closed 3 years ago

odoe commented 3 years ago

If I try to build an app using @arcgis/core, I get a number of cyclic dependency errors.

⠇ building(node:47851) UnhandledPromiseRejectionWarning: Error: Cyclic dependency
    at visit (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/toposort/index.js:35:13)
    at visit (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/toposort/index.js:53:9)
    at visit (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/toposort/index.js:53:9)
    at visit (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/toposort/index.js:53:9)
    at visit (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/toposort/index.js:53:9)
    at visit (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/toposort/index.js:53:9)
    at Function.toposort [as array] (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/toposort/index.js:22:22)
    at Object.module.exports.dependency (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/html-webpack-plugin/lib/chunksorter.js:50:35)
    at HtmlWebpackPlugin.sortChunks (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/html-webpack-plugin/index.js:364:35)
    at /Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/html-webpack-plugin/index.js:113:21
    at _next0 (eval at create (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:21:1)
    at eval (eval at create (/Users/odoe/dev/test-apps/dojo-test-arcgis/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:36:1)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)

This happens with @dojo/cli-build-app v7 and the v8-alpha-3 version.

Bug??

There might be circular dependencies in @arcgis/core, but no other build tools throw this error, so I'm not sure if it's just some setting in the build pipeline that is extra strict or what the issue might be.

Package Version:

7.0.0 8.0.0-alpha.3

Code

I put a test app here. https://github.com/odoe/dojo-test-arcgis

Expected behavior:

Actual behavior:

odoe commented 3 years ago

I think I traced the issue down. I was able to get a better error message by changing the webpack dev.config based on this response to the same issue I was having. https://github.com/marcelklehr/toposort/issues/20#issuecomment-487128573

The error seems to stem from using try/catch without defining an error.

// fails to build
try {
    something();
} catch {}

// this works
try {
    something();
} catch (err) {}

Does the dojo build not support es2019 esm?

agubler commented 3 years ago

@odoe, @matt-gadd and I tracked down the issue to the html-webpack-plugin and have landed a PR that uses the latest version compatible with webpack 4 (that doesn't use toposort) - I think this is something that we could back port to v7, is that something that you would be interested in?

odoe commented 3 years ago

@agubler a backport would be very helpful for us, thanks!

agubler commented 3 years ago

@odoe Ran into another error during the build (different area) after resolving this one, will continue to look into it - once resolved as long as possible we'll look to back port

agubler commented 3 years ago

@odoe I think we resolved the other build issues and have backported the changes on version 7.0.5, could you give it a try for us?

odoe commented 3 years ago

That works great @agubler! Thanks a lot, now we can better demo use of our API with dojo, much appreciated!

odoe commented 3 years ago

I think I spoke too soon. In a fresh project with 7.0.5, I get this error in a build, even without our arcgis package.

./node_modules/@dojo/webpack-contrib/bootstrap-plugin/async.js
Module build failed (from ./node_modules/@dojo/webpack-contrib/static-build-loader/index.js):
agubler commented 3 years ago

That seems strange. We’ll try and have a look tomorrow.

agubler commented 3 years ago

@odoe I can reproduce, it's a problem we caused on the backport! Luckily we never made it latest so most consumers will still be on 7.0.6 - phew - thanks for letting us know

agubler commented 3 years ago

@odoe did you create a fresh project then manually install 7.0.5 independently? I reproduced the error earlier when doing that, but then I remove node_modules and package-lock.json and the error no longer happens. Could you give that a try for me?

odoe commented 3 years ago

Lol, ok, that works. Thanks!

agubler commented 3 years ago

@odoe Excellent, it looks like it is something to do with how the dependencies are installed which is annoying.

denov commented 3 years ago

7.0.5 seem to fix this this error for me as well.

i couldn't upgrade to 7.0.5 from 7.0.0. i got some other strange webpack error. it did work with a fresh install after removing node_modules and package-lock.json