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

Cannot set property x of #<Object> which has only a getter #1938

Open
DmitryScaletta opened this issue Nov 11, 2023 · 0 comments · May be fixed by #1940
Open

Cannot set property x of #<Object> which has only a getter #1938

DmitryScaletta opened this issue Nov 11, 2023 · 0 comments · May be fixed by #1940
Labels

Comments

@DmitryScaletta
Copy link

Impress and Node.js versions

impress: 3.0.13, node: v21.1.0

Platform

No response

Describe the bug

drizzle-orm@0.29.0

First the module loader loads the main package which imports a relations module which exports a relations function.

node_modules/drizzle-orm/index.cjs

https://github.com/drizzle-team/drizzle-orm/blob/0d833d1ca78735e29b124e2a672bda2c85738f48/drizzle-orm/src/index.ts#L10

image

node_modules/drizzle-orm/relations.cjs

https://github.com/drizzle-team/drizzle-orm/blob/0d833d1ca78735e29b124e2a672bda2c85738f48/drizzle-orm/src/relations.ts#L495

image

Then it tries to load a relations submodule (the same name as the function that was already loaded).

node_modules/drizzle-orm/package.json

image

So lib[subName] is already exists and it points to the same object as sub.relations.

I added this debug code here:

impress/lib/deps.js

Lines 57 to 58 in 4cabe81

const sub = appRequire(name + '/' + subName);
lib[subName] = sub;

const sub = appRequire(name + '/' + subName);
if (name === 'drizzle-orm' && subName === 'relations') {
  console.log(lib[subName] && (lib[subName] === sub[subName])); // true
}
lib[subName] = sub; // the error is here
TypeError: Cannot set property relations of #<Object> which has only a getter
    at loadModule (node_modules\impress\lib\deps.js:63:24)
    at Object.<anonymous> (node_modules\impress\lib\deps.js:89:13)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (node_modules\impress\lib\planner.js:3:32)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)

sql submodule is also have this problem.

To Reproduce

  1. Run npm i drizzle-orm@0.29.0
  2. Run npm start
  3. See a module loading error

Expected behavior

No response

Screenshots

No response

Additional context

All drizzle-orm's transpiled code can be found here: https://www.npmjs.com/package/drizzle-orm?activeTab=code

DmitryScaletta added a commit to DmitryScaletta/impress that referenced this issue Nov 12, 2023
DmitryScaletta added a commit to DmitryScaletta/impress that referenced this issue Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant