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

Could not resolve .jsx file when import from other .jsx #523

Closed
n3tr opened this issue Feb 28, 2020 · 1 comment · Fixed by #524
Closed

Could not resolve .jsx file when import from other .jsx #523

n3tr opened this issue Feb 28, 2020 · 1 comment · Fixed by #524
Labels
kind: bug Something isn't working

Comments

@n3tr
Copy link
Contributor

n3tr commented Feb 28, 2020

Current Behavior

Encounter an error

Error: Could not resolve './ComponentC' from src/ComponentB.jsx

When import JSX file from JSX file with than 2 levels deep, eg

index.ts -> A.jsx -> B.jsx -> C.jsx
# Error: Could not resolve './C' from src/B.jsx

index.ts -> A.js -> B.jsx
# Error: Could not resolve './B' from src/A.js

index.js -> A.jsx
#  Error: Could not resolve './A' from src/index.js

Below is working fine

index.ts -> A.jsx -> B.jsx 

# or

index.ts -> A.jsx -> B.jsx -> C.jsx
index.ts -> B.jsx

Repo for reproducing

Expected behavior

The build command should be successfully

Suggested solution(s)

I don't really know what is the root cause of this, but trying to set extensions: ['.mjs', '.js', '.jsx', '.json', '.node'] to @rollup/plugin-node-resolve seems to solve the issue.

resolve({
mainFields: [
'module',
'main',
opts.target !== 'node' ? 'browser' : undefined,
].filter(Boolean) as string[],
}),

Additional context

Your environment

Software Version(s)
TSDX 0.12.3
TypeScript 3.8.2
Browser
npm/Yarn
Node v12.4.0
Operating System
@agilgur5
Copy link
Collaborator

Weird that it works sometimes but not others... 🤔🤔

(Also you've got a typo here, you wrote rollup-plugin-typescript2 instead of @rollup/plugin-node-resolve)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants