I’m having a problem with the new auto tracing bundler and some dependencies I have in a common plugin we use.
The basics structure is that we have a bunch of elements, converters and services in a common UI library that is developed as an Aurelia plugin. This plugin has some dependencies like moment, numeral and nprogress. They are all declared in the package.json file under “dependencies”
This plugin compiles and worked fine when using the old aurelia-cli (using
aurelia.json to declare it) and using
(yarn/npm) link to pull this library in.
With the new bundler, it keeps giving me errors as below
ERROR [PackageAnalyzer] Unable to load package metadata (package.json) of numeral:
INFO [PackageAnalyzer] Error: cannot resolve npm package folder for "numeral"
ERROR [Bundler] Unable to analyze numeral
INFO [Bundler] Error: Unable to find package metadata (package.json) of numeral
ERROR [Bundler] Failed to add Nodejs module numeral
While it’s true that
node_modules does not contain the numeral package, it is available under
common-webui-folder is the name of the package where all these things are present.
As I said, this used to work, and while not exactly common to have external dependencies “linked” in via
(npm/yarn) link, I do believe it’s a valid environment that should be supported.
This also might be automated with the import instructions inside your plugins package.json @huochunpeng can definitely tell you more about it when hes back from vacation
Thanks, I had read that, and I know I can force it to be included. I don’t think it’s so much a problem of not being traced as it can’t find the code to include into the bundle. I have already fixed it by just doing
yarn add numeral in the actual app, and then it gets bundled just fine, even though I did not import it anywhere.
This is quite strange, npm v3 and above uses flat node_modules folder. It will only create nested node_modules folder if there is version conflict. When conflict happened, there should be at least a version of numeral at top node_modules level.
It is very strange that top level numeral is missing. Old cli would not automatically get nested package for you, it is likely due to some change in npm package management.
Is common-webui-folder installed from a privated git hosted repo? Could numeral be missplaced in devDeps?
It is quite a strange setup yes. common-web-ui is a local folder on the PC where the plugin is developed. It’s part of the Git repository, but it’s not a sub folder of the actual aurelia app. We use
npm link to register it with the npm cache, and then in the aurelia project folder we use
npm link common-webui-folder to symlink it into our
node_modules folder. npm then doesn’t register it in package.json, or resolve it’s dependencies, or anything like that.
The plugin is never “published” to npm, so we can’t
npm install it, and it wouldn’t work for us anyway even if we could since it is actively developed side by side with the other projects.
As an info and not a criticism, this really did work with the old cli (3 older projects using same common-webui-folder package that work), and a recent experiment with switching to webpack also included numeral in the bundle.
I could try and host a small repro on Github if you would like to have a look.
I think that sample would certainly help
Old cli needs explicit config for numeral, what was in aurelia.json?