From 08f025b71de90252fc34255f10af6c0cbc016e49 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Sat, 20 Jul 2024 15:28:15 +0100 Subject: [PATCH] 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 --- app/services/legacy-module-mappings.js | 9 ++------- ember-cli-build.js | 8 +------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/app/services/legacy-module-mappings.js b/app/services/legacy-module-mappings.js index 9b535230..eac3522f 100644 --- a/app/services/legacy-module-mappings.js +++ b/app/services/legacy-module-mappings.js @@ -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', @@ -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) { @@ -32,10 +31,6 @@ export default class LegacyModuleMappingsService extends Service { }); } - fetch() { - return fetch('/assets/mappings.json'); - } - getModule(name, documentedModule) { if (!this.mappings) { return ''; diff --git a/ember-cli-build.js b/ember-cli-build.js index 2b2f5ef9..251fa0e8 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -57,12 +57,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, @@ -72,5 +66,5 @@ module.exports = function (defaults) { staticComponents: true, }); - return mergeTrees([require('prember').prerender(app, appTree), mappingsTree]); + return mergeTrees(require('prember').prerender(app, appTree)); };