This repository was archived by the owner on Dec 16, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 126
Added a rollup config section to the readme #398
Open
ansballard
wants to merge
2
commits into
preactjs:master
Choose a base branch
from
ansballard:rollup-docs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -94,6 +94,43 @@ First, install it: `npm install --save-dev aliasify` | |
| } | ||
| ``` | ||
|
|
||
| ## Usage with Rollup | ||
|
|
||
| Using `preact-compat` with rollup requires [rollup-plugin-alias](http://npm.im/rollup-plugin-alias), along with a few other plugins | ||
|
|
||
| First, install it: `npm install --save-dev rollup-plugin-alias rollup-plugin-buble rollup-plugin-commonjs rollup-plugin-node-resolve rollup-plugin-replace` | ||
|
|
||
| ... then in your `rollup.config.js`, configure the alias plugin to point to `react` and `react-dom`, along with the rest of the plugins: | ||
|
|
||
| ```js | ||
| import alias from "rollup-plugin-alias"; | ||
| import buble from "rollup-plugin-buble"; | ||
| import resolve from "rollup-plugin-node-resolve"; | ||
| import replace from "rollup-plugin-replace"; | ||
| import commonjs from "rollup-plugin-commonjs"; | ||
| // ... | ||
|
|
||
| export default { | ||
| // ... | ||
| plugins: [ | ||
| // ... | ||
| resolve({ | ||
| jsnext: true // preact | ||
| }), | ||
| alias({ | ||
| "react": "node_modules/preact-compat/dist/preact-compat.es.js", | ||
| "react-dom": "node_modules/preact-compat/dist/preact-compat.es.js", | ||
| "create-react-class": "node_modules/preact-compat/lib/create-react-class.js" | ||
| }), | ||
| commonjs(), // prop-types | ||
| replace({ | ||
|
||
| "process.env.NODE_ENV": JSON.stringify("development") // prop-types | ||
| }), | ||
| buble() // es6 | ||
| // ... | ||
| } | ||
| ``` | ||
|
|
||
| ## Usage with Babel | ||
|
|
||
| Using `preact-compat` with Babel is easy. | ||
|
|
||
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.
Unrelated to this docs PR, but do you think it might be useful for
preact-compatto include an export that auto-generates this?Uh oh!
There was an error while loading. Please reload this page.
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.
oh, that's a cool idea. Although the function shorthand may confuse users that want to use more than just the preact aliases, since they would need to be a little more verbose and use destructuring with the regular object syntax.
Oh nevermind, they could just
...the args going in, I should know not to comment before the caffeine kicks in. Seems good to me!