vuejs/vue-loader

Build is unstable when project is build in a different path

mvorisek opened this issue · 4 comments

https://github.com/atk4/ui/blob/dedb4cea3191e45ba2334ad48c0f98c6d25edf32/.github/workflows/test-unit.yml#L344 hack is needed to make babel build stable, otherwise a variable name in the resulting build is containing the resolved local path, making the build unstable

how to reproduce:

  1. checkout https://github.com/atk4/ui
  2. cd into js/ dir
  3. run npm install (without the patch from above applied) and npm run build
  4. notice the git changes in ../public/js dir containing a local path

@alexander-akait do you have an idea how to fix it or is a webpack issue instead?

Oh, missed your issue (not sure how it happens), give me time to look

@mvorisek

There is a small bug - https://github.com/vuejs/vue-loader/blob/main/src/index.ts#L285, it should be:

code += `\n\nimport exportComponent from ${stringifyRequest(exportHelperPath)}`;

and https://github.com/vuejs/vue-loader/blob/main/src/index.ts#LL47C1-L47C75, should be:

const exportHelperPath = require.resolve('./exportHelper');

stringifyRequest makes a request relative to context, so you will not have absolute paths and a code generation in the development mode will be more stable, you can send a PR with fix

This happened because you have node_modules inside js directory, but your source code in src and they are on the same level (i.e. js and src directories)