Description
From this merged pull request:
@wp-playground/blueprints
will need to be smart about providing a Node.js polyfill fornew DOMParser()
andfetch()
.
Currently, the following browser globals are found in the blueprints
package.
DOMParser
Used in:blueprints/src/lib/steps/install-theme.ts
blueprints/src/lib/steps/install-plugin.ts
FormData
fetch
Possible solution: Prepare a proxy module/package that exports native DOM API for the browser and jsdom for Node.js.
The closest NPM package I found was k0michi/isomorphic-dom
, which uses the exports
property in its package.json
to define browser and server exports.
There's also fetch-shim
which does the same for fetch and undici
; however, this latter module is now in Node.js core as global fetch
since v18 so it's no longer necessary. EDIT: Just learned that global FormData
is also available since Node.js v18. So it's only DOMParser
that needs to be polyfilled on the server side.