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

Unable to launch following install instructions #21

Closed
michaeltford opened this issue May 31, 2023 · 7 comments
Closed

Unable to launch following install instructions #21

michaeltford opened this issue May 31, 2023 · 7 comments

Comments

@michaeltford
Copy link

I get the following error when trying to load. Am I missing something obvious? I appears to be a babel related issue.

ModuleNotFoundError: Module not found: Error: Can't resolve '@babel/plugin-syntax-unicode-sets-regex' in 'C:\dev\sheetxl\node_modules@babel\standalone'.

When trying to troubleshoot I downloaded the source and tried to run the example (I am on a windows 11 box). I get the following error
Cannot find module './dist/cjs/preset'

@svanetten1976
Copy link

svanetten1976 commented May 31, 2023

@michaeltford I am getting the same exact issue when running Storybook 6.5.14. Or, if I have not built yet and am trying to build with a test Playground component, I also get this message "Field 'browser' doesn't contain a valid alias configuration" along with a number of node_modules/@babel/plugin-syntax-unicode-sets-regex doesn't exist errors. Any ideas @JeremyRH ?

@michaeltford
Copy link
Author

Thanks @svanetten1976 . I am not new to development and I spent several hours with no luck. I also tried in sb 7.1alpha with fresh download. This component looks so awesome.

It has something to do with babel standalone needed for monaco but sb is include/mapping.

@JeremyRH
Copy link
Owner

Thanks for reporting, I'll take a look at this soon.

@svanetten1976
Copy link

@michaeltford @JeremyRH I actually just solved the issue, figured out what I needed to do anyways with my configuration. This is the magic line, maybe this is something you want to add :
'@babel/plugin-syntax-unicode-sets-regex': path.resolve(__dirname, '../', 'node_modules/@babel/standalone')

This is in storybook/main.ts in my case, here is the full webpackFinal function (there is some other stuff in there very specific to the app I am working on but that is the magic line that fixed stuff for me):

  webpackFinal: async (config) => {
    // Use SVGR for SVG files
    const fileLoaderRule = config.module.rules.find((rule) => (rule as any).test.test('.svg'));
    (fileLoaderRule as any).exclude = /\.svg$/;
    config.module.rules.push({
      test: /\.svg$/,
      use: [
        { loader: '@svgr/webpack', options: { icon: true } },
        {
          loader: 'file-loader',
          options: {
            name: '[name].[contenthash].[ext]',
          },
        },
      ],
    });

    config.resolve.alias = {
      '@babel/plugin-syntax-unicode-sets-regex': path.resolve(__dirname, '../', 'node_modules/@babel/standalone'),
      '@': path.resolve(__dirname, '../', 'src'),
    };

    return config;
  },

@michaeltford
Copy link
Author

@svanetten1976, very nice job! I thought about an alias but I thought there might be a ton more. I will try this patch tomorrow and thanks. @JeremyRH do you think this is a storybook issue or a monaco issue? I didn't see anything in your codebase that looked like it would cause this.

@JeremyRH
Copy link
Owner

JeremyRH commented Jun 1, 2023

@babel/standalone has this in its JS:

require("@babel/plugin-syntax-unicode-sets-regex")

but it does not have @babel/plugin-syntax-unicode-sets-regex as a dependency or peer dependency. Maybe this was working before due to storybook or some other dependency bringing in @babel/plugin-syntax-unicode-sets-regex and now it's not. I can try to fix it by making @babel/plugin-syntax-unicode-sets-regex a dependency of storybook-addon-code-editor but it should really be fixed elsewhere.

EDIT: Looks like this might be related: babel/babel#15636
This comment here sheds some light on this. I'm intentionally transforming code written in the editor to CommonJS to hook into the require( calls. I'm hoping there's a way to stop this plugin from loading even when using CommonJS. Possibly this.

@JeremyRH
Copy link
Owner

This was fixed on babel's side: https://github.com/babel/babel/pull/15675/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants