Skip to content

Commit

Permalink
fix(plugin): polyfill upgrade breaking build (#374)
Browse files Browse the repository at this point in the history
A minor version
[change](davidmyersdev/vite-plugin-node-polyfills@abf35b8#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>
  • Loading branch information
mkilpatrick and github-actions[bot] authored Aug 11, 2023
1 parent fa613e3 commit d376d4c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 81 deletions.
11 changes: 10 additions & 1 deletion packages/pages/src/vite-plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
43 changes: 2 additions & 41 deletions playground/locations-site/sites-config/features.json
Original file line number Diff line number Diff line change
@@ -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": []
}
Original file line number Diff line number Diff line change
@@ -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": []
}

0 comments on commit d376d4c

Please sign in to comment.