Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old version of clone-deep causes rollup/vite build errors #22

Open
leifdalan opened this issue Oct 14, 2024 · 0 comments
Open

Old version of clone-deep causes rollup/vite build errors #22

leifdalan opened this issue Oct 14, 2024 · 0 comments

Comments

@leifdalan
Copy link

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch clone-deep@0.2.4 for the project I'm working on.

When bundling using rollup, I get the following error:

5.388 βœ“ 2163 modules transformed.
5.390 x Build failed in 4.01s
5.392 node_modules/clone-deep/utils.js (10:0): Illegal reassignment of import "commonjsRequire" in "node_modules/clone-deep/utils.js".
5.392 file: /webapp/node_modules/clone-deep/utils.js:10:0
5.392 
5.392  8: var fn = require;
5.392  9: 
5.392 10: require = utils;
5.392     ^
5.392 11: require('is-plain-object', 'isObject');
5.392 12: require('shallow-clone', 'clone');
5.392 
5.392     at getRollupError (file:///webapp/node_modules/rollup/dist/es/shared/parseAst.js:395:41)
5.392     at error (file:///webapp/node_modules/rollup/dist/es/shared/parseAst.js:391:42)
5.392     at Module.error (file:///webapp/node_modules/rollup/dist/es/shared/node-entry.js:15535:16)
5.392     at Identifier.disallowImportReassignment (file:///webapp/node_modules/rollup/dist/es/shared/node-entry.js:4991:35)
5.392     at Identifier.deoptimizePath (file:///webapp/node_modules/rollup/dist/es/shared/node-entry.js:4888:18)
5.392     at AssignmentExpression.applyDeoptimizations (file:///webapp/node_modules/rollup/dist/es/shared/node-entry.js:10958:19)
5.392     at AssignmentExpression.hasEffects (file:///webapp/node_modules/rollup/dist/es/shared/node-entry.js:10877:18)
5.392     at ExpressionStatement.hasEffects (file:///webapp/node_modules/rollup/dist/es/shared/node-entry.js:2879:28)
5.392     at Program.hasEffects (file:///webapp/node_modules/rollup/dist/es/shared/node-entry.js:13256:22)
5.392     at Program.shouldBeIncluded (file:///webapp/node_modules/rollup/dist/es/shared/node-entry.js:2979:62) {
5.392   code: 'ILLEGAL_REASSIGNMENT',
5.392   id: '/webapp/node_modules/clone-deep/utils.js',
5.392   pos: 425,
5.392   loc: {
5.392     column: 0,
5.392     file: '/webapp/node_modules/clone-deep/utils.js',
5.392     line: 10
5.392   },
5.392   frame: ' 8: var fn = require;\n' +
5.392     ' 9: \n' +
5.392     '10: require = utils;\n' +
5.392     '    ^\n' +
5.392     "11: require('is-plain-object', 'isObject');\n" +
5.392     "12: require('shallow-clone', 'clone');",

Here is the diff that solved my problem:

diff --git a/node_modules/clone-deep/utils.js b/node_modules/clone-deep/utils.js
index d2a7570..0315a18 100644
--- a/node_modules/clone-deep/utils.js
+++ b/node_modules/clone-deep/utils.js
@@ -5,14 +5,12 @@
  */
 
 var utils = require('lazy-cache')(require);
-var fn = require;
 
-require = utils;
-require('is-plain-object', 'isObject');
-require('shallow-clone', 'clone');
-require('kind-of', 'typeOf');
-require('for-own');
-require = fn;
+const _require = utils;
+_require('is-plain-object', 'isObject');
+_require('shallow-clone', 'clone');
+_require('kind-of', 'typeOf');
+_require('for-own');
 
 /**
  * Expose `utils`

Updating the clone-deep to the latest version would fix this issue without having to patch it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant