← 输入框|github.com|刷新
Skip to content

fix(vite): preserve package imports during vendor bundling - #11565

Merged
NathanWalker merged 2 commits into
NativeScript:mainfrom
aleclarson:fix/vite-package-imports
Oct 22, 2026
Merged

NathanWalker merged 2 commits into
NativeScript:mainfrom
aleclarson:fix/vite-package-imports

Conversation

@aleclarson

Copy link
Copy Markdown
Contributor

PR Checklist

  • The PR title follows the commit guidelines.
  • There is an issue for this bug.
  • You have signed the CLA (not verified here).
  • All existing checks pass (baseline Nx/lint failures below).
  • Tests for the change are included.

What is the current behavior?

Valid package-internal imports such as Octane's #octane/dist/signal-actions/graph become throwing optional-dependency stubs. The plugin probes them with a project-scoped require.resolve; its paths option does not switch the package imports scope to the importer.

What is the new behavior?

Let # specifiers fall through to esbuild to resolve the importer's package.json imports map. Closes #11564.

The regression bundles a fixture through the actual plugin and evaluates it: #internal exports 42, while an absent optional dependency still throws and triggers its try/catch fallback. It fails before the guard change and passes afterward.

Validation: all 1,900 tests pass with cd packages/vite && npx vitest run; changed-file ESLint and formatting pass. npx nx run vite:test has five existing typescript-optional.spec.ts failures; vite:lint has three existing errors in configuration/base.ts and hmr/server/css-device-module.ts. Both failures were reproduced with the original source. No simulator required.

Let esbuild resolve # specifiers in the importing package scope instead of probing them from the app scope and stubbing valid imports.

Closes NativeScript#11564.
@nx-cloud

nx-cloud Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 97a8eff

Command Status Duration Result
nx run-many -t build -p core,webpack5,vite ✅ Succeeded 7s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-10-22 23:31:15 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11565
npm i https://pkg.pr.new/@nativescript/vite@11565
npm i https://pkg.pr.new/@nativescript/webpack@11565

commit: 97a8eff

@NathanWalker
NathanWalker merged commit fb22e10 into NativeScript:main Oct 22, 2026
7 checks passed
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.

vite: package imports are stubbed as missing optional dependencies

2 participants