From 488fe05bb373af1be8849cac8f795b7b8528a816 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli Date: Sat, 18 Jun 2022 08:53:57 -0400 Subject: [PATCH] chore(estimate-bytes): manage externals a bit better --- build/estimate-bytes/index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/build/estimate-bytes/index.js b/build/estimate-bytes/index.js index 7580ba771..9a581b1c9 100644 --- a/build/estimate-bytes/index.js +++ b/build/estimate-bytes/index.js @@ -11,6 +11,9 @@ import filesize from 'filesize'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const root = path.join(__dirname, '../..'); const dist = path.join(root, 'ember-resources/dist'); +const packageJsonPath = path.join(root, 'ember-resources/package.json'); + +let packageJson; const config = { bundles: { @@ -28,6 +31,8 @@ const config = { * 3. Find gzip + brotli sizes */ async function collectStats() { + packageJson = JSON.parse((await fs.readFile(packageJsonPath)).toString()); + let { path: tmp } = await tmpDir(); let bundlePatterns = Object.keys(config.bundles); @@ -83,6 +88,11 @@ async function collectStats() { } async function bundle(entry, outFile) { + let externals = [ + ...Object.keys(packageJson.dependencies || {}), + ...Object.keys(packageJson.peerDependencies || {}) + ]; + /** * Utils are one file */ @@ -94,10 +104,17 @@ async function bundle(entry, outFile) { outfile: outFile, bundle: true, external: [ + ...externals, + 'ember', '@ember/application', '@ember/debug', '@ember/helper', '@ember/destroyable', + '@ember/object', + '@ember/runloop', + '@ember/test', + '@embroider/macros', + '@glimmer/component', '@glimmer/tracking', ], });