Skip to content

fix(repo): use import type for type-only @nx/devkit imports in copy-a…#35897

Merged
FrozenPandaz merged 3 commits into
masterfrom
fix/freebsd-copy-assets-import-type
Jun 6, 2026
Merged

fix(repo): use import type for type-only @nx/devkit imports in copy-a…#35897
FrozenPandaz merged 3 commits into
masterfrom
fix/freebsd-copy-assets-import-type

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

…ssets plugin

CreateNodesV2 and TargetConfiguration are types but were imported as values. The @nx/workspace-plugin package is type: module, so under Node's native TypeScript stripping (Node >= 22.18) those names are left as runtime imports. @nx/devkit is CommonJS with no such runtime exports, so the plugin fails to load -- surfacing on the FreeBSD publish job as the misleading "imported again after being required. Status = 0" Node error. Marking them import type lets native strip erase them so the plugin loads on any Node.

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #

…ssets plugin

CreateNodesV2 and TargetConfiguration are types but were imported as
values. The @nx/workspace-plugin package is type: module, so under Node's
native TypeScript stripping (Node >= 22.18) those names are left as runtime
imports. @nx/devkit is CommonJS with no such runtime exports, so the plugin
fails to load -- surfacing on the FreeBSD publish job as the misleading
"imported again after being required. Status = 0" Node error. Marking them
import type lets native strip erase them so the plugin loads on any Node.
@FrozenPandaz FrozenPandaz requested a review from a team as a code owner June 5, 2026 22:45
@FrozenPandaz FrozenPandaz requested a review from lourw June 5, 2026 22:45
@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Jun 5, 2026

View your CI Pipeline Execution ↗ for commit 0f42557

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 16m 9s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 43s View ↗
nx build workspace-plugin ✅ Succeeded 3m 29s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 14s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 4s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-06 00:30:15 UTC

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 5, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit bfcd4cb
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a236468e46f780008c4ed39
😎 Deploy Preview https://deploy-preview-35897--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 5, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit bfcd4cb
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a236468d7093200080b667d
😎 Deploy Preview https://deploy-preview-35897--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

…Syntax

@nx/workspace-plugin is type: module, so Nx loads its .ts files through Node's
native type stripping, which can't erase a type imported as a value -- the
plugin then fails to load (surfacing as the misleading "imported again after
being required. Status = 0" on the swc-less FreeBSD publish job).

Align the lib build to ESM (module/moduleResolution: nodenext) and enable
verbatimModuleSyntax so a type-as-value import fails the build instead of only
at runtime, and convert the remaining offenders to import type:
ExecutorContext, ConformanceViolation (x2), and Tree (x2).

This complements the copy-assets-plugin import type fix and prevents the whole
class of bug from regressing across the package.
@FrozenPandaz FrozenPandaz enabled auto-merge (squash) June 6, 2026 00:10
@FrozenPandaz FrozenPandaz merged commit 0011a73 into master Jun 6, 2026
19 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/freebsd-copy-assets-import-type branch June 6, 2026 00:30
vrxj81 pushed a commit to vrxj81/nx that referenced this pull request Jun 7, 2026
nrwl#35897)

…ssets plugin

CreateNodesV2 and TargetConfiguration are types but were imported as
values. The @nx/workspace-plugin package is type: module, so under
Node's native TypeScript stripping (Node >= 22.18) those names are left
as runtime imports. @nx/devkit is CommonJS with no such runtime exports,
so the plugin fails to load -- surfacing on the FreeBSD publish job as
the misleading "imported again after being required. Status = 0" Node
error. Marking them import type lets native strip erase them so the
plugin loads on any Node.

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants