Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embroider compatibility #230

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
25 changes: 21 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,30 @@ module.exports = {
`);
},

postprocessTree(type, appTree) {
let options = this._getOptions();
buildServiceWorker(app, tree) {
let eswAddon = app.project.addons.find(
({ name }) => name === 'ember-service-worker'
);

if (!eswAddon) {
throw new Error(
"Could not find initialized ember-service-worker addon. It must be part of your app's dependencies!"
);
}

return eswAddon._postprocessTree(tree);
},

postprocessTree(type, appTree) {
if (type !== 'all' || options.enabled === false) {
return appTree;
}

return this._postprocessTree(tree);
},

_postprocessTree(appTree) {
let options = this._getOptions();
let plugins = this._findPluginsFor(this.project);

// Add the project itself as a possible plugin, this way user can add custom
Expand Down Expand Up @@ -109,7 +126,7 @@ module.exports = {

if (type === 'body-footer') {
if (options.registrationStrategy === 'default') {
return `<script src="${this._getRootURL()}${srcPath}"></script>`;
return `<script data-embroider-ignore src="${this._getRootURL()}${srcPath}"></script>`;
}

if (options.registrationStrategy === 'inline') {
Expand All @@ -118,7 +135,7 @@ module.exports = {
}

if (type === 'head-footer' && options.registrationStrategy === 'async') {
return `<script async src="${this._getRootURL()}${srcPath}"></script>`;
return `<script data-embroider-ignore async src="${this._getRootURL()}${srcPath}"></script>`;
}
},

Expand Down