storybook icon indicating copy to clipboard operation
storybook copied to clipboard

nuxt-bridge fails due to nullish coalescing in h3

Open tobiasdiez opened this issue 3 years ago • 4 comments

Version

@nuxtjs/storybook: latest nuxt: latest bridge

Reproduction Link

https://codesandbox.io/s/github/nuxt-community/storybook/tree/master/examples/bridge (the default for the nuxt bridge support)

Steps to reproduce

Start reproduction.

What is Expected?

No error.

What is actually happening?

Fails with

ERROR in ./node_modules/h3/dist/index.cjs 201:41
Module parse failed: Unexpected token (201:41)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     return input;
|   }
>   const err = new H3Error(input.message ?? input.statusMessage);
|   if (input.statusCode) {
|     err.statusCode = input.statusCode;
 @ ./node_modules/@nuxt/bridge/dist/runtime/composables.mjs 24:0-34
 @ ./node_modules/@nuxt/bridge/dist/runtime/index.mjs
 @ ./node_modules/@nuxt/bridge/dist/runtime/capi.plugin.mjs

tobiasdiez avatar Mar 21 '22 20:03 tobiasdiez

This can be temporarily fixed with the following in nuxt.config

  storybook: {
    webpackFinal(config, { configDir }) {
      config.module?.rules.push({
        test: /\.cjs$/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ["@babel/preset-env"],
          },
        },
      });
      return config;
    },
  },

tarantoj-intrepid avatar Apr 01 '22 01:04 tarantoj-intrepid

This was failing for me after updating to next bridge. Commenting as I landed here from Google.

Similarly, this config update got it to build:

build: {
  extend(config) {
    config.module?.rules.push({
      test: /\.[cm]?js$/,
      use: {
        loader: 'babel-loader',
        options: {
          presets: ['@babel/preset-env'],
        },
      },
    })
  },
},

KevinBatdorf avatar Jun 18 '22 13:06 KevinBatdorf

Nuxt Bridge now transpiles h3 by default. Is this still an issue you are experiencing?

danielroe avatar Mar 16 '23 13:03 danielroe

I no longer use bridge, so I cannot say if this still occurs. Maybe @tarantoj-intrepid or @KevinBatdorf know more?

tobiasdiez avatar Mar 16 '23 14:03 tobiasdiez

v4 of this module is no longer actively supported. Please try the newest version and open an new issue if the problem persists. Thank you for your understanding.

tobiasdiez avatar May 01 '24 07:05 tobiasdiez