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 · 2 comments
Open

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

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

Comments

@ineshbose
Copy link

Environment


  • Operating System: Linux
  • Node Version: v20.17.0
  • Package Manager: pnpm@9.11.0

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/c12@2.0.1_magicast@0.3.5/node_modules/c12/dist/shared/c12.CLRr5qYj.cjs:237:18
 ❯ loadConfig node_modules/.pnpm/c12@2.0.1_magicast@0.3.5/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/nuxt@3.13.2_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+node@20.11.0_encoding@0.1.1_p5ecgqo4fgnxalrrwhgsvb34r4/node_modules/nuxt/dist/index.mjs:4510:3
 ❯ loadNuxt node_modules/.pnpm/nuxt@3.13.2_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+node@20.11.0_encoding@0.1.1_p5ecgqo4fgnxalrrwhgsvb34r4/node_modules/nuxt/dist/index.mjs:4673:5
 ❯ Module.loadNuxt node_modules/.pnpm/@nuxt+kit@3.13.2_magicast@0.3.5_rollup@4.18.0_webpack-sources@3.2.3/node_modules/@nuxt/kit/dist/index.mjs:2664:19
 ❯ loadFixture node_modules/.pnpm/@nuxt+test-utils@3.14.2_h3@1.13.0_happy-dom@15.7.4_magicast@0.3.5_nitropack@2.9.7_@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/@nuxt+test-utils@3.14.2_h3@1.13.0_happy-dom@15.7.4_magicast@0.3.5_nitropack@2.9.7_@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

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

2 participants