Dependencies are bundled in the wrong order
See original GitHub issueIf you create a new default typescript project, add bootstrap and jQuery, then apply the dependency to the bundle as documented it works:
"dependencies": [
"jquery",
{
"name": "bootstrap",
"path": "../node_modules/bootstrap/dist",
"main": "js/bootstrap.min",
"deps": ["jquery"],
"exports": "$"
}
]
Now, remove jasmine from the project (don’t ask, I had to experiment to find the error in my project) and the vendor bundle contains bootstrap before jQuery, so the application fails on startup.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:23 (10 by maintainers)
Top Results From Across the Web
Webpack bundles my files in the wrong order ... - Stack Overflow
Tools tell me there are dependency issues. When I view the file through the tool and my IDE, it is bundled in the...
Read more >Dependency Pre-Bundling - Vite
Dependency pre-bundling only applies in development mode, and uses esbuild to convert dependencies to ESM. In production builds, @rollup/plugin-commonjs is used ...
Read more >Resolving Dependencies - Bndtools
The OSGi Framework has always used a resolver to wire a given set of bundles together, ensuring that only valid wires are made....
Read more >Introduction to the Dependency Mechanism - Apache Maven
Dependency scope is used to limit the transitivity of a dependency and to determine when a dependency is included in a classpath. There...
Read more >Upgrading your build from Gradle 5.x to 6.0
Updates to bundled Gradle dependencies ... dependency graphs, have a wrong result or a randomized dependency order when lots of excludes were present....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I may have some input to this one.
I wrote a fix for a deeper source location possibility (src file not in root folder): https://github.com/aurelia/cli/pull/427 During the progress i found some strange things happening to the dependency load order too - since i do some asynchronous folder lookups, the dependency order came wrong in most cases.
I tracked this issue down and found the bad-boy. (Fixed it also in the pull request) The issue seems to have its root in the
aurelia-cli/lib/build/bundle.js
file in the code:bundler.configureDependency
is an asynchronous task. since allconfigureDependency
get called at one point and are waiting for finish, the promises are able to resolve in different order than they occur in thedependencies
array and are therefore also added to the bundle in a different order.I fixed this with the following:
This code waits for all promises to be done and then adds the descriptions in the order as they have been in the
dependencies
array.I hope this clears things up a bit.
A workaround for this is to use prepend For instance instead of adding jquery to the dependencies, use
"prepend": ["node_modules/jquery/dist/jquery.js"]