From 0b8ec9c78961aa8ea8e470b602dfd6129c69d4e7 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Mon, 12 Jul 2021 10:29:00 -0500 Subject: [PATCH 1/2] prebundle only for development builds --- changelog.md | 2 ++ src/build/postprocess.ts | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 1152942772..9e8869a434 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,8 @@ ## 0.33.1 +- fix `gro_adapter_gro_frontend` by prebundling externals only for development builds + ([#249](https://github.com/feltcoop/gro/pull/249)) - upgrade `es-module-lexer@0.7.1` ([#248](https://github.com/feltcoop/gro/pull/248)) diff --git a/src/build/postprocess.ts b/src/build/postprocess.ts index e8ffb21731..8dab9dd732 100644 --- a/src/build/postprocess.ts +++ b/src/build/postprocess.ts @@ -169,9 +169,9 @@ const to_build_dependency = ( ctx: Build_Context, ): Build_Dependency => { const {dev, externals_aliases, build_dir} = ctx; - const browser = build_config.platform === 'browser'; let build_id: string; let final_specifier = specifier; // this is the raw specifier, but pre-mapped for common externals + const prebundle = dev && build_config.platform === 'browser'; // don't prebundle in production const is_external_import = is_external_module(specifier); const is_external_imported_by_external = source.id === EXTERNALS_SOURCE_ID; const is_external = is_external_import || is_external_imported_by_external; @@ -180,7 +180,7 @@ const to_build_dependency = ( mapped_specifier = to_build_extension(specifier, dev); if (is_external_import) { // handle regular externals - if (browser) { + if (prebundle) { if (mapped_specifier in externals_aliases) { mapped_specifier = externals_aliases[mapped_specifier]; } @@ -201,12 +201,12 @@ const to_build_dependency = ( } } else { // handle common externals, imports internal to the externals - if (browser) { + if (prebundle) { build_id = join(dir, specifier); // use absolute paths for internal externals specifiers, so we get stable ids final_specifier = build_id; } else { - // externals imported in Node builds use Node module resolution + // externals imported in production and Node builds use Node module resolution build_id = mapped_specifier; } } @@ -224,7 +224,7 @@ const to_build_dependency = ( mapped_specifier, original_specifier: specifier, build_id, - external: browser && is_external, + external: prebundle && is_external, }; }; From 4b2ce47a35ce547e0ff9fd3e59b3b3ea00a05c67 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Mon, 12 Jul 2021 10:29:28 -0500 Subject: [PATCH 2/2] prebundle only in development --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 9e8869a434..0d782633f1 100644 --- a/changelog.md +++ b/changelog.md @@ -2,7 +2,7 @@ ## 0.33.1 -- fix `gro_adapter_gro_frontend` by prebundling externals only for development builds +- fix `gro_adapter_gro_frontend` by prebundling externals only in development ([#249](https://github.com/feltcoop/gro/pull/249)) - upgrade `es-module-lexer@0.7.1` ([#248](https://github.com/feltcoop/gro/pull/248))