MCPcopy Create free account
hub / github.com/decaporg/decap-cms / reactDomServerAlias

Function reactDomServerAlias

scripts/webpack.js:106–130  ·  view source on GitHub ↗

* `react-dom/server` in the browser bundles both the streaming and the legacy * renderer, but Decap (shortcode previews) and Plate only call * `renderToString`/`renderToStaticMarkup`, which live in the legacy one. * Point the import straight at that file to drop the unused renderer.

()

Source from the content-addressed store, hash-verified

104 * Point the import straight at that file to drop the unused renderer.
105 */
106function reactDomServerAlias() {
107 let reactDomDir;
108 try {
109 reactDomDir = path.dirname(
110 require.resolve('react-dom/package.json', { paths: [process.cwd()] }),
111 );
112 } catch {
113 return {};
114 }
115 const build = isProduction ? 'production' : 'development';
116 // React 19 names the production file `.production.js`, React 18
117 // `.production.min.js`.
118 const legacyServer = [
119 `cjs/react-dom-server-legacy.browser.${build}.js`,
120 `cjs/react-dom-server-legacy.browser.${build}.min.js`,
121 ]
122 .map(file => path.join(reactDomDir, file))
123 .find(file => fs.existsSync(file));
124 if (!legacyServer) {
125 return {};
126 }
127 return {
128 'react-dom/server$': legacyServer,
129 };
130}
131
132const umdPath = path.resolve(process.cwd(), 'dist');
133const umdDirPath = path.resolve(process.cwd(), 'dist/umd');

Callers 1

baseConfigFunction · 0.85

Calls 3

resolveMethod · 0.80
findMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected