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

can't locate @ember-data/record-data/-private referred to in module rules #1322

Closed
mansona opened this issue Jan 10, 2023 · 14 comments · Fixed by #1369
Closed

can't locate @ember-data/record-data/-private referred to in module rules #1322

mansona opened this issue Jan 10, 2023 · 14 comments · Fixed by #1369

Comments

@mansona
Copy link
Member

mansona commented Jan 10, 2023

I'm running tests in ember-try embroider-safe and we're getting the following error:

Build Error (WaitForTrees)

can't locate @ember-data/record-data/-private referred to in module rules:{
  "dependsOnModules": [
    "@ember-data/record-data/-private"
  ]
}

I've done some debugging and I've found the error that is being thrown in the resolver.js

'Cannot find module '@ember-data/record-data/-private' from '/private/var/folders/r5/bw5frvnn5k794hk62w3vp7km0000gn/T/embroider/2daa8e/node_modules/.pnpm/@[email protected]_k6kp2ds5o4a3bn46aja3did5ee/node_modules/@ember-data/store''

I had a look at the file on disk and it looks like it's right, there was no sibling to @ember-data/store for record-data and normal node resolution would be expected to fail.

@mansona
Copy link
Member Author

mansona commented Jan 10, 2023

I'm wondering if this is a complication created by the fact that that ember-data is now essentially a meta-package that depends on things like @ember-data/store and @ember-data/record-data, but @ember-data/store only has a peer-dependency on @ember-data/record-data 🤔

@mkszepp
Copy link
Contributor

mkszepp commented Jan 18, 2023

Beginning with ember-data v4.10.x (atm alpha version 15) there is necessary to remove the addon dependency rules, because they have moved files / modified the build process in ember-data

let rules: PackageRules[] = [
{
package: '@ember-data/store',
addonModules: {
'-private.js': {
dependsOnModules: ['@ember-data/record-data/-private'],
},
'-private/system/core-store.js': {
dependsOnModules: ['@ember-data/record-data/-private'],
},
'-private/system/model/internal-model.js': {
dependsOnModules: ['@ember-data/model/-private'],
},
},
},
];

As workaround for this problem, you can use this lines:

ember-cli-build.js

   packageRules: [
      {
        package: '@ember-data/store',
        addonModules: {
          '-private.js': {
            dependsOnModules: [],
          },
          '-private/system/core-store.js': {
            dependsOnModules: [],
          },
          '-private/system/model/internal-model.js': {
            dependsOnModules: [],
          },
        },
      },
    ],

After this fix, you get the next error, which i think is a problem in ember-data (starting with v.4.8.x).
Error while processing route: index Assertion Failed: Expected store.createRecordDataFor to be implemented but it wasn't

With Ember data 4.8.x you need a other workaround to fix the build process emberjs/data#8296 (comment)
But also with this workaround you are running in the error ´store.createRecordDataFor`

With ember-data v4.9.1 there is no workaround necessary for embroider, but there is necessary to solve this issue emberjs/data#8396

Since now, i havn't found a complete workaround to fix ember-data with embroider (without making forks)

@runspired
Copy link

this should be closable. For 4.8+ embroider should fully deactivate all compat adapters for ember-data.

EmberData's own embroider build at this point specifies the following:

return require('@embroider/compat').compatBuild(app, Webpack, {
    skipBabel: [
      {
        package: 'qunit',
      },
    ],
    compatAdapters: new Map([
      ['@ember-data/store', null],
      ['@ember-data/record-data', null],
      ['@ember-data/serializer', null],
      ['@ember-data/adapter', null],
      ['@ember-data/model', null],
      ['@ember-data/debug', null],
      ['@ember-data/tracking', null],
      ['@ember-data/request', null],
      ['@ember-data/private-build-infra', null],
      ['@ember-data/canary-features', null],
      ['ember-data', null],
    ]),
    packageRules: [
      {
        package: '@ember-data/store',
        addonModules: {
          '-private.js': {
            dependsOnModules: ['@ember-data/json-api/-private'],
          },
        },
      },
    ],
  });

@mkszepp
Copy link
Contributor

mkszepp commented Feb 27, 2023

@runspired i think we can also remove all packageRules, when the app is using ember-data v4.11.x (tested in my app)

So, embroider doen't need anymore any workarounds for ember-data.

packageRules: [
      {
        package: '@ember-data/store',
        addonModules: {
          '-private.js': {
            dependsOnModules: [],
          },
          '-private/system/core-store.js': {
            dependsOnModules: [],
          },
          '-private/system/model/internal-model.js': {
            dependsOnModules: [],
          },
        },
      },
    ],

@ef4
Copy link
Contributor

ef4 commented Feb 27, 2023

We support version ranges on the package rules, so a PR updating the built-in package rules so they stop applying to new-enough versions would be great.

@mkszepp
Copy link
Contributor

mkszepp commented Feb 28, 2023

@ef4 PR created.. is there necessary to add also something for the compatAdapters?

@esbanarango
Copy link

What's the @embroider/* version expected to avoid this error? I'm getting this same error after bumping ember-data to 4.12.0?

    "@embroider/addon-shim": "^1.8.4",
    "@embroider/compat": "2.1.1",
    "@embroider/core": "2.1.1",
    "@embroider/macros": "^1.10.0",
    "@embroider/router": "2.0.0",
    "@embroider/util": "^1.10.0",
    "@embroider/webpack": "2.1.1",

@NullVoxPopuli
Copy link
Collaborator

NullVoxPopuli commented Apr 12, 2023

@esbanarango at present, you need to use the unstable-tagged releases to get the work in this PR.

A proper release hasn't happened yet, but is planned

@esbanarango
Copy link

Unfortunately, latest unstabled-tagged release completely breaks the app:

    "@embroider/addon-shim": "1.8.5-unstable.3a9d8ad",
    "@embroider/compat": "2.1.2-unstable.3a9d8ad",
    "@embroider/core": "2.1.2-unstable.3a9d8ad",
    "@embroider/macros": "1.10.1-unstable.3a9d8ad",
    "@embroider/router": "2.0.1-unstable.3a9d8ad",
    "@embroider/util": "1.10.1-unstable.3a9d8ad",
    "@embroider/webpack": "2.1.2-unstable.3a9d8ad",

SignalUi_Tests

@NullVoxPopuli
Copy link
Collaborator

I mean, it's unstable -- but also, it can't find app/app.ts, which could hint at a goofiness with your project.

@vlascik
Copy link
Contributor

vlascik commented Apr 13, 2023

as a workaround, you can delete the node_modules/@embroider/compat/src/addon-dependency-rules/ember-data.js file.

@mkszepp
Copy link
Contributor

mkszepp commented Apr 13, 2023

the workaround, without removing files is, to add packageRules like described here #1322 (comment) So you don't need to use the "unstable" version

packageRules: [
      {
        package: '@ember-data/store',
        addonModules: {
          '-private.js': {
            dependsOnModules: [],
          },
          '-private/system/core-store.js': {
            dependsOnModules: [],
          },
          '-private/system/model/internal-model.js': {
            dependsOnModules: [],
          },
        },
      },
    ],

@mkszepp
Copy link
Contributor

mkszepp commented Apr 13, 2023

but we run in an other problem with ember-data :(, ember-data is atm not anymore compatible with embroider :(

grafik

Error while processing route: index this.requestManager is undefined request@webpack://app-name/./node_modules/@ember-data/store/index-8b77b852.js?:5453:20
query@webpack://app-name/./node_modules/@ember-data/store/index-8b77b852.js?:6398:26
query@webpack://app-name/./services/store.js?:69:33
authenticate@webpack://app-name/./services/session-user.js?:43:23
beforeModel@webpack://app-name/./routes/rg.js?:39:28
runBeforeModelHook@http://localhost:5600/nt/assets/vendor.js:45450:31
resolve/<@http://localhost:5600/nt/assets/vendor.js:45374:26
invokeCallback@http://localhost:5600/nt/assets/vendor.js:47160:17
publish@http://localhost:5600/nt/assets/vendor.js:47146:23
@http://localhost:5600/nt/assets/vendor.js:42721:62
invoke@http://localhost:5600/nt/assets/vendor.js:41306:16
flush@http://localhost:5600/nt/assets/vendor.js:41221:19
flush@http://localhost:5600/nt/assets/vendor.js:41384:21
_end@http://localhost:5600/nt/assets/vendor.js:41825:34
Backburner/this._boundAutorunEnd@http://localhost:5600/nt/assets/vendor.js:41549:14

Edit: Created a Issue in ember-data emberjs/data#8565

@runspired
Copy link

^ note that this last comment is not an issue with embroider but an issue with the app extending the store from @ember-data/store instead of ember-data/store when using ember-data which results in incomplete configuration.

derrabauke added a commit to derrabauke/ember-simple-auth-oidc that referenced this issue Apr 18, 2023
derrabauke added a commit to derrabauke/ember-simple-auth-oidc that referenced this issue Apr 19, 2023
derrabauke added a commit to derrabauke/ember-simple-auth-oidc that referenced this issue Apr 19, 2023
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

Successfully merging a pull request may close this issue.

7 participants