Skip to content

[upstream] MT worklet loader drops non-relative imports — patched locally, awaiting vue-lynx#190 #58

Description

@KealanAU

Summary

vue-lynx's main-thread worklet loader (extractLocalImports in plugin/dist/loaders/worklet-loader-mt.js) only re-emits relative import specifiers into the MT module graph. Any non-relative specifier is silently dropped, so the worklet's registerWorkletInternal(...) is never written to the MT bundle and the first interaction throws TypeError: cannot read property 'bind' of undefined.

Full write-up: docs/upstream/vue-lynx-mt-worklet-import-issue.md.

Two affected surfaces

  1. Aliases (@/…), intra-package — e.g. SwiperRoot.vue importing @/shared/gesture/useDragGesture inside @vyui/core.
  2. Bare specifiers (@vyui/core), cross-package — the demo apps consuming @vyui/core's MT worklets. (Was tracked as Shared gesture/animation worklets ARE viable — blocker is @vyui/core worklet packaging (local loader) #37.)

Current state — patched locally, works

  • Surface 1 is fixed by patches/vue-lynx@0.4.0.patch (pnpm patchedDependencies in pnpm-workspace.yaml): broadens the loader regex to also follow @/…. Carries a [REMOVE WHEN UPSTREAM FIXED] banner. Verified — MT bundle audit reports UNRESOLVED: 0 (7 unresolved without it).
  • Surface 2 is worked around by the side-effect import '../../../../packages/core/src' in each demo's index.ts (drags core's worklets into the MT graph via a relative path).

Both are stopgaps.

Proper upstream fix — vue-lynx#190

Huxpro/vue-lynx#190 fixes both:

  • Converts the loader to async and resolves non-relative specifiers via the bundler resolver (this.getResolve()), re-emitting project-source imports with their original specifiers → replaces our regex patch (surface 1).
  • Adds opt-in includeWorkletPackages to follow imports into named node_modules packages that ship MT worklets → replaces the side-effect import (surface 2), via includeWorkletPackages: ['@vyui/core'].

Status: open, ready for review. Not yet released, so we keep the stopgaps until it lands.

Cleanup when #190 ships in a vue-lynx release

  • Delete patches/vue-lynx@0.4.0.patch + its patchedDependencies entry in pnpm-workspace.yaml.
  • Drop the import '../../../../packages/core/src' side-effect from each demo index.ts; add includeWorkletPackages: ['@vyui/core'] to the loader config.
  • pnpm install, rebuild, re-run the MT-bundle audit (expect UNRESOLVED: 0), device-verify drag/gesture.

Supersedes #37. Item 1 of the #50 umbrella points here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstream-blockedBlocked by vue-lynx / Lynx / Tailwind upstream

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions