Skip to content

Conversation

@nojaf
Copy link
Member

@nojaf nojaf commented Nov 17, 2025

Problem

The extension fails to activate in the published version (v1.67.1) with the error:

TypeError: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received undefined
at createRequire (node:internal/modules/cjs/loader:1919:11)

This was introduced in commit e371ab2 which added oxc-parser and oxc-walker dependencies for the paste-as-JSX feature.

Root Cause

oxc-parser is a native module with platform-specific bindings that uses createRequire(__filename) internally to load the correct binding for the current platform. When esbuild bundles these modules, __filename and __dirname become undefined, causing createRequire to fail.

Solution

Externalize oxc-parser in the esbuild bundle configuration so it is loaded as external dependencies at runtime instead of being bundled. This allows them to correctly resolve __filename/__dirname and load their native bindings.

Copy link
Member

@tsnobip tsnobip left a comment

Choose a reason for hiding this comment

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

nice catch!

@nojaf nojaf merged commit 82c0d49 into rescript-lang:master Nov 17, 2025
6 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.

2 participants