Use production builds of react libraries (#4482)

And remove patching that doesn't seem to be required anymore
This commit is contained in:
Tom Najdek 2024-08-02 09:43:02 +02:00 committed by GitHub
parent 11a5853657
commit 144f2caed8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 9 additions and 26 deletions

View file

@ -9,8 +9,6 @@
"chrome/content/zotero/xpcom/citeproc.js",
"chrome/content/ace/*",
"chrome/content/scaffold/templates/*",
"resource/react.js",
"resource/react-dom.js",
"resource/react-virtualized.js",
"test/resource/*.js"
],

View file

@ -30,19 +30,8 @@ async function babelWorker(ev) {
try {
let contents = await fs.readFile(sourcefile, 'utf8');
// Patch react
if (comparePaths(sourcefile, 'resource/react.js')) {
transformed = contents.replace('instanceof Error', '.constructor.name == "Error"')
}
// Patch react-dom
else if (comparePaths(sourcefile, 'resource/react-dom.js')) {
transformed = contents.replace(/ ownerDocument\.createElement\((.*?)\)/gi, 'ownerDocument.createElementNS(HTML_NAMESPACE, $1)')
.replace('element instanceof win.HTMLIFrameElement',
'typeof element != "undefined" && element.tagName.toLowerCase() == "iframe"')
.replace("isInputEventSupported = false", 'isInputEventSupported = true');
}
// Patch react-virtualized
else if (comparePaths(sourcefile, 'resource/react-virtualized.js')) {
if (comparePaths(sourcefile, 'resource/react-virtualized.js')) {
transformed = contents.replace('scrollDiv = document.createElement("div")', 'scrollDiv = document.createElementNS("http://www.w3.org/1999/xhtml", "div")')
.replace('document.body.appendChild(scrollDiv)', 'document.documentElement.appendChild(scrollDiv)')
.replace('document.body.removeChild(scrollDiv)', 'document.documentElement.removeChild(scrollDiv)');

View file

@ -26,14 +26,12 @@ const copyDirs = [
// list of files from root folder to symlink
const symlinkFiles = [
'chrome.manifest',
// React needs to be patched by babel-worker.js, so symlink all files in resource/ except for
// those. Babel transpilation for React is still disabled in .babelrc.
// react-virtualized needs to be patched by babel-worker.js, so symlink all files in resource/ except for
// those. Babel transpilation is still disabled in .babelrc.
'resource/**/*',
'!resource/react.js',
'!resource/react-dom.js',
'!resource/react-virtualized.js',
// Only include dist directory of singleFile
// Also do a little bit of manipulation similar to React
// Also do a little bit of manipulation similar to react-virtualized
'!resource/SingleFile/**/*',
'resource/SingleFile/lib/**/*',
'!resource/SingleFile/lib/single-file.js',
@ -116,9 +114,7 @@ const jsFiles = [
`{${dirs.join(',')}}/**/*.jsx`,
`!{${symlinkDirs.concat(copyDirs).join(',')}}/**/*.js`,
`!{${symlinkDirs.concat(copyDirs).join(',')}}/**/*.jsx`,
// Special handling for React -- see note above
'resource/react.js',
'resource/react-dom.js',
// Special handling for react-virtualized and others -- see note above
'resource/react-virtualized.js',
'resource/SingleFile/lib/single-file.js',
'resource/citeproc_rs_wasm.js',

View file

@ -1 +1 @@
../node_modules/react-dom/umd/react-dom-server.browser.development.js
../node_modules/react-dom/umd/react-dom-server.browser.production.min.js

View file

@ -1 +1 @@
../node_modules/react-dom/umd/react-dom.development.js
../node_modules/react-dom/umd/react-dom.production.min.js

View file

@ -1 +1 @@
../node_modules/react-intl/dist/react-intl.js
../node_modules/react-intl/dist/react-intl.min.js

2
resource/react.js vendored
View file

@ -1 +1 @@
../node_modules/react/umd/react.development.js
../node_modules/react/umd/react.production.min.js