feat: add support for import.meta.dirname and import.meta.filename#782
Open
hnshah wants to merge 1 commit intoprivatenumber:masterfrom
Open
feat: add support for import.meta.dirname and import.meta.filename#782hnshah wants to merge 1 commit intoprivatenumber:masterfrom
hnshah wants to merge 1 commit intoprivatenumber:masterfrom
Conversation
Fixes privatenumber#781 Adds support for Node.js 20.11+ import.meta.dirname and import.meta.filename properties when transforming .js files to CommonJS format. These properties were already working for .ts and .mjs files (which use ESM format), but were undefined for .js files that tsx converts to CJS. Implementation follows the same pattern as existing import.meta.url support, using esbuild's define option to inject the values during transformation. Reference: unjs/jiti#308
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #781
Adds support for Node.js 20.11+
import.meta.dirnameandimport.meta.filenameproperties.Problem
undefinedfor these propertiesSolution
Follow same pattern as
import.meta.urlusing esbuilddefine.Testing
Reference: unjs/jiti#308