-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #773 from embroider-build/addon-shim
Updates to addon shim
- Loading branch information
Showing
20 changed files
with
406 additions
and
92 deletions.
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,23 @@ | ||
# unconventional js | ||
/blueprints/*/files/ | ||
/vendor/ | ||
|
||
# compiled output | ||
/dist/ | ||
/tmp/ | ||
/src/**/*.js | ||
/src/**/*.d.ts | ||
|
||
# dependencies | ||
/bower_components/ | ||
/node_modules/ | ||
|
||
# misc | ||
/coverage/ | ||
!.* | ||
.eslintcache | ||
|
||
# ember-try | ||
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/package.json.ember-try |
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,81 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
root: true, | ||
parser: 'babel-eslint', | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
legacyDecorators: true, | ||
}, | ||
}, | ||
plugins: ['ember'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:ember/recommended', | ||
'plugin:prettier/recommended', | ||
], | ||
env: { | ||
browser: true, | ||
}, | ||
overrides: [ | ||
// node files | ||
{ | ||
files: [ | ||
'.eslintrc.js', | ||
'.prettierrc.js', | ||
'.template-lintrc.js', | ||
'ember-cli-build.js', | ||
'addon-main.js', | ||
'testem.js', | ||
'blueprints/*/index.js', | ||
'config/**/*.js', | ||
'tests/dummy/config/**/*.js', | ||
], | ||
excludedFiles: [ | ||
'addon/**', | ||
'addon-test-support/**', | ||
'app/**', | ||
'tests/dummy/app/**', | ||
], | ||
parserOptions: { | ||
sourceType: 'script', | ||
}, | ||
env: { | ||
browser: false, | ||
node: true, | ||
}, | ||
plugins: ['node'], | ||
extends: ['plugin:node/recommended'], | ||
}, | ||
// node typescript files | ||
{ | ||
files: ['src/**/*.ts'], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 2017, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
extends: ['prettier/@typescript-eslint'], | ||
rules: { | ||
'@typescript-eslint/naming-convention': [ | ||
'error', | ||
{ | ||
selector: 'typeLike', | ||
format: ['PascalCase'], | ||
}, | ||
], | ||
'@typescript-eslint/consistent-type-assertions': 'error', | ||
'@typescript-eslint/no-inferrable-types': 'error', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
{ argsIgnorePattern: '^_' }, | ||
], | ||
'no-unused-vars': 'off', | ||
'@typescript-eslint/no-require-imports': 'error', | ||
}, | ||
}, | ||
], | ||
}; |
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,29 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# compiled output | ||
/dist/ | ||
/tmp/ | ||
/src/**/*.js | ||
/src/**/*.d.ts | ||
/src/**/*.map | ||
|
||
# dependencies | ||
/bower_components/ | ||
/node_modules/ | ||
|
||
# misc | ||
/.env* | ||
/.pnp* | ||
/.sass-cache | ||
/.eslintcache | ||
/connect.lock | ||
/coverage/ | ||
/libpeerconnection.log | ||
/npm-debug.log* | ||
/testem.log | ||
/yarn-error.log | ||
|
||
# ember-try | ||
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/package.json.ember-try |
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,33 @@ | ||
# compiled output | ||
/dist/ | ||
/tmp/ | ||
|
||
# dependencies | ||
/bower_components/ | ||
|
||
# misc | ||
/.bowerrc | ||
/.editorconfig | ||
/.ember-cli | ||
/.env* | ||
/.eslintcache | ||
/.eslintignore | ||
/.eslintrc.js | ||
/.git/ | ||
/.gitignore | ||
/.template-lintrc.js | ||
/.travis.yml | ||
/.watchmanconfig | ||
/bower.json | ||
/config/ember-try.js | ||
/CONTRIBUTING.md | ||
/ember-cli-build.js | ||
/testem.js | ||
/tests/ | ||
/yarn.lock | ||
.gitkeep | ||
|
||
# ember-try | ||
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/package.json.ember-try |
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,21 @@ | ||
# unconventional js | ||
/blueprints/*/files/ | ||
/vendor/ | ||
|
||
# compiled output | ||
/dist/ | ||
/tmp/ | ||
|
||
# dependencies | ||
/bower_components/ | ||
/node_modules/ | ||
|
||
# misc | ||
/coverage/ | ||
!.* | ||
.eslintcache | ||
|
||
# ember-try | ||
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/package.json.ember-try |
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 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
singleQuote: true, | ||
}; |
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 @@ | ||
{ | ||
"ignore_dirs": ["tmp", "dist"] | ||
} |
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,64 @@ | ||
# @embroider/addon-shim | ||
|
||
Makes a v2 addon work like a v1 addon so it can be used in a classic (non-Embroider) app. | ||
|
||
This allows addons to update to v2 without waiting for all their users to upgrade to Embroider. | ||
|
||
## Compatibility | ||
|
||
- Ember.js v3.13 or above | ||
- Ember CLI v2.13 or above | ||
- Node.js v10 or above | ||
|
||
## Installation | ||
|
||
``` | ||
ember install @embroider/util | ||
``` | ||
|
||
## Usage | ||
|
||
To use it: | ||
|
||
1. Be prepared to do a semver major release of your addon, because the shim demands that the app has ember-auto-import >= 2. | ||
2. Create an `addon-main.js` file that requires and invokes the shim: | ||
|
||
```js | ||
const { addonV1Shim } = require('@embroider/addon-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. Example: | ||
|
||
```js | ||
module.exports = addonV1Shim(__dirname, { | ||
disabled(options) { | ||
let welcomeConfig = options['ember-welcome-page'] || {}; | ||
return process.env.EMBER_ENV === 'production' && !welcomeConfig.enabled; | ||
}, | ||
}); | ||
``` | ||
|
||
This option _only_ works in non-embroider builds. Under embroider, apps just won't import the parts of your addon they don't want. | ||
|
||
## Contributing | ||
|
||
See the top-level CONTRIBUTING.md in this monorepo. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. |
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,12 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
name: require('./package').name, | ||
|
||
included(...args) { | ||
this._super.included.apply(this, args); | ||
this.addons | ||
.find((a) => a.name === 'ember-auto-import') | ||
.registerV2Addon(this.parent.name, this.parent.pkg.root); | ||
}, | ||
}; |
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 @@ | ||
{ | ||
"name": "@embroider/addon-shim", | ||
"version": "0.39.1", | ||
"description": "Make v2 addons work in non-Embroider apps.", | ||
"keywords": [ | ||
"ember-addon" | ||
], | ||
"main": "./src/index.js", | ||
"repository": "", | ||
"license": "MIT", | ||
"author": "", | ||
"directories": { | ||
"doc": "doc", | ||
"test": "tests" | ||
}, | ||
"scripts": { | ||
"prepare": "tsc", | ||
"build": "ember build --environment=production", | ||
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:!(fix)'", | ||
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix", | ||
"lint:hbs": "ember-template-lint .", | ||
"lint:hbs:fix": "ember-template-lint . --fix", | ||
"lint:js": "eslint . --cache", | ||
"lint:js:fix": "eslint . --fix", | ||
"start": "ember serve", | ||
"test": "npm-run-all lint test:*", | ||
"test:ember": "cross-env EMBROIDER_TEST_SETUP_FORCE=embroider EMBROIDER_TEST_SETUP_OPTIONS=optimized ember test --test-port=0", | ||
"test:classic": "cross-env EMBROIDER_TEST_SETUP_FORCE=classic ember test --test-port=0", | ||
"test:ember-compatibility": "ember try:each" | ||
}, | ||
"dependencies": { | ||
"@embroider/shared-internals": "^0.39.1", | ||
"ember-auto-import": "2.0.0-alpha.0", | ||
"semver": "^7.3.4" | ||
}, | ||
"devDependencies": { | ||
"@types/semver": "^7.3.4" | ||
}, | ||
"engines": { | ||
"node": "10.* || >= 12" | ||
}, | ||
"ember-addon": { | ||
"main": "addon-main.js" | ||
}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
} | ||
} |
Oops, something went wrong.