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(js): adjust destination directory for swc executor #9072

Merged
merged 5 commits into from Feb 23, 2022
Merged

Conversation

nartc
Copy link
Contributor

@nartc nartc commented Feb 22, 2022

Current Behavior

Currently, we use cwd with exec() to execute swc in the project's root directory (eg: packages/lib-one)

swc is executed with:

  • srcPath: ../lib-one
  • destPath: ../../dist/packages/lib-one/src

This results in faulty behavior for libs with nested libs as well as libs with source code outside of src directory.

For example (taken from https://github.com/nartc/mapper)

.
└── packages
    └── classes (lib)
        ├── experimental (dir)
        │   └── transformer-plugin (lib)
        │       └── src
        │           ├── lib
        │           │   └── ...
        │           └── index.ts
        ├── mapped-types (lib)
        │   └── src
        │       ├── lib
        │       │   └── ...
        │       └── index.ts
        ├── extra (dir)
        │   └── shim.ts (main lib code, should be included)
        └── src (main lib)
            ├── lib
            │   └── ...
            └── index.ts

With the above setup, @automapepr/classes/mapped-types and @automapepr/classes/experimental/transformer-plugin are "secondary entry points" to @automapepr/classes. In addition, they have their own build target. A complete build of classes is:

npx nx run-many --target=build --projects=classes,classes-mapped-types,classes-experimental-transformer-plugin

With nrwl/js:tsc, the following artifact is produced:

.
└── dist
    └── packages
        └── classes
            ├── experimental
            │   └── transformer-plugin
            │       ├── src
            │       │   ├── lib
            │       │   │   └── ...
            │       │   ├── index.js
            │       │   └── index.d.ts
            │       └── package.json
            ├── mapped-types
            │   ├── src
            │   │   ├── lib
            │   │   │   └── ...
            │   │   ├── index.js
            │   │   └── index.d.ts
            │   └── package.json
            ├── extra
            │   └── shim.js
            ├── src
            │   ├── lib
            │   │   └── ...
            │   ├── index.d.ts
            │   └── index.js
            └── package.json

With nrwl/js:swc, the following is produced:

.
└── dist
    └── packages
        └── classes
            ├── experimental
            │   └── transformer-plugin (here bacause of nx build classes-experimental-transformer-plugin)
            │       └── src
            │           ├── lib
            │           │   └── ...
            │           ├── index.js
            │           └── index.d.ts
            ├── mapped-types (here because of nx build classes-mapped-types)
            │   └── src
            │       ├── lib
            │       │   └── ...
            │       ├── index.js
            │       └── index.d.ts
            └── src
                ├── lib
                │   └── ...
                ├── transformer-plugin (top-level experimental is gone)
                │   └── src
                │       ├── lib
                │       │   └── ...
                │       └── index.js
                ├── src (this is mapped-types, but top-level mapped-types dir is gone)
                │   ├── lib
                │   │   └── ...
                │   └── index.js
                ├── index.js
                ├── index.d.ts
                └── shim.js (no top-level extra dir)

Expected Behavior

  • nrwl/js:swc produces artifacts similarly to nrwl/js:tsc. Files are moved correctly into dist
  • swc version is bumped to latest
  • jest-setup is added to default exclude

Related Issue(s)

Fixes #

@nx-cloud
Copy link

nx-cloud bot commented Feb 22, 2022

☁️ Nx Cloud Report

CI ran the following commands for commit 0aad7a1. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 7 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented Feb 22, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nrwl/nx-dev/B7u29tnA6EFttyPpVAhWt7LPTxam
✅ Preview: https://nx-dev-git-swc-fix-nrwl.vercel.app

[Deployment for 0aad7a1 canceled]

@nartc nartc merged commit 5527724 into master Feb 23, 2022
meeroslav pushed a commit to meeroslav/nx that referenced this pull request Mar 4, 2022
* fix(js): bump swc deps versions

* fix(js): change swc cli arguments to ensure it works in parity with tsc

* fix(js): add "dts" flag to swc executor

* fix(js): remove dts option as diff in perf is negligible

* fix(js): change logic around swc cli so that outputPath isn't computed

Co-authored-by: Chau Tran <ctran@Chaus-MacBook-Pro.local>
@FrozenPandaz FrozenPandaz deleted the swc-fix branch June 7, 2022 23:31
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants