Skip to content

Commit

Permalink
chore: lazy compute isMain
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Dec 2, 2021
1 parent 2c42f36 commit 26a33db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/yarnpkg-pnp/sources/esm-loader/built-loader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/yarnpkg-pnp/sources/esm-loader/loaderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function tryParseURL(str: string) {

export function getFileFormat(filepath: string): string | null {
const ext = path.extname(filepath);
const isMain = process.argv[1] === filepath;

switch (ext) {
case `.mjs`: {
Expand Down Expand Up @@ -60,6 +59,7 @@ export function getFileFormat(filepath: string): string | null {
// --experimental-loader behavior but is required to work around
// https://github.com/nodejs/node/issues/33226
default: {
const isMain = process.argv[1] === filepath;
if (!isMain)
return null;
const pkg = nodeUtils.readPackageScope(filepath);
Expand Down

0 comments on commit 26a33db

Please sign in to comment.