Skip to content

Commit

Permalink
stop requesting mappings over the network
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mansona committed Jul 20, 2024
1 parent a937223 commit f49a627
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 102 deletions.
9 changes: 2 additions & 7 deletions app/services/legacy-module-mappings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import fetch from 'fetch';
import Service from '@ember/service';
import { tracked } from '@glimmer/tracking';

import mappings from 'ember-rfc176-data/mappings.json';

const LOCALNAME_CONVERSIONS = {
Object: 'EmberObject',
Array: 'EmberArray',
Expand All @@ -13,8 +14,6 @@ export default class LegacyModuleMappingsService extends Service {

async initMappings() {
try {
let response = await this.fetch();
let mappings = await response.json();
let newMappings = this.buildMappings(mappings);
this.mappings = newMappings;
} catch (e) {
Expand All @@ -32,10 +31,6 @@ export default class LegacyModuleMappingsService extends Service {
});
}

fetch() {
return fetch('/assets/mappings.json');
}

getModule(name, documentedModule) {
if (!this.mappings) {
return '';
Expand Down
10 changes: 1 addition & 9 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
const envIsProduction = process.env.EMBER_ENV === 'production';
const premberUrls = require('./prember-urls');
const nodeSass = require('node-sass');
Expand Down Expand Up @@ -57,12 +55,6 @@ module.exports = function (defaults) {
},
});

let mappingsTree = new Funnel('node_modules/ember-rfc176-data/', {
srcDir: '/',
include: ['mappings.json'],
destDir: '/assets/',
});

const { Webpack } = require('@embroider/webpack');
const appTree = require('@embroider/compat').compatBuild(app, Webpack, {
staticAddonTrees: true,
Expand All @@ -72,5 +64,5 @@ module.exports = function (defaults) {
staticComponents: true,
});

return mergeTrees([require('prember').prerender(app, appTree), mappingsTree]);
return require('prember').prerender(app, appTree);
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"bourbon-neat": "^1.9.1",
"broccoli-asset-rev": "^3.0.0",
"broccoli-funnel": "^2.0.1",
"broccoli-merge-trees": "^2.0.0",
"ember-a11y-testing": "^0.5.4",
"ember-anchor": "^1.0.3",
"ember-auto-import": "^2.7.2",
Expand Down
Loading

0 comments on commit f49a627

Please sign in to comment.