fix(cli): Fix configuration reuse issue in swcDir() by deep clone#95
fix(cli): Fix configuration reuse issue in swcDir() by deep clone#95kdy1 merged 5 commits intoswc-project:mainfrom CodeMan62:fix/config-reuse
Conversation
🦋 Changeset detectedLatest commit: 9fbb393 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The reason for checks not passing is not code as I have check that it's a build error that I was also getting locally when I tried to build here is what error is you can see full in CI check fails too. which we should fix asap I see the related issue too swc-project/swc#89 packages/cli prepublishOnly$ pnpm build
packages/cli prepublishOnly: > @swc/cli@0.7.3 build /Users/runner/work/pkgs/pkgs/packages/cli
packages/cli prepublishOnly: > swc src --strip-leading-paths -d lib --ignore '**/*.test.ts' --ignore '**/__mocks__/**'
packages/cli prepublishOnly: node:internal/modules/cjs/loader:1215
packages/cli prepublishOnly: throw err;
packages/cli prepublishOnly: ^
packages/cli prepublishOnly: Error: Cannot find module '../lib/swc/bin.js'
packages/cli prepublishOnly: Require stack:
packages/cli prepublishOnly: - /Users/runner/work/pkgs/pkgs/packages/cli/bin/swc.js
packages/cli prepublishOnly: at Module._resolveFilename (node:internal/modules/cjs/loader:1212:15)
packages/cli prepublishOnly: at Module._load (node:internal/modules/cjs/loader:1043:27)
packages/cli prepublishOnly: at Module.require (node:internal/modules/cjs/loader:1298:19)
packages/cli prepublishOnly: at require (node:internal/modules/helpers:182:18)
packages/cli prepublishOnly: at Object.<anonymous> (/Users/runner/work/pkgs/pkgs/packages/cli/bin/swc.js:4:1)
packages/cli prepublishOnly: at Module._compile (node:internal/modules/cjs/loader:1529:14)
packages/cli prepublishOnly: at Module._extensions..js (node:internal/modules/cjs/loader:1613:10)
packages/cli prepublishOnly: at Module.load (node:internal/modules/cjs/loader:1275:32)
packages/cli prepublishOnly: at Module._load (node:internal/modules/cjs/loader:[109](https://github.com/swc-project/pkgs/actions/runs/14650662047/job/41115433572?pr=95#step:3:119)6:12)
packages/cli prepublishOnly: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12) {
packages/cli prepublishOnly: code: 'MODULE_NOT_FOUND',
packages/cli prepublishOnly: requireStack: [ '/Users/runner/work/pkgs/pkgs/packages/cli/bin/swc.js' ]
packages/cli prepublishOnly: }
packages/cli prepublishOnly: Node.js v20.19.0
packages/cli prepublishOnly: ELIFECYCLE Command failed with exit code 1.
packages/cli prepublishOnly: Failed
ELIFECYCLE Command failed with exit code 1. |
|
I'll merge this after fixing CI |
I request you to move #10404 issue from swc to this repo |
|
Done 👍 |
| result.map = JSON.stringify(sourceMap); | ||
| } | ||
| return result; | ||
| } catch (err: any) { |
There was a problem hiding this comment.
Can you revert these kinds of changes? It seems like CI is failing because of it
|
give me a bit time i am facing a error while committing my changes the error says commit is empty let me try to solve |
Head branch was pushed to by a user without write access
|
@kdy1 CI passed 😆 good catch |
Issue: The
swcDir()function in the@swcproject was experiencing configuration reuse issues due to shared references in the options object. This led to unintended side effects when compiling different module types (ESM and CommonJS) in the same process.Fix: Implemented a
deepClonefunction to ensure complete isolation of configuration objects. This prevents shared references and ensures that modifications to one configuration do not affect others.Testing:
deepClonefunction. The tests demonstrated that deep cloning maintains object isolation, while shallow cloning does not.related issue link:- #97