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

fix(register): respect SWCRC environment variable when running in async mode #715

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

bgdavidx
Copy link
Contributor

The current @swc-node/register/esm loader does not respect the SWCRC environment variable. This is due to the condition for setting swcRegisterConfig only applying to the sync transform version.

This PR fixes that, and also fixes module being overridden by "commonjs" when SWCRC environment variable is specified, which causes files being transformed by register/esm to be loaded as CommonJS which causes errors such as these:

server  | file:///app/apps/backend/src/app.ts:2
server  | Object.defineProperty(exports, "__esModule", {
server  |                       ^
server  |
server  | ReferenceError: exports is not defined in ES module scope
server  |     at file:///app/apps/backend/src/app.ts.mjs:2:23
server  |     at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
server  |

@CLAassistant
Copy link

CLAassistant commented Jun 28, 2023

CLA assistant check
All committers have signed the CLA.

@Brooooooklyn Brooooooklyn merged commit c6aa3f9 into swc-project:master Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants