Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Create a local bundler to run in development mode #1662

@jgutman

Description

@jgutman

This issue is motivated by the following:

We are currently blocked on the upgrade to V5 of React Query.
V5 removed the umd directory from the builds, and converted the module type from common JS module to ES module. This isn't a problem for production mode where we use a bundler, but in development mode, we don't have a bundler and so we have some hacks for reading in the local source files created when we build. We can't do this with react query v5, and if any other tanstack libraries do a similar change, we won't be able to upgrade them either.

I think we will ultimately have to solve this by having a bundler run in watch mode for development purposes

Originally posted by @jgutman in #1659 (comment)

This is also seems to be blocking the upgrade to React 18. In v18 of React DOM, some of the critical functionality has moved into react-dom/client, in particular this piece here. To upgrade, we would need to import like this: import * as ReactDOMClient from 'react-dom/client';
However, if we are using our substitute for a bundler and just adding react-dom/umd/react-dom.development.js to the source code, then development mode is not able to find the source code 'react-dom/client' and we get a reference error for ReactDOMClient

This seems like possibly the same issue that prompted this patch in the main application when in development mode:

positron/src/vs/loader.js

Lines 1601 to 1634 in 1f7e74c

// Fixup for loading react-dom/client.js.
if (paths[0].includes('react-dom.production.min.js/client.js')) {
// Save the original path to the react-dom/client.js file.
const reactDomClientOriginalPath = paths[0];
// Release builds load from node_modules.asar.
if (paths[0].includes('/node_modules.asar/')) {
paths[0] = paths[0].replace("/../node_modules.asar/react-dom/umd/react-dom.production.min.js/client.js", "/react-dom/client.js");
} else {
// The set of original paths adjust.
const reactDomClientElectron = '/out/../node_modules/react-dom/umd/react-dom.production.min.js/client.js';
const reactDomClientWeb = 'remote/web/node_modules/react-dom/umd/react-dom.production.min.js/client.js';
// Attempt to adjust the original path.
if (paths[0].endsWith(reactDomClientElectron)) {
paths[0] = `${paths[0].substr(0, paths[0].length - reactDomClientElectron.length)}/out/react-dom/client.js`;
} else if (paths[0].endsWith(reactDomClientWeb)) {
paths[0] = `${paths[0].substr(0, paths[0].length - reactDomClientWeb.length)}out/react-dom/client.js`;
}
}
// Log what happened with loading react-dom/client.js.
console.log('------------------------------------------------------------------------');
if (paths[0] !== reactDomClientOriginalPath) {
console.log(`Changing where the react-dom client.js file is loaded from.`);
console.log(`Original path: ${reactDomClientOriginalPath}`);
console.log(`Adjusted path: ${paths[0]}`);
} else {
console.log('ERROR: Unable to change where the react-dom client.js file is loaded from.')
console.log(`Original path: ${reactDomClientOriginalPath}`);
}
console.log('------------------------------------------------------------------------');
}
// --- End Positron ---

but unfortunately we can't just switch to adding react-dom/client.js from the extension's node_modules folder instead, that breaks as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: data explorerIssues related to Data Explorer category.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions