Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ng-dev): yarnpkg lockfile package cannot be bundled with ESM #615

Merged
merged 2 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ng-dev/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ NG_DEV_EXTERNALS = [
# `typescript` is external because we want the project to provide a TypeScript version.
# TODO: Figure out how we want to manage dependencies for the dev-infra tool.
"typescript",
# Package uses `__filename` and `__dirname` and cannot be bundled in ESM. We do not
# intend to provide interop globals for this as it could hide other significant issues.
"@yarnpkg/lockfile",
]

ts_library(
Expand Down
4 changes: 2 additions & 2 deletions ng-dev/utils/resolve-yarn-bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as path from 'path';
import which from 'which';

import {isNodeJSWrappedError} from './nodejs-errors.js';
import {parse as parseLockfile} from '@yarnpkg/lockfile';
import lockfile from '@yarnpkg/lockfile';
import {parse as parseYaml} from 'yaml';
import {ChildProcess} from './child-process.js';
import {Log} from './logging.js';
Expand All @@ -33,7 +33,7 @@ export interface YarnCommandInfo {

/** List of Yarn configuration files and their parsing mechanisms. */
export const yarnConfigFiles: ConfigWithParser[] = [
{fileName: '.yarnrc', parse: (c) => parseLockfile(c).object},
{fileName: '.yarnrc', parse: (c) => lockfile.parse(c).object},
{fileName: '.yarnrc.yml', parse: (c) => parseYaml(c)},
];

Expand Down
6 changes: 3 additions & 3 deletions ng-dev/utils/version-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import * as path from 'path';
import * as fs from 'fs';
import {LockFileObject, parse as parseYarnLockfile} from '@yarnpkg/lockfile';
import lockfile from '@yarnpkg/lockfile';
import {
ngDevNpmPackageName,
workspaceRelativePackageJsonPath,
Expand All @@ -34,7 +34,7 @@ export async function verifyNgDevToolIsUpToDate(workspacePath: string): Promise<
try {
const lockFileContent = fs.readFileSync(workspaceDirLockFile, 'utf8');
const packageJson = JSON.parse(fs.readFileSync(workspacePackageJsonFile, 'utf8')) as any;
const lockFile = parseYarnLockfile(lockFileContent);
const lockFile = lockfile.parse(lockFileContent);

if (lockFile.type !== 'success') {
throw Error('Unable to parse workspace lock file. Please ensure the file is valid.');
Expand All @@ -45,7 +45,7 @@ export async function verifyNgDevToolIsUpToDate(workspacePath: string): Promise<
return true;
}

const lockFileObject = lockFile.object as LockFileObject;
const lockFileObject = lockFile.object as lockfile.LockFileObject;
const devInfraPkgVersion =
packageJson?.dependencies?.[ngDevNpmPackageName] ??
packageJson?.devDependencies?.[ngDevNpmPackageName] ??
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@types/tmp": "^0.2.1",
"@types/uuid": "^8.3.1",
"@types/yargs": "^17.0.0",
"@yarnpkg/lockfile": "^1.1.0",
"browser-sync": "^2.27.7",
"clang-format": "1.8.0",
"prettier": "2.6.2",
Expand Down Expand Up @@ -105,7 +106,6 @@
"@types/wait-on": "^5.3.1",
"@types/which": "^2.0.1",
"@types/yarnpkg__lockfile": "^1.1.5",
"@yarnpkg/lockfile": "^1.1.0",
"chalk": "^5.0.1",
"cli-progress": "^3.7.0",
"conventional-commits-parser": "^3.2.1",
Expand Down
1 change: 1 addition & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
true,
{
"noNamedExports": [
"@yarnpkg/lockfile",
"typescript",
"multimatch",
"semver",
Expand Down