emberjs / data

WarpDrive is a lightweight data library for web apps — universal, typed, reactive, and ready to scale.
https://api.emberjs.com/ember-data/release
MIT License
3.04k stars 1.33k forks source link

vite: the `ember-data` package seems to be required? #9599

Closed Jopie01 closed 1 hour ago

Jopie01 commented 9 hours ago

I'm working towards creating a new app using the latest and greatest developments of embroider, ember and ember-data.

I started with:

npx ember-cli@latest new vite-test -b @embroider/app-blueprint --pnpm

Then I uninstalled ember-data because I want to use the separate packages as I already do. I manually copied the ember-data packages over to the package.json as dependencies:

"@ember-data/debug": "5.4.0-alpha.117",
"@ember-data/graph": "5.4.0-alpha.117",
"@ember-data/json-api": "5.4.0-alpha.117",
"@ember-data/store": "5.4.0-alpha.117",
"@ember-data/tracking": "5.4.0-alpha.117",
"@ember-data/request": "5.4.0-alpha.117",
"@warp-drive/build-config": "0.0.0-alpha.54",
"@warp-drive/core-types": "0.0.0-alpha.103",
"@warp-drive/schema-record": "0.0.0-alpha.103",

And did a pnpm install.

But running this with pnpm start --host 0.0.0.0 fails with:

✘ [ERROR] /home/ember/ember/vite-test/node_modules/.pnpm/@ember-data+debug@5.4.0-alpha.117_@ember-data+model@5.4.0-alpha.117_@ember-data+request-utils_j4dhddez64f3vt4eeqdyqnk4la/node_modules/@ember-data/debug/dist/data-adapter.js: Cannot read properties of undefined (reading 'env') [plugin embroider-esbuild-resolver]

    node_modules/.pnpm/@embroider+macros@1.16.10-unstable.aaeb674/node_modules/@embroider/macros/src/babel/macro-condition.js:37:40:
      37 │ ... let [kept, removed] = predicate.value ? [consequent.node, altern...
         ╵                                     ^

No idea what's going on, but I looked at PR #9595 which adds a vite test app. There I found that also the ember-data package is also installed. That's what I did and then the app build and boots correctly, I can see the welcome page, make changes etc.

So why is the ember-data package needed? Will it make changes to the new schema and schema-records?

runspired commented 3 hours ago

Likely you need to set the build config. The vite test app is just testing the happy path (installation via blueprint), I have a few apps building with vite using the individual package approach that don't use ember-data so there shouldn't be any entanglements there.

In your ember-cli-build file make sure you've done this:

const { setConfig } = await import('@warp-drive/build-config');

let app = new EmberApp(defaults, {});

setConfig(app, __dirname, { compatWith: '3.12' });
Jopie01 commented 1 hour ago

AAArrgggghhh, I missed that one :cry: When I saw the config I immediately remembered that I have seen that before and indeed ..... #9461.

Sorry for the noise ...