Skip to content

Commit

Permalink
mention shim in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 committed Mar 30, 2021
1 parent c375da3 commit 00db51a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions packages/util/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,45 @@ The first argument is allowed to be:

In the Javascript version, you must pass a second argument that is any object with an owner (a `Component` instance works great).

## addonV1Shim

This makes a V2-formatted addon act like a v1 addon in non-embroider builds. It lets addons ship as v2 even though their users aren't using embroider yet.

To use it:

1. Be prepared to do a semver major release of your addon, because the shim demands that consumers of your package must have a new-enough version of ember-auto-import. ember-auto-import is how we get v2 addons into non-embroider builds. You will want to document the minimum supported ember-auto-import version needed by the version of the shim you're using.
2. Create an `addon-main.js` file that requires and invokes the shim:

```js
const { addonV1Shim } = require('@embroider/util/shim');
module.exports = addonV1Shim(__dirname);
```

3. Update your `package.json` to point at addon-main.js:

```json
{
"ember-addon": {
"version": 2,
"type": "addon",
"main": "addon-main.js"
}
}
```

### Shim Options

**disabled**: this optional argument lets you control whether your shimmed addon will emit `'app-js'` and `'public-assets'` into non-embroider builds. This _only_ works in non-embroider builds, because under embroider apps just won't import the parts of your addon they don't want. Example:

```js
module.exports = addonV1Shim(__dirname, {
disabled(options) {
let welcomeConfig = options['ember-welcome-page'] || {};
return process.env.EMBER_ENV === 'production' && !welcomeConfig.enabled;
},
});
```

## Contributing

See the [Contributing](CONTRIBUTING.md) guide for details.
Expand Down

0 comments on commit 00db51a

Please sign in to comment.