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

jsc.paths regression in 1.3.79 with symlinks #8667

Closed
jbedard opened this issue Feb 27, 2024 · 1 comment · Fixed by #8757
Closed

jsc.paths regression in 1.3.79 with symlinks #8667

jbedard opened this issue Feb 27, 2024 · 1 comment · Fixed by #8757
Assignees
Labels
Milestone

Comments

@jbedard
Copy link

jbedard commented Feb 27, 2024

Describe the bug

This issue still exists with a more accurate bazel use case: #8265. See the latest change to reproduce it.

See jbedard@08db617 for a new test that should reproduce it, but I haven't finished the rust setup to actually compile+run this test yet.

Input code

import { moduleA } from "@modules/moduleA";

moduleA();

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript"
    },
    "target": "es2021",
    "baseUrl": "./src",
    "paths": {
      "@modules/*": [
        "./modules/*"
      ]
    }
  },
  "module": {
    "type": "commonjs"
  },
  "sourceMaps": true
}

Playground link (or link to the minimal reproduction)

https://github.com/alexeagle/swc_8265_repro/

SWC Info output

swc-darwin-arm64 --version
SWC 0.91.64

Expected behavior

SWC 1.3.78 produces

const _moduleA = require("./modules/moduleA/index");

In #8258 you suggested that we compare with what tsc produces. As I understand it, typescript never attempts to re-write import/require statements. So the result is here

https://github.com/aspect-build/rules_swc/pull/216/files#diff-e3a9eafb3b943b9863d6cea0b348d4ef40bc1b7bb5867a38ac889fcacea0cbf4R3

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var moduleA_1 = require("@modules/moduleA");
(0, moduleA_1.moduleA)();

Actual behavior

SWC 1.3.79 - 1.4.3+ produces:

const _moduleA = require("../../../../../../../shared/cache/bazel/user_base/09a27d1eeea3b44d1580773090924b4d/sandbox/linux-sandbox/629/execroot/aspect_rules_swc/examples/paths/src/modules/moduleA");

Version

1.3.79

Additional context

See #8265

7dfdc12 fixed the original example in the original repo.

However another example that is closer aligned with what actually occurs in bazel reproduces the issue, essentially just another layer of symlinks: alexeagle/swc_8265_repro@16bfa92

@jbedard jbedard added the C-bug label Feb 27, 2024
@kdy1 kdy1 self-assigned this Feb 27, 2024
@kdy1 kdy1 added this to the Planned milestone Feb 27, 2024
kdy1 added a commit that referenced this issue Mar 18, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.4.11 Mar 27, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Apr 26, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants