Skip to content

vite: package imports are stubbed as missing optional dependencies #11564

Closed

Description

@aleclarson

@nativescript/vite 8.0.17 with Octane 0.10.2 fails during iOS dev boot with Cannot find module '#octane/dist/signal-actions/graph' (also #octane/dist/signal-actions/bindings), despite valid package.json imports-map entries. The same guard is present on current main (1fe745085).

createOptionalDependencyStubEsbuildPlugin treats # specifiers as bare dependencies and probes them with a project-scoped createRequire(...).resolve(id, { paths: [dirname(importer)] }). The paths option does not change the package imports scope, so valid dependency-internal imports fail the probe and become throwing ns-optional-dep-stub modules.

Minimal reproduction: create node_modules/fixture/package.json with imports: { "#internal": "./internal.js" }, export value = 42 from internal.js, and import it from the fixture entry. Bundle through the actual optional-dependency plugin with esbuild and evaluate the output: it throws Cannot find module '#internal'.

Letting # specifiers fall through to esbuild resolves them using the importer's package scope. A regression test can also verify a genuinely absent optional dependency still throws inside try/catch and preserves the fallback. No simulator is needed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions