Skip to content
This repository was archived by the owner on Dec 16, 2021. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Copy link
Member

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-compat to include an export that auto-generates this?

import alias from 'rollup-plugin-alias';
import aliases from 'preact-compat/aliases';

export default {
  // ...
  plugins: [
    alias(aliases)
  ]
};

Copy link
Author

@ansballard ansballard Jun 21, 2017

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!

"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({
Copy link

@crccheck crccheck Jun 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it were to be trimmed down...

The replace step seem unrelated to the intent of just using rollup + preact. As a newb, I'd prefer the smallest example that works. I'd prefer if this was trimmed

"process.env.NODE_ENV": JSON.stringify("development") // prop-types
}),
buble() // es6
// ...
}
```

## Usage with Babel

Using `preact-compat` with Babel is easy.
Expand Down