-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Add .jsx extension support #3376
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
Merged
timneutkens
merged 23 commits into
vercel:canary
from
timneutkens:add/jsx-extension-resolve
Dec 5, 2017
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
b225e38
Add .jsx extension
timneutkens de5d553
Merge branch 'canary' of github.com:zeit/next.js into add/jsx-extensi…
timneutkens 7977261
Merge branch 'canary' into add/jsx-extension-resolve
arunoda ce89edc
examples: add create-next-app (#3377)
fouad 0540558
Upgrading with-flow example to the latest flow-bin ver. 0.59.0 (#3337)
davscro 1c55e77
doc'd fs-routing option & added note on `passHref` (#3384)
brandonmp 8f0b7f5
fix typo in readme.md (#3385)
kanjielu 32f9ab3
Upgrade styled-jsx to v2.2.1 (#3358)
giuseppeg e2888b8
Make sure import that doesn’t end in .jsx works
timneutkens 8bff9a8
Move tests
timneutkens 450aa3f
Merge branch 'canary' into add/jsx-extension-resolve
timneutkens 6107c1a
Show error when .js and .jsx both exist
timneutkens 4a3d4a9
Remove .jsx when importing from ‘path.jsx’
timneutkens a83d922
Fixes
timneutkens 6f76712
Get .jsx resolver back
timneutkens 69e592e
Revert "Get .jsx resolver back"
timneutkens 60fc776
Revert "Revert "Get .jsx resolver back""
timneutkens 630cf5a
Add remove .jsx to preset
timneutkens 5e3ef1a
Remove jsx resolver
timneutkens 8248e50
Revert "Remove jsx resolver"
timneutkens 2a6d418
Revert "Revert "Remove jsx resolver""
timneutkens 87428c9
Revert "Revert "Revert "Remove jsx resolver"""
timneutkens 86f95be
Make 1 component not use .jsx
timneutkens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // This plugins removes the `.jsx` extension from import statements. Because we transpile .jsx files to .js in .next | ||
| // E.g. `import Hello from '../components/hello.jsx'` will become `import Hello from '../components/hello'` | ||
| module.exports = function ({types}) { | ||
| return { | ||
| name: 'remove-dotjsx-from-import', | ||
| visitor: { | ||
| ImportDeclaration (path) { | ||
| const value = path.node.source.value | ||
| if (value.slice(-4) === '.jsx') { | ||
| path.node.source = types.stringLiteral(value.slice(0, -4)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export const Hello = () => ( | ||
| <div>Hello</div> | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export const World = () => ( | ||
| <div>World</div> | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import {World} from '../components/world' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add another case where we are importing with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done 👍 |
||
| import {Hello} from '../components/hello.jsx' | ||
|
|
||
| export default () => ( | ||
| <div><Hello/> <World/></div> | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used by the ondemandentries plugin to resolve the file within webpack. That's why it's needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next build -> next start etc work fine without this.