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

Bug: third-party compiler, transpiler, swc backend should be resolved relative to tsconfig that declared it, not to the project #1662

Closed
cspotcode opened this issue Feb 24, 2022 · 0 comments · Fixed by #1655
Milestone

Comments

@cspotcode
Copy link
Collaborator

Bug: "compiler", "transpiler", and overridden swc backend resolve relative to the project, not to the tsconfig that declared them. This means an extended, reusable tsconfig that bundles its own dependencies cannot reliably declare these options.

compiler and transpiler

Both are module specifiers in a tsconfig file. We try to resolve them as if the tsconfig was an executable script that had done require.resolve().

overridden swc backend

I doubt anyone's using this config, since I don't think it's documented, but you can technically use our built-in swc transpiler, but with a non-standard @swc/core backend.

{
  // tsconfig.json
  "ts-node": {
    "transpiler": ["ts-node/transpilers/swc", {"swc": "third-party-swc-wrapper"}]
  }
}

This will attempt to require("third-party-swc-wrapper") instead of "@swc/core" or "@swc/wasm". You can also use this mechanism to force usage of "@swc/wasm" instead of "@swc/core", if your module graph has both on disk.

Same rules as above: we simulate if the tsconfig had been able to require.resolve() them.

@cspotcode cspotcode changed the title Bug: third-party @swc should be resolved relative to tsconfig that declared it, not to the project Bug: third-party compiler, transpiler, swc backend should be resolved relative to tsconfig that declared it, not to the project Feb 24, 2022
@cspotcode cspotcode added this to the 10.7.0 milestone Mar 4, 2022
cspotcode added a commit that referenced this issue Mar 5, 2022
cspotcode added a commit that referenced this issue Mar 5, 2022
…ding from `create()`; fix pluggable dep resolution (#1655)

* WIP

* lint-fix

* WIP

* it works!

* Update index.ts

* Move `preferTsExts` from `RegisterOptions` to `CreateOptions`

* fix

* fix

* fix tests

* fix?

* fix

* fix?

* fix?

* fix!

* fix

* fix!!

* fix

* fix...

* tweak test lib's suite delimiter to match ava's

* fix

* fix

* docs, fixes

* fix #1662 and add tests

* lint-fix

* test cleanup, remove or cleanup version checks, skip failing tsconfig "extends" tests on TS 2.7

* ensure tests are forced to install and use most recent ts-node tarball and cannot accidentally use project-root nor outdated tarball

* fix absence of fs method on old node
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this issue Mar 8, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [ts-node](https://typestrong.org/ts-node) ([source](https://github.com/TypeStrong/ts-node)) | devDependencies | minor | [`10.6.0` -> `10.7.0`](https://renovatebot.com/diffs/npm/ts-node/10.6.0/10.7.0) |

---

### Release Notes

<details>
<summary>TypeStrong/ts-node</summary>

### [`v10.7.0`](https://github.com/TypeStrong/ts-node/releases/v10.7.0)

[Compare Source](TypeStrong/ts-node@v10.6.0...v10.7.0)

Questions about this release? Ask in the official discussion thread: [#&#8203;1680](TypeStrong/ts-node#1680)

**Added**

-   Adds `--esm` flag, option, and `ts-node-esm` binary ([#&#8203;1258](TypeStrong/ts-node#1258), [#&#8203;1655](TypeStrong/ts-node#1655))
    -   Enables full `esm` support; no need for `--loader` nor `NODE_OPTIONS`
    -   Use shebang `#!/usr/bin/env ts-node-esm`, run `ts-node --esm`, or add to your tsconfig.json: `"ts-node": {"esm": true}`

**Changed**

-   Unflag ESM json modules on node >=17.5.0 ([#&#8203;1661](TypeStrong/ts-node#1661), [#&#8203;1665](TypeStrong/ts-node#1665)) [@&#8203;Jamesernator](https://github.com/Jamesernator)
    -   no longer requires `--experimental-json-modules`
-   Lazy-load dependencies to improve startup responsiveness. ([#&#8203;1676](TypeStrong/ts-node#1676))

**Fixed**

-   Fixed bug where "compiler", "transpiler", and swc backend would not resolve relative to the tsconfig.json that declared them ([#&#8203;1662](TypeStrong/ts-node#1662), [#&#8203;1655](TypeStrong/ts-node#1655))
    -   Enables reusable tsconfig.json shared via node module to include necessary dependencies

https://github.com/TypeStrong/ts-node/milestone/11

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1200
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant