Closed NullVoxPopuli closed 2 months ago
Your working example is using Vite and your failing example is using Webpack. Are you sure this plugin actually works in standalone webpack? Because I have seen very poor support for virtual-file-like unplugins in webpack.
The "meta failing to propagate" message is because your virtual file is presenting itself as /full/path/to/kolay/docs-app/_virtual_%00kolay%2Fsetup
. That is a nonsensical place for it to be because webpack is not building an app in /full/path/to/kolay
, it's building an app in /full/path/to/kolay/node_modules/.embroider
and nothing in webpack is supposed to even look at the "real" app dir. (This will change when we finish eliminating app rewriting.)
My suggestion is to first confirm that this plugin really works in a vanilla webpack project. If it does, we can look into whether we're missing something that would cause it to get confused about where the app lives.
I've updated the demo to add a webpack example -- showing that the vite example works the same in vanilla webpack as well:
It seems this error is also present on main
: https://github.com/universal-ember/kolay/actions/runs/8150310099/job/22276369766?pr=33#step:3:159
Just tested with the unstable release:
ERROR in ../../../_virtual_%00kolay%2Fsetup 1:0-40
Module not found: Error: bug: embroider resolver's meta is not propagating
@ ../../../_virtual_%00kolay%2Ftest-support 1:0-50 7:10-15
@ ./tests/kolay/components/comment-query-test.ts 4:0-48 11:2-12
@ ./assets/test.js 9:0-78 30:13-17
@embroider/vite
has an issue as well:
(test-support is a virtual file)
✘ [ERROR] A module tried to resolve "kolay/test-support" and didn't find it (v1 catch-all fallback).
- Maybe a dependency declaration is missing?
- Remember that v1 addons can only import non-Ember-addon NPM dependencies if they include ember-auto-import in their dependencies.
- If this dependency is available in the AMD loader (because someone manually called "define()" for it), you can configure a shim like:
amdCompatibility: {
es: [
["kolay/test-support", ["default", "yourNamedExportsGoHere"]],
]
}
[plugin embroider-esbuild-resolver]
node_modules/.embroider/rewritten-app/tests/kolay/components/api-docs-test.ts:4:27:
4 │ import { setupKolay } from 'kolay/test-support';
╵ ~~~~~~~~~~~~~~~~~~~~
This error came from the "onResolve" callback registered here:
../node_modules/.pnpm/@embroider+vite@0.2.1-unstable.4c0881e_@embroider+core@3.4.6-unstable.4c0881e_@glint+template@1.3.0_vite@5.1.4/node_modules/@embroider/vite/src/esbuild-resolver.js:22:18:
22 │ build.onResolve({ filter: /./ }, async ({ path, import...
╵ ~~~~~~~~~
at setup (<.pnpm>/@embroider+vite@0.2.1-unstable.4c0881e_@embroider+core@3.4.6-unstable.4c0881e_@glint+template@1.3.0_vite@5.1.4/node_modules/@embroider/vite/src/esbuild-resolver.js:22:19)
at handlePlugins (<.pnpm>/esbuild@0.19.12/node_modules/esbuild/lib/main.js:1293:21)
at buildOrContextImpl (<.pnpm>/esbuild@0.19.12/node_modules/esbuild/lib/main.js:979:5)
at Object.buildOrContext (<.pnpm>/esbuild@0.19.12/node_modules/esbuild/lib/main.js:788:5)
at <.pnpm>/esbuild@0.19.12/node_modules/esbuild/lib/main.js:2223:68
at new Promise (<anonymous>)
at Object.context (<.pnpm>/esbuild@0.19.12/node_modules/esbuild/lib/main.js:2223:27)
at Object.context (<.pnpm>/esbuild@0.19.12/node_modules/esbuild/lib/main.js:2048:58)
at prepareEsbuildScanner (file://<.pnpm>/vite@5.1.4/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:51022:26)
During the meeting today, we talked about trying to work around this via using the internally prefixed imports in the virtual files -- and it seemed insufficient to escape the embroider-resolver (so that only rollup/webpack/vite would handle resolving).
unplugin has released the fix, and this problem remains :sweat_smile:
oh, counter evidence -- I have another project where the unplugin fix does solve this. yaaaas
I'm going to close this issue as the original repro (in embroider anyway), is passing!
tl;dr: upgrade unplugin to at least 1.10.1
for the other case where I have the embroider resolver meta problem, I need to figure out how that scenario is different from the place where I have things working.
Example setup of non-embroider usage to describe what I mean:
code here
The plugins (in a pcakage): ```js /** * This plugin is *basically* what v1 addons did. */ import { stripIndent } from 'common-tags'; import { createUnplugin } from 'unplugin'; import { virtualFile } from './helpers.js'; export const docs = createUnplugin(() => { return { name: 'kolay-docs', ...virtualFile([ { importPath: 'kolay/api-docs:virtual', content: `export const name = 'docs';`, }, { importPath: 'kolay/manifest:virtual', content: `export const name = 'manifest';`, }, ]), }; }); export const setup = createUnplugin(() => { return { name: 'kolay-setup', ...virtualFile([ { importPath: 'kolay/setup', content: stripIndent` export async function setupKolay() { let [apiDocs, manifest] = await Promise.all([ import('kolay/api-docs:virtual'), import('kolay/manifest:virtual'), ]); return { apiDocs, manifest }; } `, }, { importPath: 'kolay/test-support', content: stripIndent` import { setupKolay as setup } from 'kolay/setup'; export function setupKolay() { return setup(); } `, }, ]), }; }); ``` The consumer's main.js: ```js import { setupKolay } from 'kolay/test-support'; console.log(setupKolay); let result = await setupKolay(); console.log(result); ``` expected output: ![image](https://github.com/embroider-build/embroider/assets/199018/f968491a-2cf1-4ded-ac18-9459ea630625)Under embroider v3, the following error is encountered:
error log
``` ================================================================================= ENV Summary: TIME: Fri Mar 01 2024 09:00:52 GMT-0500 (Eastern Standard Time) TITLE: ember ARGV: - 🏠/.volta/tools/image/node/20.10.0/bin/node - <.pnpm>/ember-cli@5.5.0/node_modules/ember-cli/bin/ember - serve EXEC_PATH: 🏠/.volta/tools/image/node/20.10.0/bin/node TMPDIR: /tmp SHELL: /bin/bash PATH: -We don't actually care about embroider resolver's meta in this case.
Some notes on the difference between my working-repro and local-repro (breaking, PR here: https://github.com/universal-ember/kolay/pull/33)
ember-addon