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

Storybook: Dynamic import argument must be a string or a template literal #1376

Open
cloudshadow opened this issue Oct 24, 2023 · 4 comments
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: rollup 🗞️ Issue is related to rollup bundler bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@cloudshadow
Copy link

Environment

"storybook": "7.5.1",
"@storybook/react-webpack5": "7.5.1",
"@linaria/babel-preset": "5.0.3",
"@linaria/core": "5.0.2",
"@linaria/react": "5.0.3",
"@linaria/rollup": "5.0.3",
"@linaria/webpack-loader": "5.0.3",

  • Linaria version: 5.0.2
  • Node.js version: 20.2.0
  • OS: ventura 13.5

Description

Run "npm run storybook" and will return the error ERROR in ./storybook-stories.js Module build failed (from ./node_modules/@linaria/webpack-loader/lib/index.js): Error: /storybook-stories.js: Dynamic import argument must be a string or a template literal

but it work fine when I use
"@linaria/babel-preset": "4.5.4",
"@linaria/core": "4.5.4",
"@linaria/react": "4.5.4",
"@linaria/rollup": "4.5.4",
"@linaria/webpack-loader": "4.5.4",

@cloudshadow cloudshadow added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Oct 24, 2023
@github-actions github-actions bot added bundler: rollup 🗞️ Issue is related to rollup bundler bundler: webpack 📦 Issue is related to webpack bundler and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Oct 24, 2023
@layershifter
Copy link
Contributor

Please provide a reproduction case on Stackblitz or a Github repository.

@cloudshadow
Copy link
Author

Hi @layershifter
please check the repo https://github.com/cloudshadow/linaria-with-storybook-issue

@aforian
Copy link

aforian commented Dec 26, 2023

@layershifter Are there any updates?
I encountered the same problem using the simular config like @cloudshadow does
v4.5.4 works fine
reproduction here:
https://github.com/aforian/linaria-storybook-issue-poc


but v6 will throw the error:

ERROR in ./storybook-stories.js
Module build failed (from ./node_modules/@wyw-in-js/webpack-loader/lib/index.js):
Error: /Users/alexian/repo/work/linaria-storybook-issue-poc/storybook-stories.js: Dynamic import argument must be a string or a template literal
    at PluginPass.CallExpression (/Users/alexian/repo/work/linaria-storybook-issue-poc/node_modules/@wyw-in-js/transform/lib/plugins/dynamic-import.js:28:17)

reproduction here:
https://github.com/aforian/linaria-storybook-issue-poc/tree/test/linaria-6

@JuliaBelokrinitskaya
Copy link

Adding exclude solved the problem for me:

    config.module.rules.push({
      test: /\.(tsx|ts|js|mjs|jsx)$/,
      use: [
        {
          loader: require.resolve('@wyw-in-js/webpack-loader'),
          options: {
            sourceMap: false,
          },
        },
      ],
      exclude: [
        /node_modules/,
        path.resolve(process.cwd(), 'storybook-stories.js'),
        path.resolve(process.cwd(), 'storybook-config-entry.js'),
      ],
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: rollup 🗞️ Issue is related to rollup bundler bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

No branches or pull requests

4 participants