Comments (32)
I'm so sorry folks. v1.0.6 is out now, which reverts #19
from toposort.
@WiseBird I found that error happiness if html-webpack-plugin uses default chunksSortMode parameter.
For example, you can change it in the following way:
new HtmlWebpackPlugin({
"template": "./src/index.html",
"filename": "./index.html",
"hash": false,
"inject": true,
"compile": true,
"favicon": false,
"minify": false,
"cache": true,
"showErrors": true,
"chunks": "all",
"excludeChunks": [],
"title": "Webpack App",
"xhtml": true,
"chunksSortMode": 'none'
}
}),
Or use your special function. For example:
const entryPoints = ["inline","polyfills","sw-register","styles","vendor","main"];
...
chunksSortMode: function sort(left, right) {
let leftIndex = entryPoints.indexOf(left.names[0]);
let rightIndex = entryPoints.indexOf(right.names[0]);
if (leftIndex > rightIndex) {
return 1;
}
else if (leftIndex < rightIndex) {
return -1;
}
else {
return 0;
}
}
...
from toposort.
throw new Error('Cyclic dependency: '+JSON.stringify(node))
and followed by same output as above.
Not much changed in terms of environment that this is ran in, hence pinpointing it down to latest release
from toposort.
Thanks for quick turnaround!
from toposort.
i'm seeing this error with 1.0.7 in a dojo project
$ npm list toposort
[email protected] C:\development\projects\xxx\project
`-- @dojo/[email protected]
`-- [email protected]
`-- [email protected]
change chucksSortMode
to none
fixes it
from toposort.
I also get this error without specifying chunksSortMode
as none
.
from toposort.
@seanlandsman I think webpack is whats failing us as well, how did you downgrade toposort for it specifically? Never did it before for specific packages, would be cool to know :)
from toposort.
npm install [email protected]
from toposort.
@laurentpayot there already is one: jantimon/html-webpack-plugin#870 ;)
from toposort.
I'm using yarn, and added this to my package.json:
"resolutions": {
"toposort": "1.0.4"
}
from toposort.
+1 not too happy, respect semver! :(
from toposort.
Reproduction in case anyone needs it. Error is thrown when building angular app in AoT mode.
from toposort.
+1
from toposort.
+1
from toposort.
For me too - the fix on my side was to downgrade the version of toposort to 1.0.4.
I didn't actually reference this dependency directly - webpack does - just fyi.
from toposort.
+1
from toposort.
+1 - affects html webpack plugin
from toposort.
+1
from toposort.
+1
from toposort.
We're also hitting this. :(
from toposort.
@iljadaderko I added this to package.json
"toposort":"1.0.4"
thanks
from toposort.
+1
from toposort.
+1
from toposort.
+1
from toposort.
+1
from toposort.
thanks for the quick fix. Our production build failed yesterday since it's the dependency of html-webpack-plugin
from toposort.
UPDATE: there's a workaround provided in jantimon/html-webpack-plugin#870 which is working for me at the moment. I'm leaving this comment up in case anybody else is affected.
I'm currently hitting this error in 1.0.6 too (through html-webpack-plugin
).
> npm list toposort
[email protected] /Users/aditya/dev/rekrn
└─┬ [email protected]
└─┬ [email protected]
└── [email protected]
I made a new and clean repo to try and reproduce it but wasn't able to:
> npm list toposort
[email protected] /Users/aditya/dev/testwebpack4
└─┬ [email protected]
└─┬ [email protected]
└── [email protected]
Any help will be appreciated.
Full error dump:
95% emitting HtmlWebpackPlugin/Users/aditya/dev/rekrn/node_modules/html-webpack-plugin/node_modules/toposort/index.js:29
throw new Error('Cyclic dependency: '+JSON.stringify(node))
^
TypeError: Converting circular structure to JSON
at JSON.stringify (<anonymous>)
at visit (/Users/aditya/dev/rekrn/node_modules/html-webpack-plugin/node_modules/toposort/index.js:29:50)
at visit (/Users/aditya/dev/rekrn/node_modules/html-webpack-plugin/node_modules/toposort/index.js:47:9)
at visit (/Users/aditya/dev/rekrn/node_modules/html-webpack-plugin/node_modules/toposort/index.js:47:9)
at visit (/Users/aditya/dev/rekrn/node_modules/html-webpack-plugin/node_modules/toposort/index.js:47:9)
at Function.toposort [as array] (/Users/aditya/dev/rekrn/node_modules/html-webpack-plugin/node_modules/toposort/index.js:22:22)
at Object.module.exports.dependency (/Users/aditya/dev/rekrn/node_modules/html-webpack-plugin/lib/chunksorter.js:50:35)
at HtmlWebpackPlugin.sortChunks (/Users/aditya/dev/rekrn/node_modules/html-webpack-plugin/index.js:364:35)
at /Users/aditya/dev/rekrn/node_modules/html-webpack-plugin/index.js:113:21
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/aditya/dev/rekrn/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:14:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/Users/aditya/dev/rekrn/node_modules/tapable/lib/Hook.js:35:21)
at Compiler.emitAssets (/Users/aditya/dev/rekrn/node_modules/webpack/lib/Compiler.js:305:19)
at onCompiled (/Users/aditya/dev/rekrn/node_modules/webpack/lib/Watching.js:50:19)
at hooks.afterCompile.callAsync.err (/Users/aditya/dev/rekrn/node_modules/webpack/lib/Compiler.js:485:14)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/aditya/dev/rekrn/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:15:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/Users/aditya/dev/rekrn/node_modules/tapable/lib/Hook.js:35:21)
from toposort.
Sorry for my absence. Can you reproduce this with toposort only? Alternatively, what does the dependency graph look like?
from toposort.
So, when I run the build script for the reproduction repo, I get the following edges of the dependency graph:
5005 => 5004,
5003 => 5004,
5004 => 5005,
5003 => 5005
Clearly, there is a cyclic dependency between 5005 and 5004. The only "bug" in toposort, is the type error, if you will, which I'll fix now. :)
from toposort.
I found that error happiness if html-webpack-plugin uses default chunksSortMode parameter.
@sumbad do you mean that this cyclic dependency error does not occur when chunksSortMode
option of HtmlWebpackPlugin is set to 'none'
?
If that's what you mean then it's the same for me since I switched to webpack 4.
Should we open an HtmlWebpackPlugin issue?
from toposort.
@WiseBird I found that error happiness if html-webpack-plugin uses default chunksSortMode parameter.
For example, you can change it in the following way:new HtmlWebpackPlugin({ "template": "./src/index.html", "filename": "./index.html", "hash": false, "inject": true, "compile": true, "favicon": false, "minify": false, "cache": true, "showErrors": true, "chunks": "all", "excludeChunks": [], "title": "Webpack App", "xhtml": true, "chunksSortMode": 'none' } }),
Or use your special function. For example:
const entryPoints = ["inline","polyfills","sw-register","styles","vendor","main"]; ... chunksSortMode: function sort(left, right) { let leftIndex = entryPoints.indexOf(left.names[0]); let rightIndex = entryPoints.indexOf(right.names[0]); if (leftIndex > rightIndex) { return 1; } else if (leftIndex < rightIndex) { return -1; } else { return 0; } } ...
厉害了我的哥
from toposort.
@WiseBird I found that error happiness if html-webpack-plugin uses default chunksSortMode parameter.
For example, you can change it in the following way:new HtmlWebpackPlugin({ "template": "./src/index.html", "filename": "./index.html", "hash": false, "inject": true, "compile": true, "favicon": false, "minify": false, "cache": true, "showErrors": true, "chunks": "all", "excludeChunks": [], "title": "Webpack App", "xhtml": true, "chunksSortMode": 'none' } }),
Or use your special function. For example:
const entryPoints = ["inline","polyfills","sw-register","styles","vendor","main"]; ... chunksSortMode: function sort(left, right) { let leftIndex = entryPoints.indexOf(left.names[0]); let rightIndex = entryPoints.indexOf(right.names[0]); if (leftIndex > rightIndex) { return 1; } else if (leftIndex < rightIndex) { return -1; } else { return 0; } } ...
yes, change to chucksSortMode to none in webpack config file fixes it
from toposort.
Related Issues (16)
- Does not work for nodes that have multiple dependencies HOT 3
- Throws "cyclic dependency" error where there is none HOT 2
- How do you handle a node that has no dependency on anything else? HOT 2
- Wrong sort example? HOT 1
- vertices not specified in nodes causes unpredictable behaviour HOT 3
- Doc from NPM is completely wrong HOT 1
- Version 1.0.0 HOT 1
- What changed for 1.0 HOT 1
- Exclude graph.jpg from (NPM) package HOT 2
- Is this tool able to detect circular dependencies? HOT 2
- Allow passing a sort function as a tie breaker
- Error in the "Unknown Node" test and Vows runner hangs HOT 2
- Still having : throw new Error('Cyclic dependency: '+JSON.stringify(node)) HOT 9
- On Cyclical Dependency Error: Include Id Property In Error Object?
- Deno support HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toposort.