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

Feature: support NodePath dynamic imports #30

Open
ntucker opened this issue Dec 13, 2023 · 1 comment
Open

Feature: support NodePath dynamic imports #30

ntucker opened this issue Dec 13, 2023 · 1 comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler enhancement New feature or request needs: more info ℹ Not enough information was provided to work on issue needs: triage 🏷 Issue needs to be checked and prioritized

Comments

@ntucker
Copy link

ntucker commented Dec 13, 2023

Environment

  • wyw-in-js version: 0.2.2
  • custom processor:
  • Bundler (+ version): [email protected]
  • Node.js version: 20.10.0
  • OS: Ubuntu on WSL

Description

Error: /temp/storybook-stories.js: Dynamic import argument must be a string or a template literal

Full error
ERROR in ./storybook-stories.js
Module build failed (from ./node_modules/@wyw-in-js/webpack-loader/lib/index.js):
Error: /home/ntucker/src/temp/storybook-stories.js: Dynamic import argument must be a string or a template literal
    at PluginPass.CallExpression (/home/ntucker/src/temp/node_modules/@wyw-in-js/transform/lib/plugins/dynamic-import.js:28:17)
    at newFn (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/visitors.js:160:14)
    at NodePath._call (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/path/context.js:82:31)
    at TraversalContext.visitQueue (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitSingle (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:65:19)
    at TraversalContext.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:109:19)
    at traverseNode (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitMultiple (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:61:17)
    at TraversalContext.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:107:19)
    at traverseNode (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitSingle (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:65:19)
    at TraversalContext.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:109:19)
    at traverseNode (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitMultiple (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:61:17)
    at TraversalContext.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:107:19)
    at traverseNode (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitSingle (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:65:19)
    at TraversalContext.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:109:19)
    at traverseNode (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitMultiple (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:61:17)
    at TraversalContext.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:107:19)
    at traverseNode (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitMultiple (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:61:17)
    at TraversalContext.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:107:19)
    at traverseNode (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitSingle (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:65:19)
    at TraversalContext.visit (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/context.js:109:19)
    at traverseNode (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at traverse (/home/ntucker/src/temp/node_modules/@babel/traverse/lib/index.js:52:34)
    at transformFile (/home/ntucker/src/temp/node_modules/@babel/core/lib/transformation/index.js:82:31)
    at transformFile.next (<anonymous>)
    at run (/home/ntucker/src/temp/node_modules/@babel/core/lib/transformation/index.js:24:12)
    at run.next (<anonymous>)
    at /home/ntucker/src/temp/node_modules/@babel/core/lib/transform-ast.js:23:33

When using storybook it creates a virtual file that includes a dynamic import. This breaks the build.

Problem is here

Context on nodepath

Reproducible Demo

https://github.com/ntucker/wyw-in-js-storybook

git clone https://github.com/ntucker/wyw-in-js-storybook
cd wyw-in-js-storybook
yarn storybook
@ntucker ntucker 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 Dec 13, 2023
@Anber Anber added bundler: webpack 📦 Issue is related to webpack bundler and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Dec 13, 2023
@layershifter layershifter added enhancement New feature or request enhancement: approved ✅ Improvement of the current behaviour that has been approved and removed needs: complete repro 🖥️ Issue need to have complete repro provided bundler: webpack 📦 Issue is related to webpack bundler labels Dec 29, 2023
@layershifter layershifter changed the title Support NodePath dynamic imports Feature: support NodePath dynamic imports Dec 29, 2023
@Anber Anber added the bundler: webpack 📦 Issue is related to webpack bundler label Dec 29, 2023
@layershifter layershifter added needs: more info ℹ Not enough information was provided to work on issue needs: triage 🏷 Issue needs to be checked and prioritized and removed enhancement: approved ✅ Improvement of the current behaviour that has been approved labels Dec 29, 2023
@layershifter
Copy link
Collaborator

I tried clone the repo, install deps and did yarn storybook:

image

(node 20)

@ntucker can you please provide more details? It seems that something is missing in the repro.

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: webpack 📦 Issue is related to webpack bundler enhancement New feature or request needs: more info ℹ Not enough information was provided to work on issue needs: triage 🏷 Issue needs to be checked and prioritized
Projects
None yet
Development

No branches or pull requests

3 participants