Skip to content

Commit 7438dbc

Browse files
committed
stop requesting mappings over the network
for some reason we're requesting the mappings.json file on every initial page load (and not cached in the shoebox). This is in the application afterModel hook so there is no chance that we will ever not make this request, so it's worth just backing the json into the JS bundle to save a request
1 parent 4677173 commit 7438dbc

8 files changed

+30
-64
lines changed

Diff for: app/routes/class.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,13 @@ export default class ClassRoute extends Route {
1010
legacyModuleMappings;
1111

1212
model(params) {
13-
return this.legacyModuleMappings
14-
.fetch()
15-
.then((response) => response.json())
16-
.then((mappings) => {
17-
let ret = {
18-
mappings: this.legacyModuleMappings.buildMappings(mappings),
19-
className: params['class'].substr(
20-
0,
21-
params['class'].lastIndexOf('.')
22-
),
23-
};
24-
return ret;
25-
});
13+
let ret = {
14+
mappings: this.legacyModuleMappings.buildMappings(
15+
this.legacyModuleMappings.legacyMappings
16+
),
17+
className: params['class'].substr(0, params['class'].lastIndexOf('.')),
18+
};
19+
return ret;
2620
}
2721

2822
redirect(model) {

Diff for: app/routes/data-class.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@ export default class DataClassRoute extends Route {
1010
legacyModuleMappings;
1111

1212
model(params) {
13-
return this.legacyModuleMappings
14-
.fetch()
15-
.then((response) => response.json())
16-
.then((mappings) => {
17-
return {
18-
mappings: this.legacyModuleMappings.buildMappings(mappings),
19-
className: params['class'].substr(
20-
0,
21-
params['class'].lastIndexOf('.')
22-
),
23-
};
24-
});
13+
return {
14+
mappings: this.legacyModuleMappings.buildMappings(
15+
this.legacyModuleMappings.legacyMappings
16+
),
17+
className: params['class'].substr(0, params['class'].lastIndexOf('.')),
18+
};
2519
}
2620

2721
redirect(model) {

Diff for: app/routes/data-module.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ export default class DataModuleRoute extends Route {
1010
legacyModuleMappings;
1111

1212
model(params) {
13-
return this.legacyModuleMappings
14-
.fetch()
15-
.then((response) => response.json())
16-
.then((mappings) => {
17-
return {
18-
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
19-
mappings: this.legacyModuleMappings.buildMappings(mappings),
20-
};
21-
});
13+
return {
14+
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
15+
mappings: this.legacyModuleMappings.buildMappings(
16+
this.legacyModuleMappings.legacyMappings
17+
),
18+
};
2219
}
2320

2421
redirect(model) {

Diff for: app/routes/module.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ export default class ModuleRoute extends Route {
1010
legacyModuleMappings;
1111

1212
model(params) {
13-
return this.legacyModuleMappings
14-
.fetch()
15-
.then((response) => response.json())
16-
.then((mappings) => {
17-
return {
18-
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
19-
mappings: this.legacyModuleMappings.buildMappings(mappings),
20-
};
21-
});
13+
return {
14+
moduleName: params.module.substr(0, params.module.lastIndexOf('.')),
15+
mappings: this.legacyModuleMappings.buildMappings(
16+
this.legacyModuleMappings.legacyMappings
17+
),
18+
};
2219
}
2320

2421
redirect(model) {

Diff for: app/services/legacy-module-mappings.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import fetch from 'fetch';
21
import Service from '@ember/service';
32
import { tracked } from '@glimmer/tracking';
43

4+
import legacyMappings from 'ember-rfc176-data/mappings.json';
5+
56
const LOCALNAME_CONVERSIONS = {
67
Object: 'EmberObject',
78
Array: 'EmberArray',
@@ -10,12 +11,11 @@ const LOCALNAME_CONVERSIONS = {
1011

1112
export default class LegacyModuleMappingsService extends Service {
1213
@tracked mappings;
14+
legacyMappings = legacyMappings;
1315

1416
async initMappings() {
1517
try {
16-
let response = await this.fetch();
17-
let mappings = await response.json();
18-
let newMappings = this.buildMappings(mappings);
18+
let newMappings = this.buildMappings(legacyMappings);
1919
this.mappings = newMappings;
2020
} catch (e) {
2121
this.mappings = [];
@@ -32,10 +32,6 @@ export default class LegacyModuleMappingsService extends Service {
3232
});
3333
}
3434

35-
fetch() {
36-
return fetch('/assets/mappings.json');
37-
}
38-
3935
getModule(name, documentedModule) {
4036
if (!this.mappings) {
4137
return '';

Diff for: ember-cli-build.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict';
22

33
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
4-
const Funnel = require('broccoli-funnel');
5-
const mergeTrees = require('broccoli-merge-trees');
64
const envIsProduction = process.env.EMBER_ENV === 'production';
75
const premberUrls = require('./prember-urls');
86
const nodeSass = require('node-sass');
@@ -57,12 +55,6 @@ module.exports = function (defaults) {
5755
},
5856
});
5957

60-
let mappingsTree = new Funnel('node_modules/ember-rfc176-data/', {
61-
srcDir: '/',
62-
include: ['mappings.json'],
63-
destDir: '/assets/',
64-
});
65-
6658
const { Webpack } = require('@embroider/webpack');
6759
const appTree = require('@embroider/compat').compatBuild(app, Webpack, {
6860
staticAddonTrees: true,
@@ -72,5 +64,5 @@ module.exports = function (defaults) {
7264
staticComponents: true,
7365
});
7466

75-
return mergeTrees([require('prember').prerender(app, appTree), mappingsTree]);
67+
return require('prember').prerender(app, appTree);
7668
};

Diff for: package.json

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"bourbon-neat": "^1.9.1",
6262
"broccoli-asset-rev": "^3.0.0",
6363
"broccoli-funnel": "^2.0.1",
64-
"broccoli-merge-trees": "^2.0.0",
6564
"ember-a11y-testing": "^5.2.1",
6665
"ember-anchor": "^1.0.3",
6766
"ember-auto-import": "^2.7.2",

Diff for: pnpm-lock.yaml

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)