This addon allows importing files that are in the CommonJS format via the
app.import functionality added in ember-cli 2.16.
ember install ember-cli-cjs-transform
ember-cli-build.js file just like the
For example, add the following to import
index.js into your build:
At build time we automatically follow all dependencies (e.g. internal
calls) in the source file, and includes their contents in the final build
This means that even for reasonably complicated things, we can
"entry point" files and everything "just" works.
Examples (used while testing functionality):
showdown-highlight for usage (without extra "shim" addon packages!):
There may be cases where you need additional rollup plugins in order to import your CommonJs files. For example, you may need to handle builtin node require statements, i.e.
var path = require('path');
For this, you may want to import the rollup plugin
rollup-plugin-node-builtins. In order to do this, include the plugin in your
package.json and use the following syntax in your
const nodeBuiltins = ;app;
You can include multiple rollup plugins in the array and pass in options via the arguments to your plugin creation function.
git clone <repository-url>this repository
- Visit your app at http://localhost:4200.
ember try:eachto test your addon against multiple Ember versions)
ember test --server
For more information on using ember-cli, visit https://ember-cli.com/.