Skip to content

Commit

Permalink
fix: get FastBoot compatibility working again
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlafroscia committed Jan 1, 2019
1 parent 559fc74 commit ba29d12
Show file tree
Hide file tree
Showing 6 changed files with 483 additions and 26 deletions.
4 changes: 3 additions & 1 deletion addon/instance-initializers/hydrate-fastboot-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export function initialize(appInstance) {
const shoebox = get(fastboot, 'shoebox');
const emotionIds = shoebox.retrieve(FASTBOOT_STYLE_CACHE_NAME);

hydrate(emotionIds);
if (emotionIds) {
hydrate(emotionIds);
}
}
}

Expand Down
5 changes: 1 addition & 4 deletions fastboot/instance-initializers/setup-style-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ export function initialize(application) {
}

// Put IDs into shoebox for re-hydration
shoebox.put(
FASTBOOT_STYLE_CACHE_NAME,
Object.keys(emotion.caches.inserted)
);
shoebox.put(FASTBOOT_STYLE_CACHE_NAME, Object.keys(emotion.cache.inserted));

document.head.appendChild(style);
});
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = {
this._super.included.apply(this, arguments);

this.import('node_modules/emotion/dist/emotion.umd.min.js', {
using: [{ transformation: 'amd', as: 'emotion' }]
using: [{ transformation: 'amd', as: 'emotion-umd' }]
});

const opts = this.appOptions();
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"broccoli-asset-rev": "^2.7.0",
"ember-cli": "~3.6.0",
"ember-cli-dependency-checker": "^3.0.0",
"ember-cli-fastboot": "^2.0.0",
"ember-cli-github-pages": "^0.2.1",
"ember-cli-htmlbars": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
Expand Down Expand Up @@ -83,6 +84,9 @@
},
"ember-addon": {
"configPath": "tests/dummy/config",
"demoURL": "http://alexlafroscia.com/ember-emotion"
"demoURL": "http://alexlafroscia.com/ember-emotion",
"fastbootDependencies": [
"emotion"
]
}
}
20 changes: 20 additions & 0 deletions vendor/shims/emotion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(function() {
function vendorModule() {
'use strict';

const emotion =
typeof FastBoot !== 'undefined'
? FastBoot.require('emotion')
: require('emotion-umd');

return Object.assign(
{
default: emotion,
__esModule: true
},
emotion
);
}

define('emotion', [], vendorModule);
})();
Loading

0 comments on commit ba29d12

Please sign in to comment.