embroider
embroider copied to clipboard
importSync error: `Expected identifier but found "*"` when using the `@cached` decorator in `ember-headless-table` with `@embroider/vite`
@mansona thanks for an exciting demo today during the Ember.js Europe meetup🚀 I tried the steps tonight on my own app, and it turns out I belong to the 40% that wouldn't get vite to run with ember-source 5.7.0:)
Since ember-headless-table
is a V2 addon that works well in webpack, I am posting it as an issue here, and not on the addon repo.
Steps to reproduce:
- Checkout the
ember-headless-table-expected-identifier-on-cached-decorator
branch in this repository: https://github.com/johanrd/ember-vite-app - Run
pnpm vite
- See the following error in the console:
✘ [ERROR] Expected identifier but found "*"
node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@ember+test-waiters@3_iveooflb4fr3ajv754gzshjrpu/node_modules/ember-headless-table/dist/table-443deac1.js:3:18:
3 │ import { tracked, * as _importSync0 } from '@glimmer/tracking';
╵ ^
~/ember-vite-app/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1651
let error = new Error(text);
^
Error: Build failed with 1 error:
node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@ember+test-waiters@3_iveooflb4fr3ajv754gzshjrpu/node_modules/ember-headless-table/dist/table-443deac1.js:3:18: ERROR: Expected identifier but found "*"
at failureErrorWithLog (~/ember-vite-app/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1651:15)
at ~/ember-vite-app/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1059:25
at ~/ember-vite-app/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1527:9
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
errors: [Getter/Setter],
warnings: [Getter/Setter]
}
The compiled V2 output of the addon seems to include an importSync
reference to @glimmer/tracking
and ember-cached-decorator-polyfill
:
let cached = macroCondition(dependencySatisfies('ember-source', '>= 4.1.0-alpha.0')) ? importSync('@glimmer/tracking').cached : importSync('ember-cached-decorator-polyfill').cached;
Perhaps the use of ember-cached-decorator-polyfill
is the issue here? not sure. Possibly also related to #1672?
Oh, that's exactly what i saw today as well. A fix is being worked on here https://github.com/ef4/babel-import-util/pull/11