Skip to content

Commit e46507f

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 ff0844c commit e46507f

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

app/services/legacy-module-mappings.js

Lines changed: 2 additions & 7 deletions
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 mappings from 'ember-rfc176-data/mappings.json';
5+
56
const LOCALNAME_CONVERSIONS = {
67
Object: 'EmberObject',
78
Array: 'EmberArray',
@@ -13,8 +14,6 @@ export default class LegacyModuleMappingsService extends Service {
1314

1415
async initMappings() {
1516
try {
16-
let response = await this.fetch();
17-
let mappings = await response.json();
1817
let newMappings = this.buildMappings(mappings);
1918
this.mappings = newMappings;
2019
} catch (e) {
@@ -32,10 +31,6 @@ export default class LegacyModuleMappingsService extends Service {
3231
});
3332
}
3433

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

ember-cli-build.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
4-
const Funnel = require('broccoli-funnel');
54
const mergeTrees = require('broccoli-merge-trees');
65
const envIsProduction = process.env.EMBER_ENV === 'production';
76
const premberUrls = require('./prember-urls');
@@ -57,12 +56,6 @@ module.exports = function (defaults) {
5756
},
5857
});
5958

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

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

0 commit comments

Comments
 (0)