mirror of
https://github.com/developit/microbundle.git
synced 2026-01-25 14:06:50 +00:00
Merge #571
571: Support import JSX from JS file r=ForsakenHarmony a=n3tr ## Changes - Support import JSX from JS file by adding JSX extension to `@rollup/plugin-node-resolve` plugin ## Background I have experience an error when importing `.jsx file` from `.js` file like ``` index.js -> A.jsx ``` will cause an error ``` Could not resolve './A' from src/index.js ``` However, Importing `.jsx` file from TypeScript file (`.ts`) file is seems working fine except the the import is chaining more than 3 levels depth. ```sh index.ts -> A.jsx # This is fine index.ts -> A.jsx -> B.jsx # This is fine index.ts -> A.jsx -> B.jsx -> C.jsx # Error: Could not resolve './C' from src/jsx-components/B.jsx ``` To reproduce the issue ```sh git clone -b import-jsx-error --single-branch git@github.com:n3tr/microbundle-example.git cd microbundle-example yarn yarn build --jsx React.createElement ./src/index.js # or yarn build --jsx React.createElement ./src/index.ts ``` --- I'm not really sure what is the root cause of the error, by adding extensions seems to fix the problem. Co-authored-by: Jirat Ki <saakyz@gmail.com>
This commit is contained in:
commit
6012f39053
@ -527,6 +527,8 @@ function createConfig(options, entry, format, writeMeta) {
|
||||
nodeResolve({
|
||||
mainFields: ['module', 'jsnext', 'main'],
|
||||
browser: options.target !== 'node',
|
||||
// defaults + .jsx
|
||||
extensions: ['.mjs', '.js', '.jsx', '.json', '.node'],
|
||||
}),
|
||||
commonjs({
|
||||
// use a regex to make sure to include eventual hoisted packages
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user