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

TypeError: Cannot add property _layers, object is not extensible #205

Open
ineshbose opened this issue Nov 20, 2024 · 5 comments
Open

TypeError: Cannot add property _layers, object is not extensible #205

ineshbose opened this issue Nov 20, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@ineshbose
Copy link

Environment



Reproduction

https://stackblitz.com/github/nuxt-modules/tailwindcss/tree/c12-refactor

Run pnpm test basic

Describe the bug

Getting an error: TypeError: Cannot add property _layers, object is not extensible

This is when the config is equal to [Module: null prototype] { } and I have passed a custom merger as well that is based of defu (also creates copy of objects using klona). I'm not 100% sure where the issue may be lying in this case.

Additional context

In the test fixture, I am trying to load tailwind.config.js that uses CommonJS syntax but it loadConfig / jiti doesn't seem to be picking that 🤔

It'll work if the extension is .cjs or the file uses ESM, but not all users may have that scenario.

Logs

TypeError: Cannot add property _layers, object is not extensible
 ❯ extendConfig node_modules/.pnpm/[email protected][email protected]/node_modules/c12/dist/shared/c12.CLRr5qYj.cjs:237:18
 ❯ loadConfig node_modules/.pnpm/[email protected][email protected]/node_modules/c12/dist/shared/c12.CLRr5qYj.cjs:205:11
 ❯ Object.loadConfigs src/internal-context/load.ts:119:27
 ❯ src/module.ts:93:23
 ❯ initNuxt node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_p5ecgqo4fgnxalrrwhgsvb34r4/node_modules/nuxt/dist/index.mjs:4510:3
 ❯ loadNuxt node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_p5ecgqo4fgnxalrrwhgsvb34r4/node_modules/nuxt/dist/index.mjs:4673:5
 ❯ Module.loadNuxt node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@nuxt/kit/dist/index.mjs:2664:19
 ❯ loadFixture node_modules/.pnpm/@[email protected][email protected][email protected][email protected][email protected]_@openteleme_3tgsw6odecy35hpfofogcjtniu/node_modules/@nuxt/test-utils/dist/shared/test-utils.CaqvQLs_.mjs:103:16
    101|     });
    102|     const buildDir = ctx.nuxt.options.buildDir;
    103|     if (!existsSync(buildDir)) {
       |                ^
    104|       await promises.mkdir(buildDir, { recursive: true });
    105|       ctx.teardown = ctx.teardown || [];
 ❯ setup2 node_modules/.pnpm/@[email protected][email protected][email protected][email protected][email protected]_@openteleme_3tgsw6odecy35hpfofogcjtniu/node_modules/@nuxt/test-utils/dist/shared/test-utils.CaqvQLs_.mjs:180:7
@ineshbose ineshbose added the bug Something isn't working label Nov 20, 2024
@pi0
Copy link
Member

pi0 commented Nov 22, 2024

Any chance you can prepare a minimal (c12 only) reproduction? 🙏🏼 (my guess is that it can be reproduced by using a natively imported .cjs config in a layer)

@ineshbose
Copy link
Author

Hey sorry the stackblitz got updated! My workaround was to use extend: false in src/internal-context/load.ts. Let me also try to reproduce in an isolated usage

@ineshbose
Copy link
Author

Can't reproduce yet, but your guess seemed quite close. I will close this for now!

@ineshbose ineshbose closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2024
@pi0
Copy link
Member

pi0 commented Dec 13, 2024

(reopening since might resurface.)

@pi0 pi0 reopened this Dec 13, 2024
@wiseadme
Copy link

Hi! I faced the same problem after upgrading nuxt version from 3.13.2 to 3.15.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants