Matheus Castro
Matheus Castro

Reputation: 311

Module level directives cause errors when bundled, 'use client' was ignored causing JavaScript heap out of memory

I had this error in my pipeline aws: Module level directives cause errors when bundled, 'use client' was ignored causing JavaScript heap out of memory

I want a solution for this problem considering that i am using vite.js on my react.js app.

Upvotes: 11

Views: 13524

Answers (1)

Matheus Castro
Matheus Castro

Reputation: 311

to resolve this question I used 2 steps:

  1. add this code into vite.config.js:

    export default defineConfig({
      build: {
        chunkSizeWarningLimit: 100,
        rollupOptions: {
          onwarn(warning, warn) {
            if (warning.code === "MODULE_LEVEL_DIRECTIVE") {
              return;
            }
            warn(warning);
          },
        },
      },
      plugins: [react()],
    });
    
  2. I used this config in my AWS pipeline: https://stackoverflow.com/a/66889948/13507783

Upvotes: 10

Related Questions