Skip to content

Commit

Permalink
fix: scheduler not find
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Dec 18, 2024
1 parent 87c1b1e commit 209dc52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions scripts/download-react.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const pluginTitle = `${author}/${name}`;

// fix ReferenceError: process is not defined
const fixProcessUndefined = (code) => code.replace('process.env.NODE_ENV', '"development"');
// prevent collision of name, use a different name. See `src/react-scheduler.js.meta`.
const fixSchedulerNameCollision = (code) => code.replace('require("scheduler")', 'require("react-scheduler.js")');

const version = '19';
const reactPath = `node_modules/react/cjs`;
Expand All @@ -18,8 +20,8 @@ const [reactDev, react, reactDomDev, reactDom, reactDomClientDev, reactClientDom
fs.readFile(path.join(reactPath, `react.production.js`), 'utf-8'),
fs.readFile(path.join(reactDomPath, `react-dom.development.js`), 'utf-8').then(fixProcessUndefined),
fs.readFile(path.join(reactDomPath, `react-dom.production.js`), 'utf-8'),
fs.readFile(path.join(reactDomPath, `react-dom-client.development.js`), 'utf-8').then(fixProcessUndefined),
fs.readFile(path.join(reactDomPath, `react-dom-client.production.js`), 'utf-8'),
fs.readFile(path.join(reactDomPath, `react-dom-client.development.js`), 'utf-8').then(fixProcessUndefined).then(fixSchedulerNameCollision),
fs.readFile(path.join(reactDomPath, `react-dom-client.production.js`), 'utf-8').then(fixSchedulerNameCollision),
fs.readFile(path.join(reactPath, `react-jsx-runtime.development.js`), 'utf-8').then(fixProcessUndefined),
fs.readFile(path.join(reactPath, `react-jsx-runtime.production.js`), 'utf-8'),
fs.readFile(path.join(schedulerPath, `scheduler.development.js`), 'utf-8').then(fixProcessUndefined),
Expand All @@ -38,6 +40,6 @@ await Promise.all([
fs.writeFile(path.join(pluginPath, 'react-dom-client.js'), reactClientDom),
fs.writeFile(path.join(devPluginPath, 'react-jsx-runtime.js'), reactJsxRuntimeDev),
fs.writeFile(path.join(pluginPath, 'react-jsx-runtime.js'), reactJsxRuntime),
fs.writeFile(path.join(devPluginPath, 'scheduler.js'), schedulerDev),
fs.writeFile(path.join(pluginPath, 'scheduler.js'), scheduler),
fs.writeFile(path.join(devPluginPath, 'react-scheduler.js'), schedulerDev),
fs.writeFile(path.join(pluginPath, 'react-scheduler.js'), scheduler),
]);
2 changes: 1 addition & 1 deletion src/scheduler.js.meta → src/react-scheduler.js.meta
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
title: scheduler
title: react-scheduler.js
type: application/javascript
module-type: library

0 comments on commit 209dc52

Please sign in to comment.