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

feat(js): infer tslib as a dependency when using importHelpers #9350

Conversation

gioragutt
Copy link
Contributor

@gioragutt gioragutt commented Mar 16, 2022

Current Behavior

When using "importHelpers": true and building with tsc, the built bundle expects to be supplied the tslib package.

Currently, it's up to developers to add tslib as a dependency to those libraries' package.json files.

Expected Behavior

This PR makes the tsc executor infer that importHelpers is used,
and subsequently, add tslib as a dependency to the generated package.json.

Related Issue(s)

Fixes #9343

@nx-cloud
Copy link

nx-cloud bot commented Mar 16, 2022

☁️ Nx Cloud Report

CI ran the following commands for commit f31486e. 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 Mar 16, 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/67zAs7EopJcbjXnbdWMcKYHPygaR
✅ Preview: Canceled

[Deployment for f31486e canceled]

@gioragutt
Copy link
Contributor Author

@AgentEnder any reason CI is not running on this PR?

@AgentEnder
Copy link
Member

First contribution right? For some reason, Circle seems to not be kicking off for first-time contributors. One of us will need to rebase your branch.

Copy link
Member

@AgentEnder AgentEnder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, going to get another opinion. Left a few small changes.

packages/js/src/utils/tslib-dependency.ts Outdated Show resolved Hide resolved
packages/workspace/src/utilities/typescript.ts Outdated Show resolved Hide resolved
@@ -60,6 +61,8 @@ export async function* tscExecutor(
options.tsConfig = tmpTsConfig;
}

addTslibDependencyIfNeeded(options, context, dependencies);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AgentEnder does this seem like the right approach? Perhaps there's a way to make it so that tslib will be part of the dependencies in the first place, by altering the graph somehow?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine for the time being, eventually a lot of the js specific logic should be pulled out to use processProjectGraph like a community plugin would, to truly separate the core and at that point then some of this may make more sense there. Since this is specific to the tsc executor (and not wanted for the swc executor), I think this makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I figured there's something missing to do what I had in mind. Thanks for the feedback 👍🏻 I'll push a fix momentarily

Copy link
Member

@AgentEnder AgentEnder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@gioragutt gioragutt changed the title feat(js): infer tslib as dependency when using importHelpers feat(js): infer tslib as a dependency when using importHelpers Mar 16, 2022
When using "importHelpers" and building with "tsc", the built bundle expects to be supplied the
"tslib" package.

Currently, it's up to developers to add "tslib" as a dependency to those
libraries' package.json files.

This PR makes the "tsc" execute infer that "importHelpers" is used,
and subsequently add "tslib" as a dependency to the generated package.json

ISSUES CLOSED: nrwl#9343
@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 19, 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.

Include tslib as a dependency in buildable packages when importHelpers is true
2 participants