Skip to content

Commit f861b5f

Browse files
authored
Adopt Embroider (#845)
1 parent f8da2e7 commit f861b5f

5 files changed

+3779
-586
lines changed

config/bundlesize.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ module.exports = {
44
app: {
55
javascript: {
66
pattern: 'assets/*.js',
7-
limit: '310KB',
7+
limit: '270KB',
88
compression: 'gzip',
99
},
1010
css: {
11-
pattern: 'assets/*.css',
11+
// Embroider build includes both the minified and the unminified CSS
12+
// `assets/` folder. Only the minified CSS is referenced by `index.html`.
13+
// The unminified version does not increase the bundle size for consumers.
14+
// We need to exclude it when calculating bundle size.
15+
// Only the minified version includes a fingerprint. We can exclude the
16+
// unminified version by using a pattern, which only matches files
17+
// including a fingerprint hash in their file name.
18+
pattern: 'assets/croodle.*.css',
1219
limit: '16.5KB',
1320
compression: 'gzip',
1421
},

config/ember-cli-update.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"isBaseBlueprint": true,
1313
"options": [
1414
"--ci-provider=github",
15+
"--embroider",
1516
"--typescript"
1617
]
1718
}

ember-cli-build.js

+31-39
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,21 @@
11
'use strict';
22

33
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
4+
const SubresourceIntegrityPlugin = require('webpack-subresource-integrity-embroider');
45

56
module.exports = function (defaults) {
67
const app = new EmberApp(defaults, {
7-
autoImport: {
8-
forbidEval: true,
9-
webpack: {
10-
externals: {
11-
// sjcl requires node's cryto library, which isn't needed
12-
// in Browser but causes webpack to bundle a portable version
13-
// which increases the build size by an inacceptable amount
14-
crypto: 'null',
15-
},
16-
},
17-
},
188
buildInfoOptions: {
199
metaTemplate: 'version={SEMVER}',
2010
},
2111
'ember-bootstrap': {
2212
importBootstrapCSS: false,
2313
bootstrapVersion: 4,
2414
importBootstrapFont: false,
25-
include: [
26-
'bs-alert',
27-
'bs-button',
28-
'bs-button-group',
29-
'bs-form',
30-
'bs-modal',
31-
'bs-tooltip',
32-
],
3315
},
3416
'ember-cli-babel': {
3517
enableTypeScriptTransform: true,
3618
},
37-
'ember-composable-helpers': {
38-
only: ['array', 'pick'],
39-
},
40-
'ember-math-helpers': {
41-
only: ['lte', 'sub'],
42-
},
4319
autoprefixer: {
4420
browsers: ['last 2 ios version'],
4521
cascade: false,
@@ -51,21 +27,37 @@ module.exports = function (defaults) {
5127
},
5228
});
5329

54-
// Use `app.import` to add additional libraries to the generated
55-
// output files.
56-
//
57-
// If you need to use different assets in different
58-
// environments, specify an object as the first parameter. That
59-
// object's keys should be the environment name and the values
60-
// should be the asset to use in that environment.
61-
//
62-
// If the library that you are including contains AMD or ES6
63-
// modules that you would like to import into your application
64-
// please specify an object with the list of modules as keys
65-
// along with the exports of each module as its value.
66-
6730
app.import('node_modules/open-iconic/font/fonts/open-iconic.ttf');
6831
app.import('node_modules/open-iconic/font/fonts/open-iconic.woff');
6932

70-
return app.toTree();
33+
const { Webpack } = require('@embroider/webpack');
34+
return require('@embroider/compat').compatBuild(app, Webpack, {
35+
staticAddonTestSupportTrees: true,
36+
staticAddonTrees: true,
37+
staticHelpers: true,
38+
staticModifiers: true,
39+
staticComponents: true,
40+
// `ember-cli-deprecation-workflow` does not support `staticEmberSource = true`
41+
// yet. See https://github.com/mixonic/ember-cli-deprecation-workflow/issues/156
42+
// for details.
43+
staticEmberSource: false,
44+
skipBabel: [
45+
{
46+
package: 'qunit',
47+
},
48+
],
49+
packagerOptions: {
50+
webpackConfig: {
51+
devtool: 'source-map',
52+
plugins: [new SubresourceIntegrityPlugin()],
53+
resolve: {
54+
fallback: {
55+
// SJCL supports node.js as well using node's crypto module.
56+
// We don't want it to be included in the bundle.
57+
crypto: false,
58+
},
59+
},
60+
},
61+
},
62+
});
7163
};

0 commit comments

Comments
 (0)