From d376d4c1cb2be732d9c825935b614170de021328 Mon Sep 17 00:00:00 2001 From: Matt Kilpatrick Date: Fri, 11 Aug 2023 06:16:26 -0800 Subject: [PATCH] fix(plugin): polyfill upgrade breaking build (#374) A minor version [change](https://github.com/davidmyersdev/vite-plugin-node-polyfills/commit/abf35b8c0309b0d5fc43d5e51e037d4ee4f675e3#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R164) to vite-plugin-node-polyfill adds a dev-only polyfill because it always assumes dev. This breaks the build when generating features because window is undefined. This changes the globals to be polyfilled as "build". --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- packages/pages/src/vite-plugin/plugin.ts | 11 ++++- .../locations-site/sites-config/features.json | 43 +------------------ .../sunglasses.oakley.com/features.json | 41 +----------------- 3 files changed, 14 insertions(+), 81 deletions(-) diff --git a/packages/pages/src/vite-plugin/plugin.ts b/packages/pages/src/vite-plugin/plugin.ts index 5150ee57d..dafc8eafa 100644 --- a/packages/pages/src/vite-plugin/plugin.ts +++ b/packages/pages/src/vite-plugin/plugin.ts @@ -15,7 +15,16 @@ const plugin = (): PluginOption[] => { }; const projectStructure = new ProjectStructure(projectConfigFromBuildArgs); - return [build(projectStructure), nodePolyfills()]; + return [ + build(projectStructure), + nodePolyfills({ + globals: { + Buffer: "build", + global: "build", + process: "build", + }, + }), + ]; }; export default plugin; diff --git a/playground/locations-site/sites-config/features.json b/playground/locations-site/sites-config/features.json index f80e38ca0..02c781471 100644 --- a/playground/locations-site/sites-config/features.json +++ b/playground/locations-site/sites-config/features.json @@ -1,43 +1,4 @@ { - "features": [ - { - "name": "turtlehead-tacos", - "templateType": "JS", - "staticPage": {} - }, - { - "name": "robots", - "templateType": "JS", - "staticPage": {} - }, - { - "name": "location", - "streamId": "location-stream", - "templateType": "JS", - "entityPageSet": {} - } - ], - "streams": [ - { - "$id": "location-stream", - "filter": { - "entityTypes": [ - "location" - ] - }, - "fields": [ - "id", - "uid", - "meta", - "address", - "slug" - ], - "localization": { - "locales": [ - "en" - ], - "primary": false - } - } - ] + "features": [], + "streams": [] } \ No newline at end of file diff --git a/playground/multibrand-site/sites-config/sunglasses.oakley.com/features.json b/playground/multibrand-site/sites-config/sunglasses.oakley.com/features.json index 87177a020..02c781471 100644 --- a/playground/multibrand-site/sites-config/sunglasses.oakley.com/features.json +++ b/playground/multibrand-site/sites-config/sunglasses.oakley.com/features.json @@ -1,41 +1,4 @@ { - "features": [ - { - "name": "sunglasses", - "streamId": "oakley-stream", - "templateType": "JS", - "entityPageSet": {} - }, - { - "name": "turtlehead-tacos", - "templateType": "JS", - "staticPage": {} - }, - { - "name": "robots", - "templateType": "JS", - "staticPage": {} - } - ], - "streams": [ - { - "$id": "oakley-stream", - "fields": [ - "id", - "name", - "slug" - ], - "filter": { - "savedFilterIds": [ - "1241548641" - ] - }, - "localization": { - "locales": [ - "en" - ], - "primary": false - } - } - ] + "features": [], + "streams": [] } \ No newline at end of file