fix dependency resolution - #69
Conversation
…ck or npx rollup to ensure access to node_modules and package.json
|
Maybe I should have reviewed the PR properly |
|
Maybe it could be fixed just by setting the working directory the command is run in? |
|
@ddtthh what would it take to get the tests to catch that? (the issue this PR is to fix) |
|
I understand it is not working on your end @ddtthh but the fixes proposed here are running global available rollup and webpack versions. The implementations as-was are using rollup and webpack versions defined in the build and installed in the npmInstall.dest path. Those should be referenced. It was working before 1.x migration and it is still working in master. Can we perhaps first check you test setup? Like what node versions did you try? Personally I am running 23.11 and on CI the default is 20.19.4. |
this is already set, e.g. |
|
I had to investigate a bit why the tests worked, but devBundle failed before my fix, as they use a js dependency as well. The reason is fastLinkJSTest symlinks node_modules etc. to fastLinkJSTest.dest and then calls bundle.apply(). As this is an anon task it runs in the same destination directory and node will find node_modules etc. bundleDev and bundleProd also call bundle but without symlinking before, so the dependencies are not available. My fix is basically moving this to bundle. The functionality could be removed from fastLinkJSTest symlinks node_modules etc. to fastLinkJSTest.dest and then calls bundle.apply(). As this is an anon task it runs in the same destination directory and node will find node_modules etc. bundleDev and bundleProd also call bundle but without symlinking before, so the dependencies are not available. My fix is basically moving this to bundle. The functionality could be removed from fastLinkJSTest. With respect to using npx: that could be reverted back to calling node directly. npx does use the locally installed version as well, I do not have a globally installed webpack/rollup. But npx does not seem to be available in the windows integration pipeline. This seems to be why the tests fail now for windows. We could also call "npm exec webpack/rollup". I've created a sample project to test this: https://github.com/ddtthh/millbundler-example Some unrelated remarks:
|
It could be set to npmInstall.dest, then the output would somehow have to be explicitly be set to be generated in Task.dest. But I had issues with non-standard project layouts and files outside of the project trees in the past. It's probably most robust to setup a standard project layout with input and output files contained in sub directories of the directory containing node_modules and package.js. |
|
@ddtthh |
I've tried the current master branch and found that it fails to resolve js dependencies completely. The dependencies are installed in the respective node_modules directories and listed in package.json, but the way rollup and webpack are run, they fail to find them.
I did not find any command line options of npm/npx nor webpack/rollup to fix this. So my solution is to symlink the contents of npmInstall.dest into bundle.dest and then run webpack/rollup using npx.
I'm not sure this works on windows, but the code uses symlinks already, so I've assumed it is fine, and in theory at least, windows supports symlinks.
Maybe there's a better solution, but as I had to get this running anyway, I wanted to share it.