embroider-build / embroider

Compiling Ember apps into spec-compliant, modern Javascript.
MIT License
331 stars 137 forks source link

babel loader config points at $TMPDIR #1647

Open chancancode opened 8 months ago

chancancode commented 8 months ago
/***/ "../../../../node_modules/@embroider/babel-loader-9/index.js?{\"variant\":{\"name\":\"dev\",\"runtime\":\"browser\",\"optimizeForProduction\":false},\"appBabelConfigPath\":\"/Users/godfrey/code/discourse/app/assets/javascripts/discourse/node_modules/.embroider/rewritten-app/_babel_config_.js\",\"cacheDirectory\":\"/private/var/folders/5_/psy9s2tj5h3csjy536v_cww00000gn/T/embroider/webpack-babel-loader\"}!../../../../node_modules/@embroider/webpack/src/virtual-loader.js?f=%2FUsers%2Fgodfrey%2Fcode%2Fdiscourse%2Fapp%2Fassets%2Fjavascripts%2Fnode_modules%2Fember-modifier%2F-embroider-implicit-test-modules.js&a=%2FUsers%2Fgodfrey%2Fcode%2Fdiscourse%2Fapp%2Fassets%2Fjavascripts%2Fdiscourse!":
/*!********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
  !*** ../../../../node_modules/@embroider/babel-loader-9/index.js?{"variant":{"name":"dev","runtime":"browser","optimizeForProduction":false},"appBabelConfigPath":"/Users/godfrey/code/discourse/app/assets/javascripts/discourse/node_modules/.embroider/rewritten-app/_babel_config_.js","cacheDirectory":"/private/var/folders/5_/psy9s2tj5h3csjy536v_cww00000gn/T/embroider/webpack-babel-loader"}!../../../../node_modules/@embroider/webpack/src/virtual-loader.js?f=%2FUsers%2Fgodfrey%2Fcode%2Fdiscourse%2Fapp%2Fassets%2Fjavascripts%2Fnode_modules%2Fember-modifier%2F-embroider-implicit-test-modules.js&a=%2FUsers%2Fgodfrey%2Fcode%2Fdiscourse%2Fapp%2Fassets%2Fjavascripts%2Fdiscourse! ***!
  \********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/***/ (() => {

let d = window.define;

/***/ }),

These kind of stuff gets into the development build as the module ids. We are also leaking the users's local path into the build. (In addition, there is also #1592.)

As a best practice, webpack suggests that we avoid doing these things as much as possible.

As far as I can tell, this does not affect prod builds, but it is very hard to tell if it actually got used as an implicit input to the process and just didn't surface in literal/verbatim form

chancancode commented 8 months ago

It seems like we need to:

  1. move the cache dir to somewhere within the app root like ./node_modules/.embroider
  2. relativize app the paths
  3. probably pass an additional param to babel-loader for it to find the app root (e.g. ../../..)

Unfortunately I am not sure I have all of the inner workings in my head to fix this properly. I tried patching a few obvious spots I found but that caused things to not resolve properly. I don't think this is fundamentally unsolvable or even very difficult, but there are just enough implicitly encoded assumptions scattered throughout that makes it a bit tricky for the uninitiated.

Probably faster for someone else to do this, but also happy to pair and learn.