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

Dynamic Imports Aren't Compiled (JSX) #2760

Open
ghost opened this issue Sep 28, 2024 · 0 comments
Open

Dynamic Imports Aren't Compiled (JSX) #2760

ghost opened this issue Sep 28, 2024 · 0 comments

Comments

@ghost
Copy link

ghost commented Sep 28, 2024

Environment

$ node --version
v18.20.3
$ npm ls
+-- @esbuild/[email protected] extraneous
+-- @parcel/[email protected] extraneous
+-- @parcel/[email protected] extraneous
+-- @rollup/[email protected] extraneous
+-- @rollup/[email protected] extraneous
+-- [email protected]
`-- [email protected] extraneous

Reproduction

stackblitz.com/edit/node-ru2nde

Describe the bug

When programmatically generating a path for importing with await import(), Nitro does not compile the imported file correctly.

const { default: _App } = import("src/App.jsx"); // 👍 `src/App.jsx` converted to `js` and imported

const { default: _App } = import(path.resolve(process.cwd(), "src/App.jsx")); // 👎 `src/App.jsx` not compiled
const { default: _App } = import(`${'/home/projects/node-ru2nde/src/App.jsx'}`) // 👎 `src/App.jsx` not compiled

Additional context

No response

Logs

Unknown file extension ".jsx" for /home/projects/node-ru2nde/src/App.jsx

  at __node_internal_captureLargerStackTrace2 (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:101:5335)
  at new NodeError (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:101:4149)
  at Object.getFileProtocolModuleFormat [as file:] (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:149:1318)
  at defaultGetFormat (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:149:1953)
  at defaultLoad (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:153:1154)
  at ModuleLoader.load (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:154:3400)
  at ModuleLoader. (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:154:2452)
  at new ModuleJob (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:155:876)
  at #s (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:154:2337)
  at ModuleLoader.getJobFromResolveResult (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:154:2195)
  at ModuleLoader.getModuleJob (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:154:1965)
  at async ModuleLoader.import (https://noderu2nde-alzg.w-corp-staticblitz.com/builtins.ddb8d84d.js:154:2646)
@ghost ghost added the pending triage label Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants