diff --git a/packages/lexical-clipboard/package.json b/packages/lexical-clipboard/package.json index 8c2e3b73d67..09ff00efbf9 100644 --- a/packages/lexical-clipboard/package.json +++ b/packages/lexical-clipboard/package.json @@ -25,5 +25,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-clipboard" }, - "module": "LexicalClipboard.esm.js" + "module": "LexicalClipboard.esm.js", + "sideEffects": false } diff --git a/packages/lexical-code/package.json b/packages/lexical-code/package.json index 6a3f3a7500e..659527b8857 100644 --- a/packages/lexical-code/package.json +++ b/packages/lexical-code/package.json @@ -25,5 +25,6 @@ "devDependencies": { "@types/prismjs": "^1.26.0" }, - "module": "LexicalCode.esm.js" + "module": "LexicalCode.esm.js", + "sideEffects": false } diff --git a/packages/lexical-dragon/package.json b/packages/lexical-dragon/package.json index ae26e9fa786..8d1b2f6d368 100644 --- a/packages/lexical-dragon/package.json +++ b/packages/lexical-dragon/package.json @@ -19,5 +19,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-dragon" }, - "module": "LexicalDragon.esm.js" + "module": "LexicalDragon.esm.js", + "sideEffects": false } diff --git a/packages/lexical-file/package.json b/packages/lexical-file/package.json index cc062726292..d107cea2f93 100644 --- a/packages/lexical-file/package.json +++ b/packages/lexical-file/package.json @@ -20,5 +20,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-file" }, - "module": "LexicalFile.esm.js" + "module": "LexicalFile.esm.js", + "sideEffects": false } diff --git a/packages/lexical-hashtag/package.json b/packages/lexical-hashtag/package.json index 214cd48f91d..6021e361704 100644 --- a/packages/lexical-hashtag/package.json +++ b/packages/lexical-hashtag/package.json @@ -21,5 +21,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-hashtag" }, - "module": "LexicalHashtag.esm.js" + "module": "LexicalHashtag.esm.js", + "sideEffects": false } diff --git a/packages/lexical-headless/package.json b/packages/lexical-headless/package.json index 4d8c1f4a5f7..f699cdcfabd 100644 --- a/packages/lexical-headless/package.json +++ b/packages/lexical-headless/package.json @@ -18,5 +18,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-headless" }, - "module": "LexicalHeadless.esm.js" + "module": "LexicalHeadless.esm.js", + "sideEffects": false } diff --git a/packages/lexical-history/package.json b/packages/lexical-history/package.json index f5b0a4018ef..fb1170251f1 100644 --- a/packages/lexical-history/package.json +++ b/packages/lexical-history/package.json @@ -21,5 +21,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-history" }, - "module": "LexicalHistory.esm.js" + "module": "LexicalHistory.esm.js", + "sideEffects": false } diff --git a/packages/lexical-html/package.json b/packages/lexical-html/package.json index 6350f67d15c..e7674187758 100644 --- a/packages/lexical-html/package.json +++ b/packages/lexical-html/package.json @@ -22,5 +22,6 @@ "@lexical/selection": "0.13.1", "@lexical/utils": "0.13.1" }, - "module": "LexicalHtml.esm.js" + "module": "LexicalHtml.esm.js", + "sideEffects": false } diff --git a/packages/lexical-link/package.json b/packages/lexical-link/package.json index 86e075b8cf8..d894abe6335 100644 --- a/packages/lexical-link/package.json +++ b/packages/lexical-link/package.json @@ -21,5 +21,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-link" }, - "module": "LexicalLink.esm.js" + "module": "LexicalLink.esm.js", + "sideEffects": false } diff --git a/packages/lexical-list/package.json b/packages/lexical-list/package.json index cb74005bbad..d1c91dfc581 100644 --- a/packages/lexical-list/package.json +++ b/packages/lexical-list/package.json @@ -21,5 +21,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-list" }, - "module": "LexicalList.esm.js" + "module": "LexicalList.esm.js", + "sideEffects": false } diff --git a/packages/lexical-mark/package.json b/packages/lexical-mark/package.json index c0cbede188a..1f48ad04976 100644 --- a/packages/lexical-mark/package.json +++ b/packages/lexical-mark/package.json @@ -21,5 +21,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-mark" }, - "module": "LexicalMark.esm.js" + "module": "LexicalMark.esm.js", + "sideEffects": false } diff --git a/packages/lexical-markdown/package.json b/packages/lexical-markdown/package.json index 36dd83f6971..6ef129348b0 100644 --- a/packages/lexical-markdown/package.json +++ b/packages/lexical-markdown/package.json @@ -26,5 +26,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-markdown" }, - "module": "LexicalMarkdown.esm.js" + "module": "LexicalMarkdown.esm.js", + "sideEffects": false } diff --git a/packages/lexical-offset/package.json b/packages/lexical-offset/package.json index a23df19a604..022a1f03e7e 100644 --- a/packages/lexical-offset/package.json +++ b/packages/lexical-offset/package.json @@ -18,5 +18,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-offset" }, - "module": "LexicalOffset.esm.js" + "module": "LexicalOffset.esm.js", + "sideEffects": false } diff --git a/packages/lexical-overflow/package.json b/packages/lexical-overflow/package.json index 257a522bfe3..2da8c065c0d 100644 --- a/packages/lexical-overflow/package.json +++ b/packages/lexical-overflow/package.json @@ -18,5 +18,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-overflow" }, - "module": "LexicalOverflow.esm.js" + "module": "LexicalOverflow.esm.js", + "sideEffects": false } diff --git a/packages/lexical-plain-text/package.json b/packages/lexical-plain-text/package.json index fdc3354ee0b..e18362ee881 100644 --- a/packages/lexical-plain-text/package.json +++ b/packages/lexical-plain-text/package.json @@ -20,5 +20,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-plain-text" }, - "module": "LexicalPlainText.esm.js" + "module": "LexicalPlainText.esm.js", + "sideEffects": false } diff --git a/packages/lexical-playground/package.json b/packages/lexical-playground/package.json index c9495c8bb8e..e23e756c3dd 100644 --- a/packages/lexical-playground/package.json +++ b/packages/lexical-playground/package.json @@ -41,5 +41,6 @@ "rollup-plugin-copy": "^3.5.0", "vite": "^2.9.16", "vite-plugin-replace": "0.1.1" - } + }, + "sideEffects": false } diff --git a/packages/lexical-react/package.json b/packages/lexical-react/package.json index f39f851abc0..c68570e7418 100644 --- a/packages/lexical-react/package.json +++ b/packages/lexical-react/package.json @@ -600,5 +600,6 @@ }, "require": "./useLexicalTextEntity.js" } - } + }, + "sideEffects": false } diff --git a/packages/lexical-rich-text/package.json b/packages/lexical-rich-text/package.json index a15ce071ace..4af03c75020 100644 --- a/packages/lexical-rich-text/package.json +++ b/packages/lexical-rich-text/package.json @@ -20,5 +20,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-rich-text" }, - "module": "LexicalRichText.esm.js" + "module": "LexicalRichText.esm.js", + "sideEffects": false } diff --git a/packages/lexical-selection/package.json b/packages/lexical-selection/package.json index 6dc65a2fbf0..2974dc8a604 100644 --- a/packages/lexical-selection/package.json +++ b/packages/lexical-selection/package.json @@ -19,5 +19,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-selection" }, - "module": "LexicalSelection.esm.js" + "module": "LexicalSelection.esm.js", + "sideEffects": false } diff --git a/packages/lexical-table/package.json b/packages/lexical-table/package.json index 158de55f494..7fad1867dcb 100644 --- a/packages/lexical-table/package.json +++ b/packages/lexical-table/package.json @@ -21,5 +21,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-table" }, - "module": "LexicalTable.esm.js" + "module": "LexicalTable.esm.js", + "sideEffects": false } diff --git a/packages/lexical-text/package.json b/packages/lexical-text/package.json index 7cf3e71f3a6..f9797d5cb0c 100644 --- a/packages/lexical-text/package.json +++ b/packages/lexical-text/package.json @@ -19,5 +19,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-text" }, - "module": "LexicalText.esm.js" + "module": "LexicalText.esm.js", + "sideEffects": false } diff --git a/packages/lexical-utils/package.json b/packages/lexical-utils/package.json index e70a5b42075..9e2e2729c57 100644 --- a/packages/lexical-utils/package.json +++ b/packages/lexical-utils/package.json @@ -23,5 +23,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-utils" }, - "module": "LexicalUtils.esm.js" + "module": "LexicalUtils.esm.js", + "sideEffects": false } diff --git a/packages/lexical-yjs/package.json b/packages/lexical-yjs/package.json index 0f663e5475f..8d1eab9540f 100644 --- a/packages/lexical-yjs/package.json +++ b/packages/lexical-yjs/package.json @@ -25,5 +25,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical-yjs" }, - "module": "LexicalYjs.esm.js" + "module": "LexicalYjs.esm.js", + "sideEffects": false } diff --git a/packages/lexical/package.json b/packages/lexical/package.json index a6ea3291d11..9d8c2a0e6ab 100644 --- a/packages/lexical/package.json +++ b/packages/lexical/package.json @@ -16,5 +16,6 @@ "url": "https://github.com/facebook/lexical", "directory": "packages/lexical" }, - "module": "Lexical.esm.js" + "module": "Lexical.esm.js", + "sideEffects": false } diff --git a/packages/shared/package.json b/packages/shared/package.json index 7598e110829..e1fa00ff207 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -16,5 +16,6 @@ "type": "git", "url": "https://github.com/facebook/lexical", "directory": "packages/shared" - } + }, + "sideEffects": false } diff --git a/scripts/build.js b/scripts/build.js index 53aaba52b75..c8ac2c8b426 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -619,7 +619,9 @@ function buildForkModule(outputPath, outputFileName, format, exports) { const prodFileName = `./${outputFileName}.prod${extension}`; if (format === 'esm') { lines.push( - `const mod = process.env.NODE_ENV === 'development' ? await import('${devFileName}') : await import('${prodFileName}');`, + `import * as modDev from '${devFileName}';`, + `import * as modProd from '${prodFileName}';`, + `const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;`, ); for (const name of exports) { lines.push( diff --git a/scripts/updateVersion.js b/scripts/updateVersion.js index eafcb149a09..c50d91682c6 100644 --- a/scripts/updateVersion.js +++ b/scripts/updateVersion.js @@ -59,6 +59,9 @@ function withEsmExtension(fileName) { } function updateModule(packageJSON, pkg) { + if (packageJSON.sideEffects === undefined) { + packageJSON.sideEffects = false; + } if (packageJSON.main) { packageJSON.module = withEsmExtension(packageJSON.main); } else if (fs.existsSync(`./packages/${pkg}/dist`)) {