You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
merged 10 commits into
jly36963:fix-broken-esm-json-importNov 14, 2021
This file contains 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
This may break in general in environments without native import.meta which unfortunately includes code targeting CJS and also the closure compiler toolchain. We use a different index.ts inside of Google (because some of the dynamic expression in the current one already prevent optimization), so it will not actually break us in this case though.
Anyhow, drive-by comment on the PR: I'm not sure if you want the require to be relative to import.meta.url because that's relative to the yaqs-parser file somewhere in node_modules or relative to whatever ESM bundle it is in (which may not be the same as the bundle defining the config path). Since this is node only, maybe the correct value is actually createRequire('file:///') ("the file system root") or createRequire(pathToURL(join(process.cwd(), "_yargs-parser")))?
P.S.: If you're using createRequire (which I think is great and better than using the contextual require of the file!), maybe you could even do it consistently / independent of ESM or not? The non-import.meta.url variant I mentioned above would work equally well in ESM and CJS and could replace the current implementation in general.
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.