fastly / next-compute-js

Run Next.js on Fastly Compute
MIT License
75 stars 5 forks source link

new Error("Automatic publicPath is not supported in this browser", "<stdin>", 2) #9

Open matamatanot opened 2 years ago

matamatanot commented 2 years ago

➜ compute-js: fastly compute serve ✓ Initializing... ✓ Verifying package manifest... ✓ Verifying local javascript toolchain... ✗ Running [scripts.build]...

ERROR: error during execution process:

Exception while evaluating JS: (new Error("Automatic publicPath is not supported in this browser", "", 2)) @:2:16345416 @:2:16345558 @:2:16345971

Error: failed to initialize JS

Caused by: 0: the wizer.initialize function trapped 1: Exited with i32 exit status 1 wasm backtrace: 0: 0x40d2fc - !<wasm function 6499> 1: 0x40d304 - !<wasm function 6500> 2: 0x40f0b2 - !<wasm function 6509> 3: 0x2844b - !<wasm function 211> 4: 0x3bab9 - !<wasm function 214> 5: 0x3bc8e - !<wasm function 216>

Wizer failed with status: exit status: 1.

harrykanami commented 2 years ago

C@E engineer has reviewed this. The error looks like it’s being caused possibly by one of the modules that are being used in their nextjs project.

Not all nextjs programs will work, for example if the program in question uses modules that are not compatible with compute@edge.

Can you try building the app without minification so that we can get more insight into what lines of code are causing the errors.

in compute-js/webpack.config.js, they can try changing
  optimization: {
    minimize: true,
  },
to
  optimization: {
    minimize: false,
  },

The logs may help us a bit more.

matamatanot commented 2 years ago

in compute-js/webpack.config.js, they can try changing optimization: { minimize: true, }, to optimization: { minimize: false, },

As mentioned above, I changed webpack.config.js, but logs does not change.

harmony7 commented 2 years ago

Hi, can I have you examine the log output near

Exception while evaluating JS: (new Error("Automatic publicPath is not supported in this browser", "", 2))
@:2:16345416
@:2:16345558
@:2:16345971

If you run this with the optimization.minimize set to false, then these line numbers should be different.

matamatanot commented 2 years ago

Sorry, I didn't notice these line numbers changed.

ERROR: error during execution process:

Exception while evaluating JS: (new Error("Automatic publicPath is not supported in this browser", "", 156822)) @:156822:34 @:156825:13 @:156883:12

Error: failed to initialize JS

Caused by: 0: the wizer.initialize function trapped 1: Exited with i32 exit status 1 wasm backtrace: 0: 0x40d2fc - !<wasm function 6499> 1: 0x40d304 - !<wasm function 6500> 2: 0x40f0b2 - !<wasm function 6509> 3: 0x2844b - !<wasm function 211> 4: 0x3bab9 - !<wasm function 214> 5: 0x3bc8e - !<wasm function 216>

Wizer failed with status: exit status: 1.

Thank you for checking.

harmony7 commented 2 years ago

The message "Automatic publicPath is not supported in this browser" indicates that your code, or a library you are including, triggers the Automatic Public Path feature of Webpack.

This may be something you can work around by settings public path manually (see linked article), using a polyfill, by removing that dependency, or using an alternative. Unfortuately this would depend on your code and the dependencies you are using.

harmony7 commented 2 years ago

Hi! I found a case where this occurs and it can be fixed with a webpack configuration. Can I have you try scaffolding your app again using the newest version of this tool (0.7.1)?

matamatanot commented 2 years ago

The error message has changed, but the build fails.

✅ Wrote static file loader for 278 file(s). assets by status 29.4 MiB [cached] 1 asset orphan modules 24.5 MiB [orphan] 1073 modules runtime modules 4.43 KiB 9 modules built modules 31.8 MiB [built] javascript modules 31.6 MiB modules by path ./ 24.2 MiB 240 modules modules by path ../ 7.35 MiB 229 modules optional modules 135 bytes [optional] 9 modules util (ignored) 15 bytes [built] [code generated] util (ignored) 15 bytes [built] [code generated] json modules 244 KiB modules by path ./ 244 KiB 16 modules modules by path ../.next/ 239 bytes ../.next/server/middleware-manifest.json 76 bytes [built] [code generated] ../.next/server/pages-manifest.json 163 bytes [built] [code generated]

 WARNING in configuration
 The 'mode' option has not been set, webpack will fallback to 'production' for this
 value.
 Set 'mode' option to 'development' or 'production' to enable defaults for each
 environment.
 You can also set it to 'none' to disable any default behavior. Learn more:
 https://webpack.js.org/configuration/mode/

 ERROR in ../.next/server/_error.js 60:26-58
 Module not found: Error: Can't resolve '../webpack-runtime.js' in
 '/Users/foobar/project/.next/server'
 resolve '../webpack-runtime.js' in '/Users/foobar/project/.next/server'
   using description file:  /Users/foobar/project/.next/package.json (relative path:
 ./server)
     Field 'browser' doesn't contain a valid alias configuration
     using description file:  /Users/foobar/project/.next/package.json (relative
 path: ./webpack-runtime.js)
       no extension
         Field 'browser' doesn't contain a valid alias configuration
         /Users/foobar/project/.next/webpack-runtime.js doesn't exist
       .js
         Field 'browser' doesn't contain a valid alias configuration
         /Users/foobar/project/.next/webpack-runtime.js.js doesn't exist
       .json
         Field 'browser' doesn't contain a valid alias configuration
         /Users/foobar/project/.next/webpack-runtime.js.json doesn't exist
       .wasm
         Field 'browser' doesn't contain a valid alias configuration
         /Users/foobar/project/.next/webpack-runtime.js.wasm doesn't exist
       as directory
          /Users/foobar/project/.next/webpack-runtime.js doesn't exist
  @ ./src/statics.js 6:0-60 301:94-105
  @ ./src/index.js

 webpack 5.74.0 compiled with 1 error and 1 warning in 16659 ms
harmony7 commented 2 years ago

hmm. that looks like maybe your project isn't set up correctly, as it can't find the file .next/server/webpack-runtime.js, which should have been built by npx next build. Please try:

in your project folder (the folder that contains next.config.js):

npx next build

After this, check to make sure .next/server/webpack-runtime.js exists.

Then:

cd compute-js
fastly compute build --verbose