Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main + v3, webpack]: Resolver is not compatible with virtual files which import from the app #1843

Closed
NullVoxPopuli opened this issue Mar 15, 2024 · 2 comments

Comments

@NullVoxPopuli
Copy link
Collaborator

NullVoxPopuli commented Mar 15, 2024

Repro here: https://github.com/NullVoxPopuli/embroider-3--unplugin-plugin-loads-app-files

My virtual file is basically this:

      importPath: 'build-plugin/registry',
      content: stripIndent`
        export const map = {
          foo: () => import('./components/foo.js'),
        };
	export function setup() {
          window.myRegistry = map;
	}
  	`,

and when I use it:

import * as virtualModule from 'build-plugin/registry';

// sets window.myRegistry, so we can inspect
virtualModule.setup();

I get a build time error:

Build Error (PackagerRunner) in ../../../_virtual_~build-plugin%2Fregistry

Module not found: Error: bug: embroider resolver's meta is not propagating
full report
=================================================================================

ENV Summary:

  TIME: Fri Mar 15 2024 10:08:28 GMT-0400 (Eastern Daylight Time)
  TITLE: ember
  ARGV:
  - 🏠/.volta/tools/image/node/18.19.0/bin/node
  - <repo>/node_modules/ember-cli/bin/ember
  - serve
  EXEC_PATH: 🏠/.volta/tools/image/node/18.19.0/bin/node
  TMPDIR: /tmp
  SHELL: /bin/bash
  PATH:
  - <repo>/node_modules/.bin
  - 🏠/.volta/tools/image/pnpm/8.10.2/dist/node-gyp-bin
  - 🏠/.volta/tools/image/pnpm/8.10.2/bin
  - 🏠/.volta/tools/image/yarn/1.22.19/bin
  - 🏠/.volta/tools/image/node/18.19.0/bin
  - 🏠/.local/bin
  - 🏠/.deno/bin
  - 🏠/.volta/bin
  - /tmp/frum_687489_1710510983110/bin
  - 🏠/.cargo/bin
  - 🏠/Applications
  - 🏠/apps/phantomjs/bin
  - 🏠/scripts/system-utils
  - 🏠/scripts/node
  - 🏠/scripts/git
  - 🏠/scripts/rails
  - 🏠/scripts
  - 🏠/.cargo/bin
  - 🏠/.volta/bin
  - 🏠/.local/bin
  - /usr/local/sbin
  - /usr/local/bin
  - /usr/sbin
  - /usr/bin
  - /sbin
  - /bin
  - /usr/games
  - /usr/local/games
  - /snap/bin
  - /snap/bin
  PLATFORM: linux x64
  FREEMEM: 23549485056
  TOTALMEM: 66550095872
  UPTIME: 88342.09
  LOADAVG: 0.73,0.63,0.68
  CPUS:
  - AMD Ryzen 9 7900X 12-Core Processor - 5133
  - AMD Ryzen 9 7900X 12-Core Processor - 5209
  - AMD Ryzen 9 7900X 12-Core Processor - 5222
  - AMD Ryzen 9 7900X 12-Core Processor - 5059
  - AMD Ryzen 9 7900X 12-Core Processor - 3478
  - AMD Ryzen 9 7900X 12-Core Processor - 3436
  - AMD Ryzen 9 7900X 12-Core Processor - 3474
  - AMD Ryzen 9 7900X 12-Core Processor - 4048
  - AMD Ryzen 9 7900X 12-Core Processor - 5223
  - AMD Ryzen 9 7900X 12-Core Processor - 5207
  - AMD Ryzen 9 7900X 12-Core Processor - 3405
  - AMD Ryzen 9 7900X 12-Core Processor - 4846
  - AMD Ryzen 9 7900X 12-Core Processor - 4858
  - AMD Ryzen 9 7900X 12-Core Processor - 3573
  - AMD Ryzen 9 7900X 12-Core Processor - 4990
  - AMD Ryzen 9 7900X 12-Core Processor - 5226
  - AMD Ryzen 9 7900X 12-Core Processor - 5177
  - AMD Ryzen 9 7900X 12-Core Processor - 400
  - AMD Ryzen 9 7900X 12-Core Processor - 4261
  - AMD Ryzen 9 7900X 12-Core Processor - 4402
  - AMD Ryzen 9 7900X 12-Core Processor - 5224
  - AMD Ryzen 9 7900X 12-Core Processor - 4432
  - AMD Ryzen 9 7900X 12-Core Processor - 4943
  - AMD Ryzen 9 7900X 12-Core Processor - 5153
  ENDIANNESS: LE
  VERSIONS:
  - acorn: 8.10.0
  - ada: 2.7.2
  - ares: 1.20.1
  - base64: 0.5.0
  - brotli: 1.0.9
  - cjs_module_lexer: 1.2.2
  - cldr: 43.1
  - icu: 73.2
  - llhttp: 6.0.11
  - modules: 108
  - napi: 9
  - nghttp2: 1.57.0
  - nghttp3: 0.7.0
  - ngtcp2: 0.8.1
  - node: 18.19.0
  - openssl: 3.0.12+quic
  - simdutf: 3.2.18
  - tz: 2023c
  - undici: 5.26.4
  - unicode: 15.0
  - uv: 1.44.2
  - uvwasi: 0.0.19
  - v8: 10.2.154.26-node.28
  - zlib: 1.2.13.1-motley

ERROR Summary:

  - broccoliBuilderErrorStack: ModuleNotFoundError: Module not found: Error: bug: embroider resolver's meta is not propagating
    at <.pnpm>/[email protected]/node_modules/webpack/lib/Compilation.js:2029:28
    at <.pnpm>/[email protected]/node_modules/webpack/lib/NormalModuleFactory.js:895:13
    at eval (eval at create (<.pnpm>/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at <.pnpm>/[email protected]/node_modules/webpack/lib/NormalModuleFactory.js:332:22
    at eval (eval at create (<.pnpm>/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
    at <.pnpm>/@[email protected]_@[email protected][email protected]/node_modules/@embroider/webpack/src/webpack-resolver-plugin.js:58:27
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  - code: [undefined]
  - codeFrame: Module not found: Error: bug: embroider resolver's meta is not propagating
  - errorMessage: ../../../_virtual_~build-plugin%2Fregistry: Module not found: Error: bug: embroider resolver's meta is not propagating
        at PackagerRunner (@embroider/webpack)
  - errorType: Build Error
  - location:
    - column: [undefined]
    - file: ../../../_virtual_~build-plugin%2Fregistry
    - line: [null]
    - treeDir: [undefined]
  - message: ../../../_virtual_~build-plugin%2Fregistry: Module not found: Error: bug: embroider resolver's meta is not propagating
        at PackagerRunner (@embroider/webpack)
  - name: Error
  - nodeAnnotation: @embroider/webpack
  - nodeName: PackagerRunner
  - originalErrorMessage: Module not found: Error: bug: embroider resolver's meta is not propagating
  - stack: ModuleNotFoundError: Module not found: Error: bug: embroider resolver's meta is not propagating
    at <.pnpm>/[email protected]/node_modules/webpack/lib/Compilation.js:2029:28
    at <.pnpm>/[email protected]/node_modules/webpack/lib/NormalModuleFactory.js:895:13
    at eval (eval at create (<.pnpm>/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at <.pnpm>/[email protected]/node_modules/webpack/lib/NormalModuleFactory.js:332:22
    at eval (eval at create (<.pnpm>/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
    at <.pnpm>/@[email protected]_@[email protected][email protected]/node_modules/@embroider/webpack/src/webpack-resolver-plugin.js:58:27
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

=================================================================================

and my first idea was to use the module path, not ./, so I changed my test virtual text to:

export const map = {
  foo: () => import('embroider-3--unplugin-plugin-loads-app-files/components/foo.js'),
};

but that results in what appears to be the same error

Build Error (PackagerRunner) in ../../../_virtual_~build-plugin%2Fregistry

Module not found: Error: bug: embroider resolver's meta is not propagating
full report
=================================================================================

ENV Summary:

  TIME: Fri Mar 15 2024 10:13:29 GMT-0400 (Eastern Daylight Time)
  TITLE: ember
  ARGV:
  - 🏠/.volta/tools/image/node/18.19.0/bin/node
  - <repo>/node_modules/ember-cli/bin/ember
  - serve
  EXEC_PATH: 🏠/.volta/tools/image/node/18.19.0/bin/node
  TMPDIR: /tmp
  SHELL: /bin/bash
  PATH:
  - <repo>/node_modules/.bin
  - 🏠/.volta/tools/image/pnpm/8.10.2/dist/node-gyp-bin
  - 🏠/.volta/tools/image/pnpm/8.10.2/bin
  - 🏠/.volta/tools/image/yarn/1.22.19/bin
  - 🏠/.volta/tools/image/node/18.19.0/bin
  - 🏠/.local/bin
  - 🏠/.deno/bin
  - 🏠/.volta/bin
  - /tmp/frum_687489_1710510983110/bin
  - 🏠/.cargo/bin
  - 🏠/Applications
  - 🏠/apps/phantomjs/bin
  - 🏠/scripts/system-utils
  - 🏠/scripts/node
  - 🏠/scripts/git
  - 🏠/scripts/rails
  - 🏠/scripts
  - 🏠/.cargo/bin
  - 🏠/.volta/bin
  - 🏠/.local/bin
  - /usr/local/sbin
  - /usr/local/bin
  - /usr/sbin
  - /usr/bin
  - /sbin
  - /bin
  - /usr/games
  - /usr/local/games
  - /snap/bin
  - /snap/bin
  PLATFORM: linux x64
  FREEMEM: 23183953920
  TOTALMEM: 66550095872
  UPTIME: 88642.34
  LOADAVG: 1.33,0.79,0.71
  CPUS:
  - AMD Ryzen 9 7900X 12-Core Processor - 4549
  - AMD Ryzen 9 7900X 12-Core Processor - 5007
  - AMD Ryzen 9 7900X 12-Core Processor - 400
  - AMD Ryzen 9 7900X 12-Core Processor - 4685
  - AMD Ryzen 9 7900X 12-Core Processor - 4254
  - AMD Ryzen 9 7900X 12-Core Processor - 400
  - AMD Ryzen 9 7900X 12-Core Processor - 3490
  - AMD Ryzen 9 7900X 12-Core Processor - 3617
  - AMD Ryzen 9 7900X 12-Core Processor - 5224
  - AMD Ryzen 9 7900X 12-Core Processor - 400
  - AMD Ryzen 9 7900X 12-Core Processor - 5224
  - AMD Ryzen 9 7900X 12-Core Processor - 3659
  - AMD Ryzen 9 7900X 12-Core Processor - 4972
  - AMD Ryzen 9 7900X 12-Core Processor - 4521
  - AMD Ryzen 9 7900X 12-Core Processor - 3479
  - AMD Ryzen 9 7900X 12-Core Processor - 5249
  - AMD Ryzen 9 7900X 12-Core Processor - 3668
  - AMD Ryzen 9 7900X 12-Core Processor - 5221
  - AMD Ryzen 9 7900X 12-Core Processor - 400
  - AMD Ryzen 9 7900X 12-Core Processor - 4872
  - AMD Ryzen 9 7900X 12-Core Processor - 400
  - AMD Ryzen 9 7900X 12-Core Processor - 3573
  - AMD Ryzen 9 7900X 12-Core Processor - 400
  - AMD Ryzen 9 7900X 12-Core Processor - 4255
  ENDIANNESS: LE
  VERSIONS:
  - acorn: 8.10.0
  - ada: 2.7.2
  - ares: 1.20.1
  - base64: 0.5.0
  - brotli: 1.0.9
  - cjs_module_lexer: 1.2.2
  - cldr: 43.1
  - icu: 73.2
  - llhttp: 6.0.11
  - modules: 108
  - napi: 9
  - nghttp2: 1.57.0
  - nghttp3: 0.7.0
  - ngtcp2: 0.8.1
  - node: 18.19.0
  - openssl: 3.0.12+quic
  - simdutf: 3.2.18
  - tz: 2023c
  - undici: 5.26.4
  - unicode: 15.0
  - uv: 1.44.2
  - uvwasi: 0.0.19
  - v8: 10.2.154.26-node.28
  - zlib: 1.2.13.1-motley

ERROR Summary:

  - broccoliBuilderErrorStack: ModuleNotFoundError: Module not found: Error: bug: embroider resolver's meta is not propagating
    at <.pnpm>/[email protected]/node_modules/webpack/lib/Compilation.js:2029:28
    at <.pnpm>/[email protected]/node_modules/webpack/lib/NormalModuleFactory.js:895:13
    at eval (eval at create (<.pnpm>/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at <.pnpm>/[email protected]/node_modules/webpack/lib/NormalModuleFactory.js:332:22
    at eval (eval at create (<.pnpm>/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
    at <.pnpm>/@[email protected]_@[email protected][email protected]/node_modules/@embroider/webpack/src/webpack-resolver-plugin.js:58:27
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  - code: [undefined]
  - codeFrame: Module not found: Error: bug: embroider resolver's meta is not propagating
  - errorMessage: ../../../_virtual_~build-plugin%2Fregistry: Module not found: Error: bug: embroider resolver's meta is not propagating
        at PackagerRunner (@embroider/webpack)
  - errorType: Build Error
  - location:
    - column: [undefined]
    - file: ../../../_virtual_~build-plugin%2Fregistry
    - line: [null]
    - treeDir: [undefined]
  - message: ../../../_virtual_~build-plugin%2Fregistry: Module not found: Error: bug: embroider resolver's meta is not propagating
        at PackagerRunner (@embroider/webpack)
  - name: Error
  - nodeAnnotation: @embroider/webpack
  - nodeName: PackagerRunner
  - originalErrorMessage: Module not found: Error: bug: embroider resolver's meta is not propagating
  - stack: ModuleNotFoundError: Module not found: Error: bug: embroider resolver's meta is not propagating
    at <.pnpm>/[email protected]/node_modules/webpack/lib/Compilation.js:2029:28
    at <.pnpm>/[email protected]/node_modules/webpack/lib/NormalModuleFactory.js:895:13
    at eval (eval at create (<.pnpm>/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at <.pnpm>/[email protected]/node_modules/webpack/lib/NormalModuleFactory.js:332:22
    at eval (eval at create (<.pnpm>/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
    at <.pnpm>/@[email protected]_@[email protected][email protected]/node_modules/@embroider/webpack/src/webpack-resolver-plugin.js:58:27
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

=================================================================================

Issue is the same on v3 and main.
with any extension for the import, it seems, js, hbs, no extension


when debugging, we can see that it is the virtual file trying to access an app file:
image

what's goofy though, is that the request.isVirtual flag is set to false. is this a troll? or is it used for something else 😅 an actual bug with that flag? idk

@NullVoxPopuli NullVoxPopuli changed the title v3: Resolver is not compatible with virtual files which import from the app [main + v3]: Resolver is not compatible with virtual files which import from the app Mar 15, 2024
@NullVoxPopuli NullVoxPopuli changed the title [main + v3]: Resolver is not compatible with virtual files which import from the app [main + v3, webpack]: Resolver is not compatible with virtual files which import from the app Mar 15, 2024
@ef4
Copy link
Contributor

ef4 commented Mar 15, 2024

Unplugin incorrectly assumes that the app is always at process.cwd(). But in webpack, the app in general is at options.context.

Here is a fully-working version of your repro with a patch applied to unplugin: NullVoxPopuli/embroider-3--unplugin-plugin-loads-app-files#1

@ef4 ef4 closed this as completed Mar 15, 2024
@NullVoxPopuli
Copy link
Collaborator Author

oh dang nice, thanks!
I'll copy that patch over to a PR to unplugin 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants