-
Notifications
You must be signed in to change notification settings - Fork 26.3k
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
[WIP] Add support for transpile packages installed via NPM #749
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f941be6
Add support to transpile modules patterns defined it config.transpile…
arunoda 2d3346a
Support only regular expressions for config.transpileModules
arunoda 04da4e8
Use babel-register to compile modules matching config.transpileModules
arunoda 52f64e3
Add example README.
arunoda 6fada4a
Update example to use the @kadira/react-button.
arunoda 2c60efb
Merge branch 'master' into add-706
arunoda 0bee2b0
Add README.md
arunoda 5cf9dab
Fix some typos in the README.md
arunoda 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 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 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,48 @@ | ||
|
||
# Hello World example | ||
|
||
## How to use | ||
|
||
Download the example (or clone the repo)[https://github.com/zeit/next.js.git]: | ||
|
||
```bash | ||
curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-es6-npm-module-pages | ||
cd with-es6-npm-module-pages | ||
``` | ||
|
||
Install it and run: | ||
|
||
```bash | ||
cd app | ||
npm install | ||
npm run dev | ||
``` | ||
|
||
Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download)) | ||
|
||
```bash | ||
now | ||
``` | ||
|
||
## The idea behind the example | ||
|
||
This example shows how to transpile modules installed with NPM. With that, you could publish internal component libraries to NPM without transpiling and use them directly inside your Next.js app. | ||
|
||
> By default those components get transpiled with the `next/babel` preset. You could also define a custom .babelrc in your app and define presets and plugins as you want. | ||
|
||
You can do this by adding a field called `transpileModules` in the `next.config.js`. Here's an example config: | ||
|
||
```js | ||
module.exports = { | ||
// You need to define an array of regular expressions here | ||
transpileModules: [ | ||
/react-button/ | ||
] | ||
} | ||
``` | ||
|
||
Here Next.js will transpile any module matches "react-button" in it's path name. | ||
|
||
### Note | ||
|
||
We only transpile modules inside the `node_modules` directory. So, `npm link` won't work in this case. |
This file contains 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,5 @@ | ||
module.exports = { | ||
transpileModules: [ | ||
/react-button/ | ||
] | ||
} |
This file contains 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 @@ | ||
{ | ||
"name": "with-es6-npm-module-pages", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"dev": "next", | ||
"build": "next build", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"@kadira/react-button": "^1.0.2", | ||
"next": "^2.0.0-beta" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains 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 default () => ( | ||
<div>About us</div> | ||
) |
This file contains 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,16 @@ | ||
/* globals alert */ | ||
|
||
import Link from 'next/link' | ||
import Button from '@kadira/react-button/src' | ||
|
||
export default () => ( | ||
<div> | ||
<p> | ||
Hello World. <Link href='/about'>About</Link> | ||
</p> | ||
|
||
<Button onClick={() => alert('Hello!')}> | ||
Say Hello | ||
</Button> | ||
</div> | ||
) |
Oops, something went wrong.
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.
so it does not work with symlinks (like Lerna do?) not sure to understand that comment
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.
For now yes it is.