From 491a84fb26fa716408bf6bd361680f6a450c61fc Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 25 Aug 2025 10:02:00 +0200 Subject: [PATCH] feat: use ESM instead of commonjs (#9870) --- .changeset/five-lies-travel.md | 188 ++++++++ .meta-updater/src/index.ts | 13 +- .meta-updater/tsconfig.json | 2 +- __fixtures__/package.yaml | 10 +- __patches__/@pnpm__npm-lifecycle.patch | 13 + __typings__/local.d.ts | 11 +- __typings__/typed.d.ts | 2 +- __utils__/assert-project/package.json | 1 + __utils__/assert-project/src/index.ts | 4 +- __utils__/assert-project/src/isExecutable.ts | 4 +- __utils__/assert-project/test/index.ts | 4 +- __utils__/assert-project/test/tsconfig.json | 5 +- __utils__/assert-store/package.json | 1 + __utils__/assert-store/test/index.ts | 4 +- __utils__/assert-store/test/tsconfig.json | 5 +- __utils__/build-artifacts/main.mjs | 8 +- __utils__/eslint-config/index.js | 6 +- __utils__/get-release-text/tsconfig.json | 2 +- __utils__/jest-config/config.js | 20 +- __utils__/jest-config/jest-preset.js | 5 +- __utils__/jest-config/package.json | 1 + __utils__/jest-config/setupFilesAfterEnv.js | 2 +- .../jest-config/with-registry/globalSetup.js | 11 +- .../with-registry/globalTeardown.js | 2 +- .../jest-config/with-registry/jest-preset.js | 10 +- __utils__/prepare-temp-dir/package.json | 1 + __utils__/prepare-temp-dir/src/index.ts | 2 +- __utils__/prepare/package.json | 1 + __utils__/scripts/package.json | 1 + __utils__/scripts/src/copy-artifacts.ts | 2 +- __utils__/scripts/src/typecheck-only.ts | 4 +- __utils__/test-fixtures/package.json | 1 + .../bin/test-ipc-server-client.js | 2 +- __utils__/test-ipc-server/package.json | 8 +- .../test/TestIpcServer.test.ts | 4 +- __utils__/test-ipc-server/test/tsconfig.json | 5 +- __utils__/tsconfig/tsconfig.json | 4 +- cache/api/package.json | 2 +- cache/commands/package.json | 4 +- cache/commands/src/cache.cmd.ts | 2 +- cache/commands/test/cacheDelete.cmd.test.ts | 2 +- cache/commands/test/cacheList.cmd.test.ts | 2 +- cache/commands/test/cacheView.cmd.test.ts | 2 +- cache/commands/test/tsconfig.json | 5 +- catalogs/config/package.json | 4 +- catalogs/config/test/tsconfig.json | 5 +- catalogs/protocol-parser/package.json | 4 +- catalogs/protocol-parser/test/tsconfig.json | 5 +- catalogs/resolver/package.json | 4 +- catalogs/resolver/test/tsconfig.json | 5 +- catalogs/types/package.json | 2 +- cli/cli-meta/package.json | 4 +- cli/cli-meta/src/index.ts | 20 +- cli/cli-meta/test/tsconfig.json | 5 +- cli/cli-utils/package.json | 4 +- cli/cli-utils/test/tsconfig.json | 5 +- cli/command/package.json | 2 +- cli/common-cli-options-help/package.json | 2 +- cli/default-reporter/package.json | 4 +- cli/default-reporter/src/reportError.ts | 2 +- .../src/reporterForClient/pkgsDiff.ts | 3 +- .../src/reporterForClient/reportStats.ts | 2 +- cli/default-reporter/test/index.ts | 2 +- cli/default-reporter/test/reportingErrors.ts | 4 +- cli/default-reporter/test/tsconfig.json | 5 +- cli/parse-cli-args/package.json | 4 +- cli/parse-cli-args/test/tsconfig.json | 5 +- .../plugin-commands-completion/package.json | 4 +- .../src/completionServer.ts | 2 +- .../src/getOptionType.ts | 2 +- .../test/tsconfig.json | 5 +- config/config-writer/package.json | 2 +- config/config-writer/src/index.ts | 2 +- config/config/package.json | 4 +- .../config/src/getOptionsFromRootManifest.ts | 4 +- config/config/src/index.ts | 2 +- config/config/src/readLocalConfig.ts | 2 +- config/config/src/types.ts | 2 +- config/config/test/concurrency.test.ts | 2 +- config/config/test/globalBinDir.test.ts | 13 +- config/config/test/index.ts | 27 +- config/config/test/readLocalConfig.test.ts | 2 +- config/config/test/tsconfig.json | 5 +- config/deps-installer/package.json | 4 +- config/deps-installer/test/tsconfig.json | 5 +- config/matcher/package.json | 4 +- config/matcher/test/tsconfig.json | 5 +- config/normalize-registries/package.json | 2 +- config/normalize-registries/src/index.ts | 2 +- config/package-is-installable/package.json | 4 +- .../test/checkPlatform.ts | 3 +- .../package-is-installable/test/tsconfig.json | 5 +- config/parse-overrides/package.json | 4 +- config/parse-overrides/test/tsconfig.json | 5 +- config/pick-registry-for-package/package.json | 4 +- .../test/tsconfig.json | 5 +- config/plugin-commands-config/package.json | 4 +- .../test/managingAuthSettings.test.ts | 15 +- .../plugin-commands-config/test/tsconfig.json | 5 +- crypto/hash/package.json | 4 +- crypto/hash/test/tsconfig.json | 5 +- crypto/object-hasher/package.json | 4 +- crypto/object-hasher/src/index.ts | 2 +- crypto/object-hasher/test/tsconfig.json | 5 +- crypto/shasums-file/package.json | 4 +- crypto/shasums-file/test/tsconfig.json | 5 +- dedupe/check/package.json | 4 +- dedupe/check/test/tsconfig.json | 5 +- dedupe/issues-renderer/package.json | 4 +- dedupe/issues-renderer/test/tsconfig.json | 5 +- dedupe/types/package.json | 2 +- deps/graph-builder/package.json | 2 +- deps/graph-builder/src/lockfileToDepGraph.ts | 3 +- deps/graph-sequencer/package.json | 4 +- deps/graph-sequencer/test/tsconfig.json | 5 +- deps/status/package.json | 4 +- deps/status/src/checkDepsStatus.ts | 5 +- deps/status/test/checkDepsStatus.test.ts | 64 ++- deps/status/test/tsconfig.json | 5 +- env/node.fetcher/package.json | 4 +- env/node.fetcher/test/node.test.ts | 8 +- env/node.fetcher/test/tsconfig.json | 5 +- env/node.resolver/package.json | 4 +- env/node.resolver/test/tsconfig.json | 5 +- env/path/package.json | 4 +- env/path/test/tsconfig.json | 5 +- env/plugin-commands-env/package.json | 4 +- env/plugin-commands-env/test/env.test.ts | 2 +- env/plugin-commands-env/test/node.test.ts | 23 +- env/plugin-commands-env/test/tsconfig.json | 5 +- env/system-node-version/package.json | 4 +- .../test/getSystemNodeVersion.test.ts | 7 +- env/system-node-version/test/tsconfig.json | 5 +- exec/build-commands/package.json | 4 +- exec/build-commands/src/approveBuilds.ts | 6 +- exec/build-commands/src/index.ts | 1 + .../build-commands/test/approveBuilds.test.ts | 19 +- exec/build-commands/test/tsconfig.json | 5 +- exec/build-modules/package.json | 4 +- exec/build-modules/src/buildSequence.ts | 2 +- exec/build-modules/src/index.ts | 4 +- exec/build-modules/test/tsconfig.json | 5 +- exec/lifecycle/package.json | 4 +- .../src/runLifecycleHooksConcurrently.ts | 2 +- .../test/fixtures/escape-args/echo.js | 6 + .../test/fixtures/escape-args/echo.sh | 6 - .../test/fixtures/escape-args/package.json | 3 +- .../test/fixtures/escape-newline/echo.js | 6 + .../test/fixtures/escape-newline/echo.sh | 6 - .../test/fixtures/escape-newline/package.json | 3 +- exec/lifecycle/test/index.ts | 14 +- exec/lifecycle/test/tsconfig.json | 5 +- exec/pkg-requires-build/package.json | 2 +- exec/plugin-commands-rebuild/package.json | 4 +- .../implementation/extendRebuildOptions.ts | 2 +- .../src/implementation/index.ts | 2 +- exec/plugin-commands-rebuild/src/rebuild.ts | 2 +- exec/plugin-commands-rebuild/test/index.ts | 14 +- .../plugin-commands-rebuild/test/recursive.ts | 7 +- .../test/tsconfig.json | 5 +- .../package.json | 4 +- .../src/create.ts | 2 +- .../plugin-commands-script-runners/src/dlx.ts | 2 +- .../src/exec.ts | 2 +- .../src/restart.ts | 2 +- .../plugin-commands-script-runners/src/run.ts | 2 +- .../src/runDepsStatusCheck.ts | 4 +- .../test/create.ts | 5 +- .../test/dlx.e2e.ts | 32 +- .../test/dlx.ts | 10 +- .../test/exec.e2e.ts | 2 +- .../test/exec.logs.ts | 28 +- .../test/exec.ts | 10 +- .../test/index.ts | 2 +- .../test/runRecursive.ts | 2 +- .../test/testRecursive.ts | 2 +- .../test/tsconfig.json | 5 +- .../test/verifyDepsBeforeRun.ts | 21 +- exec/pnpm-cli-runner/package.json | 2 +- exec/pnpm-cli-runner/src/index.ts | 2 +- exec/prepare-package/package.json | 4 +- exec/prepare-package/src/index.ts | 2 +- exec/prepare-package/test/index.ts | 2 +- exec/prepare-package/test/tsconfig.json | 5 +- exec/run-npm/package.json | 2 +- fetching/binary-fetcher/package.json | 2 +- fetching/directory-fetcher/package.json | 4 +- fetching/directory-fetcher/test/index.ts | 13 +- fetching/directory-fetcher/test/tsconfig.json | 5 +- fetching/fetcher-base/package.json | 2 +- fetching/git-fetcher/package.json | 4 +- fetching/git-fetcher/test/index.ts | 40 +- fetching/git-fetcher/test/tsconfig.json | 5 +- fetching/pick-fetcher/package.json | 4 +- fetching/pick-fetcher/test/tsconfig.json | 5 +- fetching/tarball-fetcher/package.json | 4 +- fetching/tarball-fetcher/test/fetch.ts | 23 +- fetching/tarball-fetcher/test/tsconfig.json | 5 +- fs/find-packages/README.md | 2 +- fs/find-packages/example.js | 2 +- fs/find-packages/package.json | 4 +- fs/find-packages/test/index.ts | 2 +- fs/find-packages/test/tsconfig.json | 5 +- fs/graceful-fs/package.json | 2 +- fs/hard-link-dir/package.json | 4 +- fs/hard-link-dir/test/tsconfig.json | 5 +- fs/indexed-pkg-importer/package.json | 4 +- .../src/importIndexedDir.ts | 4 +- .../test/createImportPackage.test.ts | 21 +- .../test/importingPkgWithInvalidFiles.ts | 4 +- fs/indexed-pkg-importer/test/tsconfig.json | 5 +- fs/is-empty-dir-or-nothing/package.json | 4 +- fs/is-empty-dir-or-nothing/test/index.test.ts | 6 +- fs/is-empty-dir-or-nothing/test/tsconfig.json | 5 +- fs/packlist/package.json | 2 +- fs/read-modules-dir/package.json | 2 +- fs/symlink-dependency/package.json | 4 +- fs/symlink-dependency/test/tsconfig.json | 5 +- hooks/pnpmfile/package.json | 4 +- hooks/pnpmfile/src/requirePnpmfile.ts | 5 +- hooks/pnpmfile/test/__fixtures__/package.json | 3 + hooks/pnpmfile/test/index.ts | 36 +- hooks/pnpmfile/test/tsconfig.json | 5 +- hooks/read-package-hook/package.json | 4 +- .../src/createReadPackageHook.ts | 3 +- .../src/createVersionsOverrider.ts | 2 +- .../test/createVersionOverrider.test.ts | 2 +- hooks/read-package-hook/test/tsconfig.json | 5 +- hooks/types/package.json | 2 +- lockfile/audit/package.json | 4 +- lockfile/audit/src/lockfileToAuditTree.ts | 2 +- lockfile/audit/test/index.ts | 2 +- lockfile/audit/test/tsconfig.json | 5 +- lockfile/detect-dep-types/package.json | 2 +- lockfile/filtering/package.json | 4 +- .../src/filterLockfileByImportersAndEngine.ts | 4 +- .../test/filterByImportersAndEngine.ts | 3 +- lockfile/filtering/test/tsconfig.json | 5 +- lockfile/fs/package.json | 4 +- lockfile/fs/src/index.ts | 2 +- lockfile/fs/src/lockfileFormatConverters.ts | 6 +- lockfile/fs/src/write.ts | 2 +- lockfile/fs/test/gitBranchLockfile.test.ts | 2 +- lockfile/fs/test/lockfileName.test.ts | 7 +- lockfile/fs/test/read.test.ts | 19 +- lockfile/fs/test/tsconfig.json | 5 +- lockfile/fs/test/write.test.ts | 15 +- lockfile/lockfile-to-pnp/package.json | 4 +- lockfile/lockfile-to-pnp/test/tsconfig.json | 5 +- lockfile/merger/package.json | 4 +- lockfile/merger/test/tsconfig.json | 5 +- lockfile/plugin-commands-audit/package.json | 4 +- lockfile/plugin-commands-audit/src/audit.ts | 4 +- lockfile/plugin-commands-audit/src/fix.ts | 2 +- lockfile/plugin-commands-audit/src/ignore.ts | 2 +- lockfile/plugin-commands-audit/test/fix.ts | 2 +- lockfile/plugin-commands-audit/test/ignore.ts | 2 +- lockfile/plugin-commands-audit/test/index.ts | 2 +- .../plugin-commands-audit/test/tsconfig.json | 5 +- .../test/utils/responses/index.ts | 6 +- .../test/utils/responses/update.ts | 4 +- lockfile/preferred-versions/package.json | 2 +- lockfile/pruner/package.json | 4 +- lockfile/pruner/src/index.ts | 5 +- lockfile/pruner/test/tsconfig.json | 5 +- lockfile/settings-checker/package.json | 2 +- .../settings-checker/src/calcPatchHashes.ts | 2 +- .../src/getOutdatedLockfileSetting.ts | 2 +- lockfile/types/package.json | 2 +- lockfile/utils/package.json | 4 +- lockfile/utils/src/index.ts | 2 +- lockfile/utils/test/tsconfig.json | 5 +- lockfile/verification/package.json | 4 +- .../src/allProjectsAreUpToDate.ts | 4 +- .../src/linkedPackagesAreUpToDate.ts | 4 +- .../src/localTarballDepsAreUpToDate.ts | 4 +- .../src/satisfiesPackageManifest.ts | 4 +- lockfile/verification/test/tsconfig.json | 5 +- lockfile/walker/package.json | 2 +- modules-mounter/daemon/package.json | 6 +- .../daemon/src/createFuseHandlers.ts | 2 +- .../daemon/test/createFuseHandlers.test.ts | 11 +- .../test/makeVirtualNodeModules.test.ts | 2 +- modules-mounter/daemon/test/tsconfig.json | 5 +- network/auth-header/package.json | 4 +- .../test/getAuthHeadersFromConfig.test.ts | 8 +- network/auth-header/test/tsconfig.json | 5 +- network/fetch/package.json | 4 +- network/fetch/test/fetchFromRegistry.test.ts | 2 +- network/fetch/test/tsconfig.json | 5 +- network/fetching-types/package.json | 2 +- object/key-sorting/package.json | 4 +- object/key-sorting/test/tsconfig.json | 5 +- object/property-path/package.json | 4 +- object/property-path/test/tsconfig.json | 5 +- package.json | 2 +- packages/calc-dep-state/package.json | 4 +- packages/calc-dep-state/test/tsconfig.json | 5 +- packages/constants/package.json | 2 +- packages/core-loggers/package.json | 2 +- packages/dependency-path/package.json | 4 +- packages/dependency-path/test/tsconfig.json | 5 +- packages/error/package.json | 4 +- packages/error/test/tsconfig.json | 5 +- packages/git-utils/package.json | 4 +- packages/git-utils/test/tsconfig.json | 5 +- packages/logger/package.json | 4 +- packages/logger/test/index.test.ts | 2 +- packages/logger/test/tsconfig.json | 5 +- packages/make-dedicated-lockfile/package.json | 4 +- packages/make-dedicated-lockfile/src/index.ts | 4 +- .../make-dedicated-lockfile/test/index.ts | 4 +- .../test/tsconfig.json | 5 +- packages/parse-wanted-dependency/package.json | 2 +- packages/plugin-commands-doctor/package.json | 4 +- .../plugin-commands-doctor/test/tsconfig.json | 5 +- packages/plugin-commands-init/package.json | 4 +- packages/plugin-commands-init/src/init.ts | 2 +- .../plugin-commands-init/test/tsconfig.json | 5 +- .../plugin-commands-init/test/utils.test.ts | 2 +- packages/plugin-commands-setup/package.json | 4 +- packages/plugin-commands-setup/src/setup.ts | 2 +- .../plugin-commands-setup/test/setup.test.ts | 14 +- .../plugin-commands-setup/test/tsconfig.json | 5 +- packages/render-peer-issues/package.json | 4 +- .../render-peer-issues/test/tsconfig.json | 5 +- packages/types/package.json | 2 +- patching/apply-patch/package.json | 4 +- patching/apply-patch/test/applyPatchToDir.ts | 11 +- patching/apply-patch/test/tsconfig.json | 5 +- patching/config/package.json | 4 +- patching/config/test/tsconfig.json | 5 +- .../plugin-commands-patching/package.json | 4 +- .../src/getPatchedDependency.ts | 4 +- .../plugin-commands-patching/src/index.ts | 2 + .../plugin-commands-patching/src/patch.ts | 2 +- .../src/patchCommit.ts | 3 +- .../src/patchRemove.ts | 6 +- .../test/patch.test.ts | 29 +- .../test/tsconfig.json | 5 +- patching/types/package.json | 2 +- pkg-manager/client/package.json | 4 +- pkg-manager/client/src/index.ts | 2 +- pkg-manager/client/test/tsconfig.json | 5 +- pkg-manager/core/package.json | 4 +- pkg-manager/core/src/install/index.ts | 6 +- pkg-manager/core/src/install/link.ts | 7 +- .../src/install/reportPeerDependencyIssues.ts | 2 +- .../core/src/install/validateModules.ts | 2 +- pkg-manager/core/src/pnpmPkgJson.ts | 2 +- .../core/test/brokenLockfileIntegrity.ts | 2 +- pkg-manager/core/test/catalogs.ts | 10 +- .../core/test/hoistedNodeLinker/install.ts | 2 +- .../core/test/install/bundledDependencies.ts | 2 +- pkg-manager/core/test/install/errors.ts | 2 +- .../test/install/excludeLinksFromLockfile.ts | 2 +- pkg-manager/core/test/install/fromRepo.ts | 2 +- .../test/install/gitBranchLockfile.test.ts | 7 +- pkg-manager/core/test/install/local.ts | 4 +- pkg-manager/core/test/install/lockfileDir.ts | 2 +- pkg-manager/core/test/install/misc.ts | 2 +- pkg-manager/core/test/install/patch.ts | 2 +- .../core/test/install/peerDependencies.ts | 2 +- .../core/test/install/setExtraNodePath.ts | 2 +- pkg-manager/core/test/link.ts | 2 +- pkg-manager/core/test/lockfile.ts | 4 +- pkg-manager/core/test/prune.ts | 2 +- pkg-manager/core/test/tsconfig.json | 5 +- pkg-manager/core/test/uninstall.ts | 2 +- pkg-manager/direct-dep-linker/package.json | 2 +- .../direct-dep-linker/src/linkDirectDeps.ts | 2 +- pkg-manager/get-context/package.json | 4 +- pkg-manager/get-context/src/index.ts | 2 +- pkg-manager/get-context/src/readLockfiles.ts | 3 +- pkg-manager/get-context/test/index.ts | 4 +- pkg-manager/get-context/test/tsconfig.json | 5 +- pkg-manager/headless/package.json | 6 +- pkg-manager/headless/src/index.ts | 8 +- .../headless/src/linkHoistedModules.ts | 3 +- pkg-manager/headless/test/index.ts | 2 +- pkg-manager/headless/test/tsconfig.json | 5 +- pkg-manager/hoist/package.json | 2 +- pkg-manager/link-bins/package.json | 4 +- pkg-manager/link-bins/src/index.ts | 7 +- pkg-manager/link-bins/test/index.ts | 17 +- pkg-manager/link-bins/test/tsconfig.json | 5 +- pkg-manager/modules-cleaner/package.json | 2 +- pkg-manager/modules-cleaner/src/prune.ts | 5 +- pkg-manager/modules-yaml/package.json | 4 +- pkg-manager/modules-yaml/src/index.ts | 6 +- pkg-manager/modules-yaml/test/index.ts | 6 +- pkg-manager/modules-yaml/test/tsconfig.json | 5 +- pkg-manager/package-bins/package.json | 4 +- pkg-manager/package-bins/test/index.ts | 2 +- pkg-manager/package-bins/test/tsconfig.json | 5 +- pkg-manager/package-requester/package.json | 4 +- .../package-requester/src/packageRequester.ts | 2 +- pkg-manager/package-requester/test/index.ts | 2 +- .../package-requester/test/tsconfig.json | 5 +- .../plugin-commands-installation/package.json | 4 +- .../plugin-commands-installation/src/add.ts | 2 +- .../src/dedupe.ts | 2 +- .../src/import/index.ts | 7 +- .../src/install.ts | 2 +- .../plugin-commands-installation/src/link.ts | 3 +- .../plugin-commands-installation/src/prune.ts | 2 +- .../src/remove.ts | 3 +- .../src/update/getUpdateChoices.ts | 7 +- .../src/update/index.ts | 8 +- .../plugin-commands-installation/test/add.ts | 18 +- .../test/addRecursive.ts | 30 +- .../test/dedupe.ts | 2 +- .../test/global.ts | 4 +- .../test/import.ts | 2 +- .../test/importRecursive.ts | 2 +- .../plugin-commands-installation/test/link.ts | 35 +- .../test/miscRecursive.ts | 12 +- .../test/patchedDependencies.ts | 11 +- .../test/prune.ts | 2 +- .../test/remove/workspace.ts | 16 +- .../test/tsconfig.json | 5 +- .../test/update/interactive.ts | 22 +- .../test/update/issue-7415.ts | 7 +- .../test/warnCyclicDependencies.ts | 24 +- .../read-projects-context/package.json | 2 +- pkg-manager/real-hoist/package.json | 4 +- pkg-manager/real-hoist/test/index.ts | 2 +- pkg-manager/real-hoist/test/tsconfig.json | 5 +- pkg-manager/remove-bins/package.json | 2 +- pkg-manager/resolve-dependencies/package.json | 4 +- .../src/getNonDevWantedDependencies.ts | 2 +- pkg-manager/resolve-dependencies/src/index.ts | 3 +- .../src/resolveDependencies.ts | 4 +- .../src/resolveDependencyTree.ts | 3 +- .../resolve-dependencies/src/resolvePeers.ts | 3 +- .../src/updateLockfile.ts | 2 +- .../resolve-dependencies/test/tsconfig.json | 5 +- pkg-manifest/exportable-manifest/package.json | 4 +- pkg-manifest/exportable-manifest/src/index.ts | 4 +- .../src/overridePublishConfig.ts | 2 +- .../exportable-manifest/test/index.test.ts | 2 +- .../exportable-manifest/test/tsconfig.json | 5 +- pkg-manifest/manifest-utils/package.json | 4 +- .../manifest-utils/test/tsconfig.json | 5 +- pkg-manifest/read-package-json/package.json | 4 +- pkg-manifest/read-package-json/test/index.ts | 6 +- .../read-package-json/test/tsconfig.json | 5 +- .../read-project-manifest/package.json | 6 +- .../read-project-manifest/src/index.ts | 4 +- .../read-project-manifest/test/index.ts | 4 +- .../read-project-manifest/test/tsconfig.json | 5 +- .../write-project-manifest/package.json | 4 +- .../write-project-manifest/test/tsconfig.json | 5 +- pnpm-lock.yaml | 439 +++++++++++------- pnpm-workspace.yaml | 18 +- pnpm/artifacts/exe/package.json | 1 + pnpm/artifacts/exe/prepare.js | 6 +- pnpm/artifacts/exe/scripts/build-artifacts.ts | 8 +- pnpm/artifacts/exe/setup.js | 7 +- pnpm/bin/{pnpm.cjs => pnpm.mjs} | 11 +- pnpm/bin/{pnpx.cjs => pnpx.mjs} | 2 +- pnpm/bundle.ts | 7 +- pnpm/dev/package.json | 1 + pnpm/dev/pd.js | 37 +- pnpm/package.json | 16 +- pnpm/pnpm.cjs | 5 + pnpm/src/checkForUpdates.test.ts | 9 +- pnpm/src/cmd/bin.ts | 2 +- pnpm/src/cmd/index.ts | 2 +- pnpm/src/cmd/root.ts | 2 +- pnpm/src/main.ts | 2 +- pnpm/src/runNpm.ts | 2 +- pnpm/test/cli.ts | 2 +- pnpm/test/errorHandler.test.ts | 2 +- pnpm/test/install/lifecycleScripts.ts | 4 +- pnpm/test/install/misc.ts | 6 +- pnpm/test/install/only.ts | 2 +- pnpm/test/monorepo/index.ts | 12 +- pnpm/test/patch/allowUnusedPatches.ts | 2 +- pnpm/test/patch/ignorePatchFailures.ts | 2 +- pnpm/test/syncInjectedDepsAfterScripts.ts | 2 +- pnpm/test/tsconfig.json | 5 +- pnpm/test/utils/execPnpm.ts | 6 +- pnpm/test/utils/localPkg.ts | 2 +- releasing/plugin-commands-deploy/package.json | 4 +- .../src/createDeployFiles.ts | 2 +- .../plugin-commands-deploy/src/deploy.ts | 2 +- .../test/deploy.test.ts | 27 +- .../test/shared-lockfile.test.ts | 23 +- .../plugin-commands-deploy/test/tsconfig.json | 5 +- .../plugin-commands-publishing/package.json | 4 +- .../plugin-commands-publishing/src/pack.ts | 2 +- .../plugin-commands-publishing/src/publish.ts | 6 +- .../src/recursivePublish.ts | 2 +- .../test/gitChecks.ts | 10 +- .../plugin-commands-publishing/test/pack.ts | 14 +- .../test/publish.ts | 44 +- .../test/tsconfig.json | 5 +- resolving/bun-resolver/package.json | 2 +- resolving/default-resolver/package.json | 4 +- resolving/default-resolver/test/tsconfig.json | 5 +- resolving/deno-resolver/package.json | 2 +- resolving/git-resolver/package.json | 4 +- resolving/git-resolver/test/index.ts | 30 +- resolving/git-resolver/test/tsconfig.json | 5 +- resolving/jsr-specifier-parser/package.json | 4 +- .../jsr-specifier-parser/test/tsconfig.json | 5 +- resolving/local-resolver/package.json | 4 +- resolving/local-resolver/test/index.ts | 40 +- resolving/local-resolver/test/tsconfig.json | 5 +- resolving/npm-resolver/package.json | 4 +- resolving/npm-resolver/src/index.ts | 2 +- .../npm-resolver/src/parseBareSpecifier.ts | 2 +- resolving/npm-resolver/src/pickPackage.ts | 2 +- resolving/npm-resolver/test/index.ts | 4 +- .../npm-resolver/test/publishedBy.test.ts | 2 +- .../npm-resolver/test/resolveJsr.test.ts | 2 +- resolving/npm-resolver/test/tsconfig.json | 5 +- resolving/resolver-base/package.json | 2 +- resolving/tarball-resolver/package.json | 4 +- resolving/tarball-resolver/test/tsconfig.json | 5 +- .../dependencies-hierarchy/example/index.js | 2 +- reviewing/dependencies-hierarchy/package.json | 4 +- .../dependencies-hierarchy/test/index.ts | 7 +- .../dependencies-hierarchy/test/tsconfig.json | 5 +- reviewing/license-scanner/package.json | 4 +- .../src/lockfileToLicenseNodeTree.ts | 2 +- .../license-scanner/test/licenses.spec.ts | 7 +- reviewing/license-scanner/test/tsconfig.json | 5 +- reviewing/list/example/index.js | 2 +- reviewing/list/package.json | 4 +- reviewing/list/src/renderJson.ts | 4 +- reviewing/list/src/renderParseable.ts | 3 +- reviewing/list/src/renderTree.ts | 3 +- reviewing/list/test/index.ts | 2 +- reviewing/list/test/tsconfig.json | 5 +- reviewing/outdated/package.json | 4 +- .../outdated/src/outdatedDepsOfProjects.ts | 2 +- reviewing/outdated/test/tsconfig.json | 5 +- .../plugin-commands-licenses/package.json | 4 +- .../plugin-commands-licenses/src/licenses.ts | 2 +- .../plugin-commands-licenses/test/index.ts | 2 +- .../test/tsconfig.json | 5 +- .../plugin-commands-listing/package.json | 4 +- reviewing/plugin-commands-listing/src/list.ts | 2 +- reviewing/plugin-commands-listing/src/ll.ts | 2 +- reviewing/plugin-commands-listing/src/why.ts | 2 +- .../plugin-commands-listing/test/index.ts | 2 +- .../test/tsconfig.json | 5 +- reviewing/plugin-commands-listing/test/why.ts | 2 +- .../plugin-commands-outdated/package.json | 4 +- .../plugin-commands-outdated/src/outdated.ts | 7 +- .../plugin-commands-outdated/src/recursive.ts | 3 +- .../plugin-commands-outdated/test/index.ts | 2 +- .../test/tsconfig.json | 5 +- semver/peer-range/package.json | 2 +- store/cafs-types/package.json | 2 +- store/cafs/package.json | 4 +- store/cafs/test/index.ts | 6 +- store/cafs/test/tsconfig.json | 5 +- store/create-cafs-store/package.json | 2 +- store/create-cafs-store/src/index.ts | 2 +- store/package-store/package.json | 4 +- store/package-store/test/tsconfig.json | 5 +- store/plugin-commands-server/package.json | 2 +- store/plugin-commands-server/src/server.ts | 2 +- .../package.json | 4 +- .../test/catFile.ts | 2 +- .../test/catIndex.ts | 4 +- .../test/findHash.ts | 2 +- .../test/tsconfig.json | 5 +- store/plugin-commands-store/package.json | 4 +- .../src/cleanExpiredDlxCache.test.ts | 97 ++-- .../src/cleanExpiredDlxCache.ts | 3 +- store/plugin-commands-store/src/store.ts | 2 +- .../plugin-commands-store/test/storePrune.ts | 2 +- .../plugin-commands-store/test/storeStatus.ts | 2 +- .../plugin-commands-store/test/tsconfig.json | 5 +- store/server/package.json | 4 +- store/server/test/index.ts | 4 +- store/server/test/tsconfig.json | 5 +- store/store-connection-manager/package.json | 2 +- .../src/runServerInBackground.ts | 5 +- store/store-controller-types/package.json | 2 +- store/store-path/__mocks__/can-link.js | 8 - store/store-path/__mocks__/fs.js | 5 - store/store-path/__mocks__/os.js | 3 - store/store-path/__mocks__/path-temp.js | 5 - .../store-path/__mocks__/root-link-target.js | 8 - store/store-path/__mocks__/touch.js | 1 - store/store-path/package.json | 4 +- store/store-path/test/index.ts | 54 ++- store/store-path/test/tsconfig.json | 5 +- testing/temp-store/package.json | 2 +- text/comments-parser/package.json | 4 +- text/comments-parser/test/tsconfig.json | 5 +- tools/path/package.json | 2 +- .../plugin-commands-self-updater/package.json | 4 +- .../src/selfUpdate.ts | 2 +- .../test/selfUpdate.test.ts | 9 +- .../test/tsconfig.json | 5 +- worker/package.json | 2 +- worker/src/index.ts | 4 +- .../filter-packages-from-dir/package.json | 2 +- .../filter-workspace-packages/package.json | 4 +- .../src/getChangedPackages.ts | 4 +- .../filter-workspace-packages/src/index.ts | 6 +- .../filter-workspace-packages/test/index.ts | 2 +- .../test/tsconfig.json | 5 +- workspace/find-packages/package.json | 4 +- workspace/find-packages/test/index.ts | 4 +- workspace/find-packages/test/tsconfig.json | 5 +- workspace/find-workspace-dir/package.json | 4 +- workspace/find-workspace-dir/test/index.ts | 4 +- .../find-workspace-dir/test/tsconfig.json | 5 +- workspace/injected-deps-syncer/package.json | 4 +- .../injected-deps-syncer/test/tsconfig.json | 5 +- workspace/manifest-writer/package.json | 4 +- workspace/manifest-writer/src/index.ts | 2 +- workspace/manifest-writer/test/tsconfig.json | 5 +- workspace/pkgs-graph/package.json | 4 +- workspace/pkgs-graph/src/index.ts | 2 +- workspace/pkgs-graph/test/tsconfig.json | 5 +- workspace/read-manifest/package.json | 4 +- workspace/read-manifest/src/index.ts | 2 +- workspace/read-manifest/test/index.ts | 42 +- workspace/read-manifest/test/tsconfig.json | 5 +- .../resolve-workspace-range/package.json | 2 +- workspace/sort-packages/package.json | 4 +- workspace/spec-parser/package.json | 4 +- workspace/spec-parser/test/tsconfig.json | 5 +- workspace/state/package.json | 4 +- workspace/state/src/createWorkspaceState.ts | 2 +- workspace/state/test/tsconfig.json | 5 +- 634 files changed, 2286 insertions(+), 1749 deletions(-) create mode 100644 .changeset/five-lies-travel.md create mode 100644 __patches__/@pnpm__npm-lifecycle.patch create mode 100644 exec/lifecycle/test/fixtures/escape-args/echo.js delete mode 100644 exec/lifecycle/test/fixtures/escape-args/echo.sh create mode 100644 exec/lifecycle/test/fixtures/escape-newline/echo.js delete mode 100644 exec/lifecycle/test/fixtures/escape-newline/echo.sh create mode 100644 hooks/pnpmfile/test/__fixtures__/package.json rename pnpm/bin/{pnpm.cjs => pnpm.mjs} (79%) rename pnpm/bin/{pnpx.cjs => pnpx.mjs} (78%) create mode 100644 pnpm/pnpm.cjs delete mode 100644 store/store-path/__mocks__/can-link.js delete mode 100644 store/store-path/__mocks__/fs.js delete mode 100644 store/store-path/__mocks__/os.js delete mode 100644 store/store-path/__mocks__/path-temp.js delete mode 100644 store/store-path/__mocks__/root-link-target.js delete mode 100644 store/store-path/__mocks__/touch.js diff --git a/.changeset/five-lies-travel.md b/.changeset/five-lies-travel.md new file mode 100644 index 0000000000..7458b88c97 --- /dev/null +++ b/.changeset/five-lies-travel.md @@ -0,0 +1,188 @@ +--- +"@pnpm/plugin-commands-installation": major +"@pnpm/plugin-commands-store-inspecting": major +"@pnpm/plugin-commands-completion": major +"@pnpm/plugin-commands-publishing": major +"@pnpm/plugin-commands-script-runners": major +"@pnpm/write-project-manifest": major +"@pnpm/filter-workspace-packages": major +"@pnpm/read-project-manifest": major +"@pnpm/plugin-commands-licenses": major +"@pnpm/plugin-commands-outdated": major +"@pnpm/tools.plugin-commands-self-updater": major +"@pnpm/workspace.filter-packages-from-dir": major +"@pnpm/plugin-commands-patching": major +"@pnpm/read-projects-context": major +"@pnpm/plugin-commands-listing": major +"@pnpm/resolve-workspace-range": major +"@pnpm/pick-registry-for-package": major +"@pnpm/make-dedicated-lockfile": major +"@pnpm/parse-wanted-dependency": major +"@pnpm/resolve-dependencies": major +"@pnpm/exportable-manifest": major +"@pnpm/plugin-commands-deploy": major +"@pnpm/reviewing.dependencies-hierarchy": major +"@pnpm/plugin-commands-doctor": major +"@pnpm/plugin-commands-audit": major +"@pnpm/plugin-commands-setup": major +"@pnpm/read-package-json": major +"@pnpm/resolving.jsr-specifier-parser": major +"@pnpm/store-connection-manager": major +"@pnpm/workspace.injected-deps-syncer": major +"@pnpm/package-is-installable": major +"@pnpm/plugin-commands-config": major +"@pnpm/plugin-commands-init": major +"@pnpm/pkg-manager.direct-dep-linker": major +"@pnpm/package-requester": major +"@pnpm/plugin-commands-rebuild": major +"@pnpm/plugin-commands-server": major +"@pnpm/store-controller-types": major +"@pnpm/find-workspace-dir": major +"@pnpm/common-cli-options-help": major +"@pnpm/normalize-registries": major +"@pnpm/lockfile.preferred-versions": major +"@pnpm/render-peer-issues": major +"@pnpm/modules-cleaner": major +"@pnpm/manifest-utils": major +"@pnpm/plugin-commands-store": major +"@pnpm/get-release-text": major +"@pnpm/prepare-temp-dir": major +"@pnpm/directory-fetcher": major +"@pnpm/fs.is-empty-dir-or-nothing": major +"@pnpm/default-resolver": major +"@pnpm/tarball-resolver": major +"@pnpm/test-ipc-server": major +"@pnpm/lockfile.detect-dep-types": major +"@pnpm/lockfile.settings-checker": major +"@pnpm/license-scanner": major +"@pnpm/workspace.manifest-writer": major +"@pnpm/assert-project": major +"@pnpm/catalogs.protocol-parser": major +"@pnpm/tarball-fetcher": major +"@pnpm/lockfile-to-pnp": major +"@pnpm/dependency-path": major +"@pnpm/modules-yaml": major +"@pnpm/package-bins": major +"@pnpm/local-resolver": major +"@pnpm/eslint-config": major +"@pnpm/test-fixtures": major +"@pnpm/plugin-commands-env": major +"@pnpm/env.system-node-version": major +"@pnpm/exec.pkg-requires-build": major +"@pnpm/fetching.binary-fetcher": major +"@pnpm/fs.indexed-pkg-importer": major +"@pnpm/hooks.read-package-hook": major +"@pnpm/calc-dep-state": major +"@pnpm/get-context": major +"@pnpm/remove-bins": major +"@pnpm/resolving.deno-resolver": major +"@pnpm/resolver-base": major +"@pnpm/create-cafs-store": major +"@pnpm/workspace.find-packages": major +"@pnpm/workspace.read-manifest": major +"@pnpm/sort-packages": major +"@pnpm/assert-store": major +"@pnpm/parse-overrides": major +"@pnpm/dedupe.issues-renderer": major +"@pnpm/mount-modules": major +"@pnpm/fetching-types": major +"@pnpm/real-hoist": major +"@pnpm/resolving.bun-resolver": major +"@pnpm/git-resolver": major +"@pnpm/npm-resolver": major +"@pnpm/jest-config": major +"@pnpm/config.deps-installer": major +"@pnpm/fetcher-base": major +"@pnpm/pick-fetcher": major +"@pnpm/symlink-dependency": major +"@pnpm/lockfile.verification": major +"@pnpm/core-loggers": major +"@pnpm/link-bins": major +"@pnpm/workspace.spec-parser": major +"@pnpm/default-reporter": major +"@pnpm/config.config-writer": major +"@pnpm/crypto.object-hasher": major +"@pnpm/deps.graph-sequencer": major +"@pnpm/exec.pnpm-cli-runner": major +"@pnpm/prepare-package": major +"@pnpm/git-fetcher": major +"@pnpm/object.property-path": major +"@pnpm/patching.apply-patch": major +"@pnpm/headless": major +"@pnpm/text.comments-parser": major +"@pnpm/workspace.pkgs-graph": major +"@pnpm/crypto.shasums-file": major +"@pnpm/exec.build-commands": major +"@pnpm/read-modules-dir": major +"@pnpm/network.auth-header": major +"@pnpm/package-store": major +"@pnpm/tsconfig": major +"@pnpm/parse-cli-args": major +"@pnpm/deps.graph-builder": major +"@pnpm/build-modules": major +"@pnpm/lockfile.filtering": major +"@pnpm/object.key-sorting": major +"@pnpm/constants": major +"@pnpm/git-utils": major +"@pnpm/client": major +"@pnpm/exe": major +"@pnpm/outdated": major +"@pnpm/testing.temp-store": major +"@pnpm/prepare": major +"@pnpm/scripts": major +"@pnpm/catalogs.resolver": major +"@pnpm/node.resolver": major +"@pnpm/hoist": major +"@pnpm/semver.peer-range": major +"@pnpm/node.fetcher": major +"@pnpm/fs.find-packages": major +"@pnpm/fs.hard-link-dir": major +"@pnpm/core": major +"@pnpm/cafs-types": major +"@pnpm/store-path": major +"@pnpm/catalogs.config": major +"@pnpm/lockfile.merger": major +"@pnpm/lockfile.pruner": major +"@pnpm/lockfile.walker": major +"@pnpm/logger": major +"@pnpm/patching.config": major +"@pnpm/workspace.state": major +"@pnpm/cache.commands": major +"@pnpm/catalogs.types": major +"@pnpm/matcher": major +"@pnpm/lifecycle": major +"@pnpm/graceful-fs": major +"@pnpm/pnpmfile": major +"@pnpm/audit": major +"@pnpm/lockfile.types": major +"@pnpm/lockfile.utils": major +"@pnpm/error": major +"@pnpm/types": major +"@pnpm/patching.types": major +"@pnpm/list": major +"@pnpm-private/updater": major +"@pnpm/cli-utils": major +"@pnpm/config": major +"@pnpm/fetch": major +"@pnpm/cli-meta": major +"@pnpm/dedupe.check": major +"@pnpm/dedupe.types": major +"@pnpm/run-npm": major +"@pnpm/server": major +"@pnpm-private/typings": major +"@pnpm/command": major +"@pnpm/crypto.hash": major +"@pnpm/deps.status": major +"@pnpm/fs.packlist": major +"@pnpm/hooks.types": major +"@pnpm/lockfile.fs": major +"@pnpm/store.cafs": major +"@pnpm/tools.path": major +"@pnpm/cache.api": major +"@pnpm/env.path": major +"pd": major +"@pnpm/worker": major +"pnpm": major +--- + +This package is now pure ESM. diff --git a/.meta-updater/src/index.ts b/.meta-updater/src/index.ts index 63c118e838..8688a98e18 100644 --- a/.meta-updater/src/index.ts +++ b/.meta-updater/src/index.ts @@ -183,8 +183,9 @@ async function updateTSConfig ( extends: '../tsconfig.json', compilerOptions: { noEmit: false, - outDir: '../test.lib', - rootDir: '.', + outDir: '../node_modules/.test.lib', + rootDir: '..', + isolatedModules: true, }, include: [ '**/*.ts', @@ -277,9 +278,9 @@ async function updateManifest (workspaceDir: string, manifest: ProjectManifest, if (manifest.name === '@pnpm/core') { // @pnpm/core tests currently works only with port 7769 due to the usage of // the next package: pkg-with-tarball-dep-from-registry - scripts._test = `cross-env PNPM_REGISTRY_MOCK_PORT=${registryMockPortForCore} jest` + scripts._test = `cross-env PNPM_REGISTRY_MOCK_PORT=${registryMockPortForCore} NODE_OPTIONS=--experimental-vm-modules jest` } else { - scripts._test = 'jest' + scripts._test = 'cross-env NODE_OPTIONS=--experimental-vm-modules jest' } break } @@ -287,7 +288,7 @@ async function updateManifest (workspaceDir: string, manifest: ProjectManifest, if (fs.existsSync(path.join(dir, 'test'))) { scripts = { ...(manifest.scripts as Record), - _test: 'jest', + _test: 'cross-env NODE_OPTIONS=--experimental-vm-modules jest', test: 'pnpm run compile && pnpm run _test', } } else { @@ -368,7 +369,7 @@ async function updateManifest (workspaceDir: string, manifest: ProjectManifest, }) } return sortKeysInManifest({ - type: 'commonjs', + type: 'module', ...manifest, bugs: { url: 'https://github.com/pnpm/pnpm/issues', diff --git a/.meta-updater/tsconfig.json b/.meta-updater/tsconfig.json index ee3c2a38bd..aeade37ddf 100644 --- a/.meta-updater/tsconfig.json +++ b/.meta-updater/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "lib", "rootDir": "src", - "module": "ES2020" + "module": "nodenext" }, "include": [ "src/**/*.ts", diff --git a/__fixtures__/package.yaml b/__fixtures__/package.yaml index 6d8c5b671a..f162ef41b5 100644 --- a/__fixtures__/package.yaml +++ b/__fixtures__/package.yaml @@ -1,9 +1,9 @@ scripts: - step1: node ../pnpm/dist/pnpm.cjs install -rf --frozen-lockfile --no-shared-workspace-lockfile --no-link-workspace-packages - step2: node ../pnpm/dist/pnpm.cjs install -rf --frozen-lockfile --no-shared-workspace-lockfile --no-link-workspace-packages - step3: node ../pnpm/dist/pnpm.cjs install -rf -C fixtureWithLinks --frozen-lockfile --link-workspace-packages --no-shared-workspace-lockfile - step4: cd ./fixture-with-external-shrinkwrap/pkg && node ../../../pnpm/dist/pnpm.cjs install -f --frozen-lockfile - step5: cd ./custom-modules-dir && node ../../pnpm/dist/pnpm.cjs install -f --frozen-lockfile + step1: node ../pnpm/dist/pnpm.mjs install -rf --frozen-lockfile --no-shared-workspace-lockfile --no-link-workspace-packages + step2: node ../pnpm/dist/pnpm.mjs install -rf --frozen-lockfile --no-shared-workspace-lockfile --no-link-workspace-packages + step3: node ../pnpm/dist/pnpm.mjs install -rf -C fixtureWithLinks --frozen-lockfile --link-workspace-packages --no-shared-workspace-lockfile + step4: cd ./fixture-with-external-shrinkwrap/pkg && node ../../../pnpm/dist/pnpm.mjs install -f --frozen-lockfile + step5: cd ./custom-modules-dir && node ../../pnpm/dist/pnpm.mjs install -f --frozen-lockfile prepareFixtures: > pnpm run step1 && pnpm run step2 && diff --git a/__patches__/@pnpm__npm-lifecycle.patch b/__patches__/@pnpm__npm-lifecycle.patch new file mode 100644 index 0000000000..9dae5fd1a4 --- /dev/null +++ b/__patches__/@pnpm__npm-lifecycle.patch @@ -0,0 +1,13 @@ +diff --git a/index.js b/index.js +index 8506b4c43670dd8ddb490001f2c2a5649b11f326..af35d94765e23a4e9b46b0e332ffd37061e05968 100644 +--- a/index.js ++++ b/index.js +@@ -87,7 +87,7 @@ function lifecycle (pkg, stage, wd, opts) { + // Instead, we use the path to the exe file. + env.npm_execpath = process.execPath + } else { +- env.npm_execpath = require.main ? require.main.filename : process.cwd() ++ env.npm_execpath = process.argv[1] ?? process.cwd() + } + env.INIT_CWD = process.cwd() + env.npm_config_node_gyp = env.npm_config_node_gyp || DEFAULT_NODE_GYP_PATH diff --git a/__typings__/local.d.ts b/__typings__/local.d.ts index 0ba3e2d5b3..907abf879b 100644 --- a/__typings__/local.d.ts +++ b/__typings__/local.d.ts @@ -29,10 +29,15 @@ declare module '@pnpm/npm-conf' { export = anything } -declare module '@pnpm/npm-conf/lib/util' { +declare module '@pnpm/npm-conf/lib/util.js' { export function parseField (types: any, field: string, value: any): unknown } +declare module '@pnpm/npm-conf/lib/conf' { + const anything: any + export = anything +} + declare module '@pnpm/npm-lifecycle' { const anything: any export = anything @@ -104,6 +109,10 @@ declare module 'read-package-json' { export = anything } +declare module 'split-cmd/index.modern.mjs' { + export function split (command: string): string[] +} + declare module 'stacktracey' { const anything: any export = anything diff --git a/__typings__/typed.d.ts b/__typings__/typed.d.ts index 61898e2f29..f011661b36 100644 --- a/__typings__/typed.d.ts +++ b/__typings__/typed.d.ts @@ -64,7 +64,7 @@ declare module 'strip-comments-strings' { str: string, replacer?: CodeItemReplacer): string } -declare module 'bin-links/lib/fix-bin' { +declare module 'bin-links/lib/fix-bin.js' { function fixBin (path: string, execMode: number): Promise export = fixBin } diff --git a/__utils__/assert-project/package.json b/__utils__/assert-project/package.json index 3788bfe74a..01ce92cf39 100644 --- a/__utils__/assert-project/package.json +++ b/__utils__/assert-project/package.json @@ -11,6 +11,7 @@ "url": "https://github.com/pnpm/pnpm/issues" }, "main": "lib/index.js", + "type": "module", "types": "lib/index.d.ts", "files": [ "lib/" diff --git a/__utils__/assert-project/src/index.ts b/__utils__/assert-project/src/index.ts index c08d6cb5c2..a1e47d9416 100644 --- a/__utils__/assert-project/src/index.ts +++ b/__utils__/assert-project/src/index.ts @@ -1,6 +1,7 @@ import fs from 'fs' import path from 'path' import util from 'util' +import { createRequire } from 'module' import { assertStore } from '@pnpm/assert-store' import { WANTED_LOCKFILE } from '@pnpm/constants' import { type LockfileFile } from '@pnpm/lockfile.types' @@ -10,6 +11,8 @@ import { sync as readYamlFile } from 'read-yaml-file' import writePkg from 'write-pkg' import isExecutable from './isExecutable.js' +const require = createRequire(import.meta.url) + export { isExecutable, type Modules } export interface Project { @@ -88,7 +91,6 @@ export function assertProject (projectPath: string, encodedRegistryName?: string return { dir: () => projectPath, requireModule (pkgName: string) { - // eslint-disable-next-line return require(path.join(modules, pkgName)) }, has (pkgName: string, _modulesDir?: string) { diff --git a/__utils__/assert-project/src/isExecutable.ts b/__utils__/assert-project/src/isExecutable.ts index adb01deef6..af29400f62 100644 --- a/__utils__/assert-project/src/isExecutable.ts +++ b/__utils__/assert-project/src/isExecutable.ts @@ -1,13 +1,13 @@ import fs from 'fs' import isWindows from 'is-windows' -import { sync as isexe } from 'isexe' +import isExe from 'isexe' const IS_WINDOWS = isWindows() // eslint-disable-next-line export default (ok: (value: any, comment: string) => void, filePath: string): void => { if (IS_WINDOWS) { - ok(isexe(`${filePath}.cmd`), `${filePath}.cmd is executable`) + ok(isExe.sync(`${filePath}.cmd`), `${filePath}.cmd is executable`) return } diff --git a/__utils__/assert-project/test/index.ts b/__utils__/assert-project/test/index.ts index 281afd38ad..5ac2d0c0c3 100644 --- a/__utils__/assert-project/test/index.ts +++ b/__utils__/assert-project/test/index.ts @@ -3,7 +3,7 @@ import path from 'path' import { assertProject } from '../src/index.js' test('assertProject()', async () => { - const project = assertProject(path.join(__dirname, '../../..')) + const project = assertProject(path.join(import.meta.dirname, '../../..')) project.has('rimraf') project.hasNot('sfdsff3g34') // cspell:disable-line @@ -12,7 +12,7 @@ test('assertProject()', async () => { }) test('assertProject() store functions', async () => { - const project = assertProject(path.join(__dirname, 'fixture/project'), 'registry.npmjs.org') + const project = assertProject(path.join(import.meta.dirname, 'fixture/project'), 'registry.npmjs.org') expect(typeof project.getStorePath()).toBe('string') project.storeHas('is-positive', '3.1.0') diff --git a/__utils__/assert-project/test/tsconfig.json b/__utils__/assert-project/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/__utils__/assert-project/test/tsconfig.json +++ b/__utils__/assert-project/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/__utils__/assert-store/package.json b/__utils__/assert-store/package.json index 3031e3869c..e6f3c239cb 100644 --- a/__utils__/assert-store/package.json +++ b/__utils__/assert-store/package.json @@ -6,6 +6,7 @@ "url": "https://github.com/pnpm/pnpm/issues" }, "main": "lib/index.js", + "type": "module", "types": "lib/index.d.ts", "files": [ "lib/" diff --git a/__utils__/assert-store/test/index.ts b/__utils__/assert-store/test/index.ts index 9dbc614b45..e754a7cae7 100644 --- a/__utils__/assert-store/test/index.ts +++ b/__utils__/assert-store/test/index.ts @@ -4,7 +4,7 @@ import { assertStore } from '@pnpm/assert-store' import { STORE_VERSION } from '@pnpm/constants' test('assertStore() store assertions', async () => { - const storePath = path.join(__dirname, `fixture/store/${STORE_VERSION}/`) + const storePath = path.join(import.meta.dirname, `fixture/store/${STORE_VERSION}/`) const encodedRegistryName = 'registry.npmjs.org' const store = assertStore(storePath, encodedRegistryName) @@ -14,7 +14,7 @@ test('assertStore() store assertions', async () => { }) test('assertStore() resolve', async () => { - const storePath = path.join(__dirname, `fixture/store/${STORE_VERSION}/`) + const storePath = path.join(import.meta.dirname, `fixture/store/${STORE_VERSION}/`) const encodedRegistryName = 'registry.npmjs.org' const store = assertStore(storePath, encodedRegistryName) diff --git a/__utils__/assert-store/test/tsconfig.json b/__utils__/assert-store/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/__utils__/assert-store/test/tsconfig.json +++ b/__utils__/assert-store/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/__utils__/build-artifacts/main.mjs b/__utils__/build-artifacts/main.mjs index 8c114f303f..55897fd2e0 100644 --- a/__utils__/build-artifacts/main.mjs +++ b/__utils__/build-artifacts/main.mjs @@ -4,16 +4,14 @@ import pkgDeb from 'pkg-deb' import pkgRhel from 'pkg-rpm' import { fileURLToPath } from 'url' -const __dirname = path.dirname(fileURLToPath(import.meta.url)) - -const artifactDir = path.join(__dirname, '../../packages/artifacts/linux-x64') -const pnpmDir = path.join(__dirname, '../../packages/pnpm') +const artifactDir = path.join(import.meta.dirname, '../../packages/artifacts/linux-x64') +const pnpmDir = path.join(import.meta.dirname, '../../packages/pnpm') const pnpmManifest = JSON.parse(fs.readFileSync(path.join(pnpmDir, 'package.json'), 'utf8')) const opts = { name: 'pnpm', version: pnpmManifest.version, - dest: path.join(__dirname, '../../dist'), + dest: path.join(import.meta.dirname, '../../dist'), src: pnpmDir, input: path.join(artifactDir, 'pnpm'), arch: 'x64', diff --git a/__utils__/eslint-config/index.js b/__utils__/eslint-config/index.js index 5342219f1a..9dfc66a46f 100644 --- a/__utils__/eslint-config/index.js +++ b/__utils__/eslint-config/index.js @@ -1,14 +1,10 @@ -import path from 'node:path' -import { fileURLToPath } from 'node:url' import js from '@eslint/js' import { FlatCompat } from '@eslint/eslintrc' import noDupeConditions from './no-dupe-conditions.js' import jestPlugin from 'eslint-plugin-jest' -const __filename = fileURLToPath(import.meta.url) -const __dirname = path.dirname(__filename) const compat = new FlatCompat({ - baseDirectory: __dirname, + baseDirectory: import.meta.dirname, recommendedConfig: js.configs.recommended, allConfig: js.configs.all }) diff --git a/__utils__/get-release-text/tsconfig.json b/__utils__/get-release-text/tsconfig.json index 82729a5304..10b292db62 100644 --- a/__utils__/get-release-text/tsconfig.json +++ b/__utils__/get-release-text/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "lib", "rootDir": "src", - "module": "ES2020" + "module": "nodenext" }, "include": [ "src/**/*.ts", diff --git a/__utils__/jest-config/config.js b/__utils__/jest-config/config.js index dcd6db2bab..615f4b1f28 100644 --- a/__utils__/jest-config/config.js +++ b/__utils__/jest-config/config.js @@ -1,15 +1,21 @@ -const path = require('path') +import path from 'path' const config = { - preset: "ts-jest", - resolver: path.join(__dirname, 'node_modules/ts-jest-resolver'), + preset: "ts-jest/presets/default-esm", + resolver: path.join(import.meta.dirname, 'node_modules/ts-jest-resolver'), + globals: { + 'ts-jest': { + useESM: true, + }, + }, + extensionsToTreatAsEsm: ['.ts'], transform: { '^.+\\.tsx?$': ['ts-jest', { // For most projects, the tsconfig.json and test/tsconfig.json are almost // exactly the same. But it's more correct to point to test/tsconfig.json // to prevent surprises in the future. tsconfig: 'test/tsconfig.json' - }] + }], }, testMatch: ["**/test/**/*.[jt]s?(x)", "**/src/**/*.test.ts"], testEnvironment: "node", @@ -18,14 +24,14 @@ const config = { testPathIgnorePatterns: ["/fixtures/", "/__fixtures__/", "/test/utils/.+"], modulePathIgnorePatterns: ['\/__fixtures__\/.*'], testTimeout: 4 * 60 * 1000, // 4 minutes - setupFilesAfterEnv: [path.join(__dirname, "setupFilesAfterEnv.js")], + setupFilesAfterEnv: [path.join(import.meta.dirname, "setupFilesAfterEnv.js")], maxWorkers: "50%", } if (process.env.PNPM_SCRIPT_SRC_DIR) { const pathAsArr = process.env.PNPM_SCRIPT_SRC_DIR.split(path.sep) const packageName = pathAsArr[pathAsArr.length - 1] - config.cacheDirectory = path.join(__dirname, ".jest-cache", packageName) + config.cacheDirectory = path.join(import.meta.dirname, ".jest-cache", packageName) } // We are running test script from pnpm command, this seems to confuse tests @@ -36,4 +42,4 @@ for (const key of Object.keys(process.env)) { } } -module.exports = config +export default config diff --git a/__utils__/jest-config/jest-preset.js b/__utils__/jest-config/jest-preset.js index 78c007ea2d..f74e0a4c05 100644 --- a/__utils__/jest-config/jest-preset.js +++ b/__utils__/jest-config/jest-preset.js @@ -1,4 +1,3 @@ -const path = require('path') -const baseConfig = require('./config') +import baseConfig from './config.js' -module.exports = baseConfig +export default baseConfig diff --git a/__utils__/jest-config/package.json b/__utils__/jest-config/package.json index 3a63f9b269..fc85542b64 100644 --- a/__utils__/jest-config/package.json +++ b/__utils__/jest-config/package.json @@ -3,6 +3,7 @@ "version": "1000.0.0", "private": true, "main": "jest-preset.js", + "type": "module", "dependencies": { "@pnpm/registry-mock": "catalog:", "@pnpm/worker": "workspace:*", diff --git a/__utils__/jest-config/setupFilesAfterEnv.js b/__utils__/jest-config/setupFilesAfterEnv.js index e1cd7b713f..4b5ea4f6d6 100644 --- a/__utils__/jest-config/setupFilesAfterEnv.js +++ b/__utils__/jest-config/setupFilesAfterEnv.js @@ -1,4 +1,4 @@ -const { finishWorkers } = require('@pnpm/worker') +import { finishWorkers } from '@pnpm/worker' afterAll(async () => { await finishWorkers() diff --git a/__utils__/jest-config/with-registry/globalSetup.js b/__utils__/jest-config/with-registry/globalSetup.js index a837ba6163..19f80a75a8 100644 --- a/__utils__/jest-config/with-registry/globalSetup.js +++ b/__utils__/jest-config/with-registry/globalSetup.js @@ -1,12 +1,13 @@ -const getPort = require('get-port') -const { promisify } = require('util') -const kill = promisify(require('tree-kill')) +import getPort from 'get-port' +import { promisify } from 'util' +import treeKill from 'tree-kill' +const kill = promisify(treeKill) -module.exports = async () => { +export default async () => { if (!process.env.PNPM_REGISTRY_MOCK_PORT) { process.env.PNPM_REGISTRY_MOCK_PORT = (await getPort({ port: getPort.makeRange(7700, 7800) })).toString() } - const { start, prepare } = require('@pnpm/registry-mock') + const { start, prepare } = await import('@pnpm/registry-mock') prepare() const server = start({ // Verdaccio stopped working properly on Node.js 22. diff --git a/__utils__/jest-config/with-registry/globalTeardown.js b/__utils__/jest-config/with-registry/globalTeardown.js index f4c62b9c15..35a2488f41 100644 --- a/__utils__/jest-config/with-registry/globalTeardown.js +++ b/__utils__/jest-config/with-registry/globalTeardown.js @@ -1,3 +1,3 @@ -module.exports = () => { +export default () => { return global.killServer?.() } diff --git a/__utils__/jest-config/with-registry/jest-preset.js b/__utils__/jest-config/with-registry/jest-preset.js index b096f74809..52ec2fbd1a 100644 --- a/__utils__/jest-config/with-registry/jest-preset.js +++ b/__utils__/jest-config/with-registry/jest-preset.js @@ -1,12 +1,12 @@ -const path = require('path') -const baseConfig = require('./../config') +import path from 'path' +import baseConfig from './../config.js' -module.exports = { +export default { ...baseConfig, // Many tests change the dist tags of packages. // Unfortunately, this means that if two such tests will run at the same time, // they may break each other. maxWorkers: 1, - globalSetup: path.join(__dirname, 'globalSetup.js'), - globalTeardown: path.join(__dirname, 'globalTeardown.js'), + globalSetup: path.join(import.meta.dirname, 'globalSetup.js'), + globalTeardown: path.join(import.meta.dirname, 'globalTeardown.js'), } diff --git a/__utils__/prepare-temp-dir/package.json b/__utils__/prepare-temp-dir/package.json index 2ba92d469b..04df49a1f2 100644 --- a/__utils__/prepare-temp-dir/package.json +++ b/__utils__/prepare-temp-dir/package.json @@ -2,6 +2,7 @@ "name": "@pnpm/prepare-temp-dir", "version": "1000.0.0", "main": "lib/index.js", + "type": "module", "types": "lib/index.d.ts", "devDependencies": { "@pnpm/prepare-temp-dir": "workspace:*", diff --git a/__utils__/prepare-temp-dir/src/index.ts b/__utils__/prepare-temp-dir/src/index.ts index 9404b4a386..6e1a255ea2 100644 --- a/__utils__/prepare-temp-dir/src/index.ts +++ b/__utils__/prepare-temp-dir/src/index.ts @@ -3,7 +3,7 @@ import path from 'path' // The testing folder should be outside of the project to avoid lookup in the project's node_modules // Not using the OS temp directory due to issues on Windows CI. -const tmpBaseDir = path.join(__dirname, '../../../../pnpm_tmp') +const tmpBaseDir = path.join(import.meta.dirname, '../../../../pnpm_tmp') const tmpPath = path.join(tmpBaseDir, `${getFilesCountInDir(tmpBaseDir).toString()}_${process.pid.toString()}`) diff --git a/__utils__/prepare/package.json b/__utils__/prepare/package.json index 32fd06f32b..be484de609 100644 --- a/__utils__/prepare/package.json +++ b/__utils__/prepare/package.json @@ -3,6 +3,7 @@ "version": "1000.0.0", "main": "lib/index.js", "types": "lib/index.d.ts", + "type": "module", "dependencies": { "@pnpm/assert-project": "workspace:*", "@pnpm/prepare-temp-dir": "workspace:*", diff --git a/__utils__/scripts/package.json b/__utils__/scripts/package.json index a8bb670b1f..fa772101eb 100644 --- a/__utils__/scripts/package.json +++ b/__utils__/scripts/package.json @@ -2,6 +2,7 @@ "name": "@pnpm/scripts", "version": "1000.0.0", "private": true, + "type": "module", "dependencies": { "@pnpm/workspace.find-packages": "catalog:", "@pnpm/workspace.read-manifest": "catalog:", diff --git a/__utils__/scripts/src/copy-artifacts.ts b/__utils__/scripts/src/copy-artifacts.ts index 6ba12a7f25..61020627c7 100644 --- a/__utils__/scripts/src/copy-artifacts.ts +++ b/__utils__/scripts/src/copy-artifacts.ts @@ -3,7 +3,7 @@ import * as execa from 'execa' import path from 'path' import makeEmptyDir from 'make-empty-dir' -const repoRoot = path.join(__dirname, '../../..') +const repoRoot = path.join(import.meta.dirname, '../../..') const dest = path.join(repoRoot, 'dist') const artifactsDir = path.join(repoRoot, 'pnpm/artifacts') diff --git a/__utils__/scripts/src/typecheck-only.ts b/__utils__/scripts/src/typecheck-only.ts index d5d161cca2..0909583a7a 100644 --- a/__utils__/scripts/src/typecheck-only.ts +++ b/__utils__/scripts/src/typecheck-only.ts @@ -7,9 +7,9 @@ import glob from 'fast-glob' import normalizePath from 'normalize-path' import path from 'path' -const repoRoot = path.resolve(__dirname, '../../../') +const repoRoot = path.resolve(import.meta.dirname, '../../../') const typeCheckDir = path.resolve(repoRoot, '__typecheck__') -const typingsDir = path.resolve(__dirname, '__typings__') +const typingsDir = path.resolve(import.meta.dirname, '__typings__') async function main (): Promise { const workspace = await readWorkspaceManifest(repoRoot) diff --git a/__utils__/test-fixtures/package.json b/__utils__/test-fixtures/package.json index bedfe77892..0dcb39c79c 100644 --- a/__utils__/test-fixtures/package.json +++ b/__utils__/test-fixtures/package.json @@ -11,6 +11,7 @@ "url": "https://github.com/pnpm/pnpm/issues" }, "main": "lib/index.js", + "type": "module", "types": "lib/index.d.ts", "files": [ "lib/" diff --git a/__utils__/test-ipc-server/bin/test-ipc-server-client.js b/__utils__/test-ipc-server/bin/test-ipc-server-client.js index b68329d0fa..0a9f59b688 100755 --- a/__utils__/test-ipc-server/bin/test-ipc-server-client.js +++ b/__utils__/test-ipc-server/bin/test-ipc-server-client.js @@ -1,2 +1,2 @@ #!/usr/bin/env node -require('../lib/clientBin') +import {} from '../lib/clientBin.js' diff --git a/__utils__/test-ipc-server/package.json b/__utils__/test-ipc-server/package.json index d94683dd5a..cd23bd7d95 100644 --- a/__utils__/test-ipc-server/package.json +++ b/__utils__/test-ipc-server/package.json @@ -3,6 +3,7 @@ "version": "1000.0.0", "private": true, "main": "lib/index.js", + "type": "module", "types": "lib/index.d.ts", "bin": { "test-ipc-server-client": "./bin/test-ipc-server-client.js" @@ -16,10 +17,13 @@ "scripts": { "lint": "eslint src/**/*.ts test/**/*.ts", "compile": "rimraf tsconfig.tsbuildinfo lib && tsc --build", - "test": "pnpm run compile && jest" + "test": "pnpm run compile && cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "keywords": [ "pnpm", "pnpm10" - ] + ], + "jest": { + "preset": "@pnpm/jest-config" + } } diff --git a/__utils__/test-ipc-server/test/TestIpcServer.test.ts b/__utils__/test-ipc-server/test/TestIpcServer.test.ts index f221793b18..dd383284aa 100644 --- a/__utils__/test-ipc-server/test/TestIpcServer.test.ts +++ b/__utils__/test-ipc-server/test/TestIpcServer.test.ts @@ -1,14 +1,14 @@ /// -import execa from 'execa' import fs from 'fs' import net from 'net' import path from 'path' +import execa from 'execa' import { setTimeout } from 'timers/promises' import { promisify } from 'util' import { prepare } from '@pnpm/prepare' import { createTestIpcServer } from '@pnpm/test-ipc-server' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') describe('TestEchoServer', () => { describe('lifecycle', () => { diff --git a/__utils__/test-ipc-server/test/tsconfig.json b/__utils__/test-ipc-server/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/__utils__/test-ipc-server/test/tsconfig.json +++ b/__utils__/test-ipc-server/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/__utils__/tsconfig/tsconfig.json b/__utils__/tsconfig/tsconfig.json index 3ea46e3dd4..062b7cebf1 100644 --- a/__utils__/tsconfig/tsconfig.json +++ b/__utils__/tsconfig/tsconfig.json @@ -4,8 +4,8 @@ "composite": true, "declaration": true, "esModuleInterop": true, - "module": "commonjs", - "moduleResolution": "node", + "module": "nodenext", + "moduleResolution": "nodenext", "noImplicitAny": true, "noImplicitReturns": true, "preserveConstEnums": true, diff --git a/cache/api/package.json b/cache/api/package.json index 963b2cd16b..6cc00d5033 100644 --- a/cache/api/package.json +++ b/cache/api/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/cache/commands/package.json b/cache/commands/package.json index 247ac26557..b7bc90f621 100644 --- a/cache/commands/package.json +++ b/cache/commands/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/cache/commands/src/cache.cmd.ts b/cache/commands/src/cache.cmd.ts index ec02eea3c5..75539b58ad 100644 --- a/cache/commands/src/cache.cmd.ts +++ b/cache/commands/src/cache.cmd.ts @@ -3,7 +3,7 @@ import { docsUrl } from '@pnpm/cli-utils' import { type Config, types as allTypes } from '@pnpm/config' import { FULL_FILTERED_META_DIR, ABBREVIATED_META_DIR } from '@pnpm/constants' import { getStorePath } from '@pnpm/store-path' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { cacheList, diff --git a/cache/commands/test/cacheDelete.cmd.test.ts b/cache/commands/test/cacheDelete.cmd.test.ts index b05a9cae44..7b5f4779f7 100644 --- a/cache/commands/test/cacheDelete.cmd.test.ts +++ b/cache/commands/test/cacheDelete.cmd.test.ts @@ -5,7 +5,7 @@ import execa from 'execa' import { cache } from '@pnpm/cache.commands' import { sync as rimraf } from '@zkochan/rimraf' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}/` describe('cache delete', () => { diff --git a/cache/commands/test/cacheList.cmd.test.ts b/cache/commands/test/cacheList.cmd.test.ts index 30ec74f296..cec0f7ebda 100644 --- a/cache/commands/test/cacheList.cmd.test.ts +++ b/cache/commands/test/cacheList.cmd.test.ts @@ -5,7 +5,7 @@ import execa from 'execa' import { cache } from '@pnpm/cache.commands' import { sync as rimraf } from '@zkochan/rimraf' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}/` describe('cache', () => { diff --git a/cache/commands/test/cacheView.cmd.test.ts b/cache/commands/test/cacheView.cmd.test.ts index 66e91af1b8..6821e8e687 100644 --- a/cache/commands/test/cacheView.cmd.test.ts +++ b/cache/commands/test/cacheView.cmd.test.ts @@ -5,7 +5,7 @@ import execa from 'execa' import { cache } from '@pnpm/cache.commands' import { sync as rimraf } from '@zkochan/rimraf' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}/` describe('cache view', () => { diff --git a/cache/commands/test/tsconfig.json b/cache/commands/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/cache/commands/test/tsconfig.json +++ b/cache/commands/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/catalogs/config/package.json b/catalogs/config/package.json index 2240d34531..d67421418e 100644 --- a/catalogs/config/package.json +++ b/catalogs/config/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -29,7 +29,7 @@ "compile": "tsc --build && pnpm run lint --fix", "prepublishOnly": "pnpm run compile", "test": "pnpm run compile && pnpm run _test", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/error": "workspace:*" diff --git a/catalogs/config/test/tsconfig.json b/catalogs/config/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/catalogs/config/test/tsconfig.json +++ b/catalogs/config/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/catalogs/protocol-parser/package.json b/catalogs/protocol-parser/package.json index 8bc686fa2f..a58fd68afc 100644 --- a/catalogs/protocol-parser/package.json +++ b/catalogs/protocol-parser/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -29,7 +29,7 @@ "compile": "tsc --build && pnpm run lint --fix", "prepublishOnly": "pnpm run compile", "test": "pnpm run compile && pnpm run _test", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "devDependencies": { "@pnpm/catalogs.protocol-parser": "workspace:*" diff --git a/catalogs/protocol-parser/test/tsconfig.json b/catalogs/protocol-parser/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/catalogs/protocol-parser/test/tsconfig.json +++ b/catalogs/protocol-parser/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/catalogs/resolver/package.json b/catalogs/resolver/package.json index 3ec1db3a53..2a4b1b7e6c 100644 --- a/catalogs/resolver/package.json +++ b/catalogs/resolver/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -29,7 +29,7 @@ "compile": "tsc --build && pnpm run lint --fix", "prepublishOnly": "pnpm run compile", "test": "pnpm run compile && pnpm run _test", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/catalogs.protocol-parser": "workspace:^", diff --git a/catalogs/resolver/test/tsconfig.json b/catalogs/resolver/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/catalogs/resolver/test/tsconfig.json +++ b/catalogs/resolver/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/catalogs/types/package.json b/catalogs/types/package.json index 3d5ea77ee1..1d0ce7ca2e 100644 --- a/catalogs/types/package.json +++ b/catalogs/types/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/cli/cli-meta/package.json b/cli/cli-meta/package.json index 975e56a42a..f4942cc0d2 100644 --- a/cli/cli-meta/package.json +++ b/cli/cli-meta/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/types": "workspace:*", diff --git a/cli/cli-meta/src/index.ts b/cli/cli-meta/src/index.ts index 06e68f5a34..3c065e9cd9 100644 --- a/cli/cli-meta/src/index.ts +++ b/cli/cli-meta/src/index.ts @@ -1,7 +1,3 @@ -import path from 'path' -import { type DependencyManifest } from '@pnpm/types' -import loadJsonFile from 'load-json-file' - const defaultManifest = { name: process.env.npm_package_name != null && process.env.npm_package_name !== '' ? process.env.npm_package_name @@ -10,21 +6,7 @@ const defaultManifest = { ? process.env.npm_package_version : '0.0.0', } -let pkgJson -if (require.main == null) { - pkgJson = defaultManifest -} else { - try { - pkgJson = { - ...defaultManifest, - ...loadJsonFile.sync( - path.join(path.dirname(require.main.filename), '../package.json') - ), - } - } catch { - pkgJson = defaultManifest - } -} +const pkgJson = defaultManifest export const packageManager = { name: pkgJson.name, diff --git a/cli/cli-meta/test/tsconfig.json b/cli/cli-meta/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/cli/cli-meta/test/tsconfig.json +++ b/cli/cli-meta/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/cli/cli-utils/package.json b/cli/cli-utils/package.json index 028ea622ba..b65181663e 100644 --- a/cli/cli-utils/package.json +++ b/cli/cli-utils/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", "test": "pnpm run compile && pnpm run _test", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/cli-meta": "workspace:*", diff --git a/cli/cli-utils/test/tsconfig.json b/cli/cli-utils/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/cli/cli-utils/test/tsconfig.json +++ b/cli/cli-utils/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/cli/command/package.json b/cli/command/package.json index fbea519750..ae6d6384b3 100644 --- a/cli/command/package.json +++ b/cli/command/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/cli/common-cli-options-help/package.json b/cli/common-cli-options-help/package.json index 44954061d4..1c322dbcfb 100644 --- a/cli/common-cli-options-help/package.json +++ b/cli/common-cli-options-help/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/cli/default-reporter/package.json b/cli/default-reporter/package.json index a4d029ac3d..baadca6e60 100644 --- a/cli/default-reporter/package.json +++ b/cli/default-reporter/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "just-test-preview": "ts-node test --type-check", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/cli/default-reporter/src/reportError.ts b/cli/default-reporter/src/reportError.ts index b6a9b144b3..487147fbe4 100644 --- a/cli/default-reporter/src/reportError.ts +++ b/cli/default-reporter/src/reportError.ts @@ -6,7 +6,7 @@ import { type PnpmError } from '@pnpm/error' import { renderPeerIssues } from '@pnpm/render-peer-issues' import { type PeerDependencyIssuesByProjects } from '@pnpm/types' import chalk from 'chalk' -import equals from 'ramda/src/equals' +import { equals } from 'ramda' import StackTracey from 'stacktracey' import { EOL } from './constants.js' diff --git a/cli/default-reporter/src/reporterForClient/pkgsDiff.ts b/cli/default-reporter/src/reporterForClient/pkgsDiff.ts index b6d10f20a3..7bf9c7b6c6 100644 --- a/cli/default-reporter/src/reporterForClient/pkgsDiff.ts +++ b/cli/default-reporter/src/reporterForClient/pkgsDiff.ts @@ -2,8 +2,7 @@ import type * as logs from '@pnpm/core-loggers' import { type BaseManifest } from '@pnpm/types' import * as Rx from 'rxjs' import { filter, map, mapTo, reduce, scan, startWith, take } from 'rxjs/operators' -import mergeRight from 'ramda/src/mergeRight' -import difference from 'ramda/src/difference' +import { mergeRight, difference } from 'ramda' export interface PackageDiff { added: boolean diff --git a/cli/default-reporter/src/reporterForClient/reportStats.ts b/cli/default-reporter/src/reporterForClient/reportStats.ts index 467787bb26..ba5bc61693 100644 --- a/cli/default-reporter/src/reporterForClient/reportStats.ts +++ b/cli/default-reporter/src/reporterForClient/reportStats.ts @@ -2,7 +2,7 @@ import { type StatsLog } from '@pnpm/core-loggers' import * as Rx from 'rxjs' import { filter, take, reduce, map } from 'rxjs/operators' import chalk from 'chalk' -import repeat from 'ramda/src/repeat' +import { repeat } from 'ramda' import stringLength from 'string-length' import { EOL } from '../constants.js' import { diff --git a/cli/default-reporter/test/index.ts b/cli/default-reporter/test/index.ts index 16b875668f..ea6435bc44 100644 --- a/cli/default-reporter/test/index.ts +++ b/cli/default-reporter/test/index.ts @@ -21,7 +21,7 @@ import { map, skip, take } from 'rxjs/operators' import chalk from 'chalk' import normalizeNewline from 'normalize-newline' import { firstValueFrom } from 'rxjs' -import repeat from 'ramda/src/repeat' +import { repeat } from 'ramda' import { formatWarn } from '../src/reporterForClient/utils/formatWarn.js' const formatErrorCode = (code: string) => chalk.bgRed.black(`\u2009${code}\u2009`) diff --git a/cli/default-reporter/test/reportingErrors.ts b/cli/default-reporter/test/reportingErrors.ts index b4b7549d10..a7c61bbc3f 100644 --- a/cli/default-reporter/test/reportingErrors.ts +++ b/cli/default-reporter/test/reportingErrors.ts @@ -68,7 +68,7 @@ test('prints no matching version error when many dist-tags exist', async () => { expect.assertions(1) const err = Object.assign(new PnpmError('NO_MATCHING_VERSION', 'No matching version found for pnpm@1000.0.0'), { - packageMeta: loadJsonFile.sync(path.join(__dirname, 'pnpm-meta.json')), + packageMeta: loadJsonFile.sync(path.join(import.meta.dirname, 'pnpm-meta.json')), }) logger.error(err, err) @@ -94,7 +94,7 @@ test('prints no matching version error when only the latest dist-tag exists', as expect.assertions(1) const err = Object.assign(new PnpmError('NO_MATCHING_VERSION', 'No matching version found for is-positive@1000.0.0'), { - packageMeta: loadJsonFile.sync(path.join(__dirname, 'is-positive-meta.json')), + packageMeta: loadJsonFile.sync(path.join(import.meta.dirname, 'is-positive-meta.json')), }) logger.error(err, err) diff --git a/cli/default-reporter/test/tsconfig.json b/cli/default-reporter/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/cli/default-reporter/test/tsconfig.json +++ b/cli/default-reporter/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/cli/parse-cli-args/package.json b/cli/parse-cli-args/package.json index 9ee3f45c33..490dd3e311 100644 --- a/cli/parse-cli-args/package.json +++ b/cli/parse-cli-args/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "start": "tsc --watch", diff --git a/cli/parse-cli-args/test/tsconfig.json b/cli/parse-cli-args/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/cli/parse-cli-args/test/tsconfig.json +++ b/cli/parse-cli-args/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/completion/plugin-commands-completion/package.json b/completion/plugin-commands-completion/package.json index dec4c1f697..8714f639d3 100644 --- a/completion/plugin-commands-completion/package.json +++ b/completion/plugin-commands-completion/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ "scripts": { "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/completion/plugin-commands-completion/src/completionServer.ts b/completion/plugin-commands-completion/src/completionServer.ts index e23e587864..0d8f931f09 100644 --- a/completion/plugin-commands-completion/src/completionServer.ts +++ b/completion/plugin-commands-completion/src/completionServer.ts @@ -1,6 +1,6 @@ import { type CompletionItem, getShellFromEnv } from '@pnpm/tabtab' import { type CompletionFunc } from '@pnpm/command' -import { split as splitCmd } from 'split-cmd' +import { split as splitCmd } from 'split-cmd/index.modern.mjs' import tabtab from '@pnpm/tabtab' import { currentTypedWordType, diff --git a/completion/plugin-commands-completion/src/getOptionType.ts b/completion/plugin-commands-completion/src/getOptionType.ts index 843aeacd8d..214872a7a3 100644 --- a/completion/plugin-commands-completion/src/getOptionType.ts +++ b/completion/plugin-commands-completion/src/getOptionType.ts @@ -1,5 +1,5 @@ import nopt from '@pnpm/nopt' -import omit from 'ramda/src/omit' +import { omit } from 'ramda' export interface CompletionCtx { last: string diff --git a/completion/plugin-commands-completion/test/tsconfig.json b/completion/plugin-commands-completion/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/completion/plugin-commands-completion/test/tsconfig.json +++ b/completion/plugin-commands-completion/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/config/config-writer/package.json b/config/config-writer/package.json index d3c3f4f011..59ff7c91ac 100644 --- a/config/config-writer/package.json +++ b/config/config-writer/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/config/config-writer/src/index.ts b/config/config-writer/src/index.ts index 2b8052e090..7832ab4218 100644 --- a/config/config-writer/src/index.ts +++ b/config/config-writer/src/index.ts @@ -1,7 +1,7 @@ import { type ProjectManifest, type PnpmSettings } from '@pnpm/types' import { tryReadProjectManifest } from '@pnpm/read-project-manifest' import { updateWorkspaceManifest } from '@pnpm/workspace.manifest-writer' -import equals from 'ramda/src/equals' +import { equals } from 'ramda' export interface WriteSettingsOptions { updatedSettings: PnpmSettings diff --git a/config/config/package.json b/config/config/package.json index 0c12b17afd..452767be47 100644 --- a/config/config/package.json +++ b/config/config/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "prepublishOnly": "pnpm run compile", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "test-with-preview": "ts-node test", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "start": "tsc --watch", "compile": "tsc --build && pnpm run lint --fix" diff --git a/config/config/src/getOptionsFromRootManifest.ts b/config/config/src/getOptionsFromRootManifest.ts index ba16aa3414..eded043678 100644 --- a/config/config/src/getOptionsFromRootManifest.ts +++ b/config/config/src/getOptionsFromRootManifest.ts @@ -9,9 +9,7 @@ import { type ProjectManifest, type PnpmSettings, } from '@pnpm/types' -import mapValues from 'ramda/src/map' -import omit from 'ramda/src/omit' -import pick from 'ramda/src/pick' +import { map as mapValues, omit, pick } from 'ramda' import { globalWarn } from '@pnpm/logger' export type OptionsFromRootManifest = { diff --git a/config/config/src/index.ts b/config/config/src/index.ts index ac2ddb5195..19258b9516 100644 --- a/config/config/src/index.ts +++ b/config/config/src/index.ts @@ -216,7 +216,7 @@ export async function getConfig (opts: { if (warn) warnings.push(warn) } { - const warn = npmConfig.addFile(path.resolve(path.join(__dirname, 'pnpmrc')), 'pnpm-builtin') + const warn = npmConfig.addFile(path.resolve(path.join(import.meta.dirname, 'pnpmrc')), 'pnpm-builtin') if (warn) warnings.push(warn) } diff --git a/config/config/src/readLocalConfig.ts b/config/config/src/readLocalConfig.ts index 7212e75ebe..45cea08480 100644 --- a/config/config/src/readLocalConfig.ts +++ b/config/config/src/readLocalConfig.ts @@ -3,7 +3,7 @@ import util from 'util' import camelcaseKeys from 'camelcase-keys' import { envReplace } from '@pnpm/config.env-replace' import { readIniFile } from 'read-ini-file' -import { parseField } from '@pnpm/npm-conf/lib/util' +import { parseField } from '@pnpm/npm-conf/lib/util.js' import { types } from './types.js' export type LocalConfig = Record & { hoist?: boolean } diff --git a/config/config/src/types.ts b/config/config/src/types.ts index 6c90dd73cc..ffa6a085b1 100644 --- a/config/config/src/types.ts +++ b/config/config/src/types.ts @@ -1,4 +1,4 @@ -import npmTypes from '@pnpm/npm-conf/lib/types' +import npmTypes from '@pnpm/npm-conf/lib/types.js' export const types = Object.assign({ 'auto-install-peers': Boolean, diff --git a/config/config/test/concurrency.test.ts b/config/config/test/concurrency.test.ts index 5054993b75..77ae013693 100644 --- a/config/config/test/concurrency.test.ts +++ b/config/config/test/concurrency.test.ts @@ -1,5 +1,5 @@ -import os, { cpus } from 'os' import { jest } from '@jest/globals' +import os, { cpus } from 'os' import { getDefaultWorkspaceConcurrency, resetAvailableParallelismCache, getWorkspaceConcurrency } from '../lib/concurrency.js' const hostCores = cpus().length diff --git a/config/config/test/globalBinDir.test.ts b/config/config/test/globalBinDir.test.ts index 7b6ee85fd4..e21dbba69b 100644 --- a/config/config/test/globalBinDir.test.ts +++ b/config/config/test/globalBinDir.test.ts @@ -6,7 +6,6 @@ import path from 'path' import pathName from 'path-name' import symlinkDir from 'symlink-dir' import { homedir } from 'os' -import { getConfig } from '@pnpm/config' const globalBinDir = path.join(homedir(), '.local', 'pnpm') const isWindows = process.platform === 'win32' @@ -19,8 +18,8 @@ jest.mock('@pnpm/npm-conf/lib/conf', () => { constructor (base: any, types: any) { super(base, types) const globalPrefixDirName = isWindows ? 'global-bin-dir-windows' : 'global-bin-dir' - this.prefix = this.globalPrefix = path.join(__dirname, globalPrefixDirName) - this.localPrefix = __dirname + this.prefix = this.globalPrefix = path.join(import.meta.dirname, globalPrefixDirName) + this.localPrefix = import.meta.dirname } get (name: string) { @@ -36,6 +35,8 @@ jest.mock('@pnpm/npm-conf/lib/conf', () => { return MockedConf }) +const { getConfig } = await import('@pnpm/config') + test('respects global-bin-dir in npmrc', async () => { const { config } = await getConfig({ cliOptions: { @@ -56,7 +57,7 @@ test('respects global-bin-dir rather than dir', async () => { const { config } = await getConfig({ cliOptions: { global: true, - dir: __dirname, + dir: import.meta.dirname, }, env: { [pathName]: `${globalBinDir}${path.delimiter}${process.env[pathName]!}`, @@ -74,7 +75,7 @@ test('an exception is thrown when the global dir is not in PATH', async () => { getConfig({ cliOptions: { global: true, - dir: __dirname, + dir: import.meta.dirname, }, env: { [pathName]: process.env[pathName], @@ -97,7 +98,7 @@ test('the global directory may be a symlink to a directory that is in PATH', asy cliOptions: { global: true, 'global-bin-dir': globalBinDirSymlink, - dir: __dirname, + dir: import.meta.dirname, }, env: { [pathName]: `${globalBinDirTarget}${path.delimiter}${process.env[pathName]!}`, diff --git a/config/config/test/index.ts b/config/config/test/index.ts index f33e7dfba6..9e54b76d90 100644 --- a/config/config/test/index.ts +++ b/config/config/test/index.ts @@ -2,8 +2,6 @@ import fs from 'fs' import path from 'path' import PATH from 'path-name' -import { getCurrentBranch } from '@pnpm/git-utils' -import { getConfig } from '@pnpm/config' import loadNpmConf from '@pnpm/npm-conf' import { prepare, prepareEmpty } from '@pnpm/prepare' import { fixtures } from '@pnpm/test-fixtures' @@ -11,7 +9,10 @@ import { jest } from '@jest/globals' import symlinkDir from 'symlink-dir' -jest.mock('@pnpm/git-utils', () => ({ getCurrentBranch: jest.fn() })) +jest.unstable_mockModule('@pnpm/git-utils', () => ({ getCurrentBranch: jest.fn() })) + +const { getConfig } = await import('@pnpm/config') +const { getCurrentBranch } = await import('@pnpm/git-utils') // To override any local settings, // we force the default values of config @@ -25,10 +26,10 @@ delete process.env.npm_config_node_version delete process.env.npm_config_fetch_retries const env = { - PNPM_HOME: __dirname, - [PATH]: __dirname, + PNPM_HOME: import.meta.dirname, + [PATH]: import.meta.dirname, } -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('getConfig()', async () => { const { config } = await getConfig({ @@ -195,7 +196,7 @@ test('when using --global, link-workspace-packages, shared-workspace-lockfile an test('registries of scoped packages are read and normalized', async () => { const { config } = await getConfig({ cliOptions: { - userconfig: path.join(__dirname, 'scoped-registries.ini'), + userconfig: path.join(import.meta.dirname, 'scoped-registries.ini'), }, packageManager: { name: 'pnpm', @@ -219,7 +220,7 @@ test('registries in current directory\'s .npmrc have bigger priority then global const { config } = await getConfig({ cliOptions: { - userconfig: path.join(__dirname, 'scoped-registries.ini'), + userconfig: path.join(import.meta.dirname, 'scoped-registries.ini'), }, packageManager: { name: 'pnpm', @@ -607,7 +608,7 @@ test('all CLI options are added to the config', async () => { }) test('local prefix search stops on pnpm-workspace.yaml', async () => { - const workspaceDir = path.join(__dirname, 'has-workspace-yaml') + const workspaceDir = path.join(import.meta.dirname, 'has-workspace-yaml') process.chdir(workspaceDir) const { config } = await getConfig({ cliOptions: {}, @@ -621,7 +622,7 @@ test('local prefix search stops on pnpm-workspace.yaml', async () => { }) test('reads workspacePackagePatterns', async () => { - const workspaceDir = path.join(__dirname, 'fixtures/pkg-with-valid-workspace-yaml') + const workspaceDir = path.join(import.meta.dirname, 'fixtures/pkg-with-valid-workspace-yaml') process.chdir(workspaceDir) const { config } = await getConfig({ cliOptions: {}, @@ -636,7 +637,7 @@ test('reads workspacePackagePatterns', async () => { }) test('setting workspace-concurrency to negative number', async () => { - const workspaceDir = path.join(__dirname, 'fixtures/pkg-with-valid-workspace-yaml') + const workspaceDir = path.join(import.meta.dirname, 'fixtures/pkg-with-valid-workspace-yaml') process.chdir(workspaceDir) const { config } = await getConfig({ cliOptions: { @@ -664,7 +665,7 @@ test('respects test-pattern', async () => { expect(config.testPattern).toBeUndefined() } { - const workspaceDir = path.join(__dirname, 'using-test-pattern') + const workspaceDir = path.join(import.meta.dirname, 'using-test-pattern') process.chdir(workspaceDir) const { config } = await getConfig({ cliOptions: {}, @@ -830,7 +831,7 @@ test('getConfig() sets sideEffectsCacheRead and sideEffectsCacheWrite when side- test('getConfig() should read cafile', async () => { const { config } = await getConfig({ cliOptions: { - cafile: path.join(__dirname, 'cafile.txt'), + cafile: path.join(import.meta.dirname, 'cafile.txt'), }, packageManager: { name: 'pnpm', diff --git a/config/config/test/readLocalConfig.test.ts b/config/config/test/readLocalConfig.test.ts index 6812d4ed37..4ab9d5ce4b 100644 --- a/config/config/test/readLocalConfig.test.ts +++ b/config/config/test/readLocalConfig.test.ts @@ -1,7 +1,7 @@ import { fixtures } from '@pnpm/test-fixtures' import { readLocalConfig } from '@pnpm/config' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('readLocalConfig parse number field', async () => { const config = await readLocalConfig(f.find('has-number-setting')) diff --git a/config/config/test/tsconfig.json b/config/config/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/config/config/test/tsconfig.json +++ b/config/config/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/config/deps-installer/package.json b/config/deps-installer/package.json index f5ebfc2a9f..a752cb1c27 100644 --- a/config/deps-installer/package.json +++ b/config/deps-installer/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "prepublishOnly": "pnpm run compile", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "test-with-preview": "ts-node test", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "start": "tsc --watch", "compile": "tsc --build && pnpm run lint --fix" diff --git a/config/deps-installer/test/tsconfig.json b/config/deps-installer/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/config/deps-installer/test/tsconfig.json +++ b/config/deps-installer/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/config/matcher/package.json b/config/matcher/package.json index 04410e031a..154613c7f3 100644 --- a/config/matcher/package.json +++ b/config/matcher/package.json @@ -16,7 +16,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/config/matcher/test/tsconfig.json b/config/matcher/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/config/matcher/test/tsconfig.json +++ b/config/matcher/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/config/normalize-registries/package.json b/config/normalize-registries/package.json index d6bb66629e..ab2669af35 100644 --- a/config/normalize-registries/package.json +++ b/config/normalize-registries/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/config/normalize-registries/src/index.ts b/config/normalize-registries/src/index.ts index de8fb72ec2..978aeb1166 100644 --- a/config/normalize-registries/src/index.ts +++ b/config/normalize-registries/src/index.ts @@ -1,6 +1,6 @@ import { type Registries } from '@pnpm/types' import normalizeRegistryUrl from 'normalize-registry-url' -import mapValues from 'ramda/src/map' +import { map as mapValues } from 'ramda' export const DEFAULT_REGISTRIES: Registries = { default: 'https://registry.npmjs.org/', diff --git a/config/package-is-installable/package.json b/config/package-is-installable/package.json index fc04bf2cac..85ba77228a 100644 --- a/config/package-is-installable/package.json +++ b/config/package-is-installable/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "start": "tsc --watch", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/config/package-is-installable/test/checkPlatform.ts b/config/package-is-installable/test/checkPlatform.ts index e13423079a..ad9b748ccc 100644 --- a/config/package-is-installable/test/checkPlatform.ts +++ b/config/package-is-installable/test/checkPlatform.ts @@ -1,6 +1,5 @@ import { jest } from '@jest/globals' import type * as DetectLibc from 'detect-libc' -import { checkPlatform } from '../lib/checkPlatform.js' const packageId = 'registry.npmjs.org/foo/1.0.0' @@ -12,6 +11,8 @@ jest.mock('detect-libc', () => { } }) +const { checkPlatform } = await import('../lib/checkPlatform.js') + test('target cpu wrong', () => { const target = { cpu: 'enten-cpu', diff --git a/config/package-is-installable/test/tsconfig.json b/config/package-is-installable/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/config/package-is-installable/test/tsconfig.json +++ b/config/package-is-installable/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/config/parse-overrides/package.json b/config/parse-overrides/package.json index dcb76a7c5f..145552ced8 100644 --- a/config/parse-overrides/package.json +++ b/config/parse-overrides/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -24,7 +24,7 @@ "!*.map" ], "scripts": { - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/config/parse-overrides/test/tsconfig.json b/config/parse-overrides/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/config/parse-overrides/test/tsconfig.json +++ b/config/parse-overrides/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/config/pick-registry-for-package/package.json b/config/pick-registry-for-package/package.json index 41ef288535..3411aea66d 100644 --- a/config/pick-registry-for-package/package.json +++ b/config/pick-registry-for-package/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -24,7 +24,7 @@ "!*.map" ], "scripts": { - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/config/pick-registry-for-package/test/tsconfig.json b/config/pick-registry-for-package/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/config/pick-registry-for-package/test/tsconfig.json +++ b/config/pick-registry-for-package/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/config/plugin-commands-config/package.json b/config/plugin-commands-config/package.json index f1c1840f8f..dca2a88966 100644 --- a/config/plugin-commands-config/package.json +++ b/config/plugin-commands-config/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/config/plugin-commands-config/test/managingAuthSettings.test.ts b/config/plugin-commands-config/test/managingAuthSettings.test.ts index 938ead9ae7..72b1d42832 100644 --- a/config/plugin-commands-config/test/managingAuthSettings.test.ts +++ b/config/plugin-commands-config/test/managingAuthSettings.test.ts @@ -1,11 +1,12 @@ -import { config } from '@pnpm/plugin-commands-config' -import { runNpm } from '@pnpm/run-npm' import { jest } from '@jest/globals' -jest.mock('@pnpm/run-npm', () => ({ +jest.unstable_mockModule('@pnpm/run-npm', () => ({ runNpm: jest.fn(), })) +const { config } = await import('@pnpm/plugin-commands-config') +const { runNpm } = await import('@pnpm/run-npm') + describe.each( [ '_auth', @@ -21,7 +22,7 @@ describe.each( const configOpts = { dir: process.cwd(), cliOptions: {}, - configDir: __dirname, // this doesn't matter, it won't be used + configDir: import.meta.dirname, // this doesn't matter, it won't be used rawConfig: {}, } it(`should set ${key}`, async () => { @@ -39,7 +40,7 @@ describe.each( json: true, dir: process.cwd(), cliOptions: {}, - configDir: __dirname, // this doesn't matter, it won't be used + configDir: import.meta.dirname, // this doesn't matter, it won't be used rawConfig: {}, } it(`should set ${key}`, async () => { @@ -68,7 +69,7 @@ describe.each( json: true, dir: process.cwd(), cliOptions: {}, - configDir: __dirname, // this doesn't matter, it won't be used + configDir: import.meta.dirname, // this doesn't matter, it won't be used rawConfig: {}, } it(`${key} should reject a non-string value`, async () => { @@ -87,7 +88,7 @@ describe.each( const configOpts = { dir: process.cwd(), cliOptions: {}, - configDir: __dirname, // this doesn't matter, it won't be used + configDir: import.meta.dirname, // this doesn't matter, it won't be used rawConfig: {}, } it('should set _auth', async () => { diff --git a/config/plugin-commands-config/test/tsconfig.json b/config/plugin-commands-config/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/config/plugin-commands-config/test/tsconfig.json +++ b/config/plugin-commands-config/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/crypto/hash/package.json b/crypto/hash/package.json index b703d2928b..3147ac7e4c 100644 --- a/crypto/hash/package.json +++ b/crypto/hash/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/crypto/hash/test/tsconfig.json b/crypto/hash/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/crypto/hash/test/tsconfig.json +++ b/crypto/hash/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/crypto/object-hasher/package.json b/crypto/object-hasher/package.json index 7c4fb6751b..d459db075f 100644 --- a/crypto/object-hasher/package.json +++ b/crypto/object-hasher/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/crypto/object-hasher/src/index.ts b/crypto/object-hasher/src/index.ts index f4a9449c6f..10caf9de66 100644 --- a/crypto/object-hasher/src/index.ts +++ b/crypto/object-hasher/src/index.ts @@ -1,4 +1,4 @@ -import isEmpty from 'ramda/src/isEmpty' +import { isEmpty } from 'ramda' // We use object-hash even though node-object-hash is faster. // Unlike node-object-hash, object-hash is streaming the hash updates, diff --git a/crypto/object-hasher/test/tsconfig.json b/crypto/object-hasher/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/crypto/object-hasher/test/tsconfig.json +++ b/crypto/object-hasher/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/crypto/shasums-file/package.json b/crypto/shasums-file/package.json index c1cb8db171..4b46bfbeb8 100644 --- a/crypto/shasums-file/package.json +++ b/crypto/shasums-file/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/crypto/shasums-file/test/tsconfig.json b/crypto/shasums-file/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/crypto/shasums-file/test/tsconfig.json +++ b/crypto/shasums-file/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/dedupe/check/package.json b/dedupe/check/package.json index 38672d92d1..74d94b33c6 100644 --- a/dedupe/check/package.json +++ b/dedupe/check/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -24,7 +24,7 @@ "!*.map" ], "scripts": { - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/dedupe/check/test/tsconfig.json b/dedupe/check/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/dedupe/check/test/tsconfig.json +++ b/dedupe/check/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/dedupe/issues-renderer/package.json b/dedupe/issues-renderer/package.json index 66321cf9f3..9bf1d323ac 100644 --- a/dedupe/issues-renderer/package.json +++ b/dedupe/issues-renderer/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -24,7 +24,7 @@ "!*.map" ], "scripts": { - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/dedupe/issues-renderer/test/tsconfig.json b/dedupe/issues-renderer/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/dedupe/issues-renderer/test/tsconfig.json +++ b/dedupe/issues-renderer/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/dedupe/types/package.json b/dedupe/types/package.json index 6730a51ab9..fc363d521e 100644 --- a/dedupe/types/package.json +++ b/dedupe/types/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/deps/graph-builder/package.json b/deps/graph-builder/package.json index 14ad35be72..306b5b83aa 100644 --- a/deps/graph-builder/package.json +++ b/deps/graph-builder/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/deps/graph-builder/src/lockfileToDepGraph.ts b/deps/graph-builder/src/lockfileToDepGraph.ts index 50fb2b75c9..a9bca6c931 100644 --- a/deps/graph-builder/src/lockfileToDepGraph.ts +++ b/deps/graph-builder/src/lockfileToDepGraph.ts @@ -21,8 +21,7 @@ import { } from '@pnpm/store-controller-types' import * as dp from '@pnpm/dependency-path' import pathExists from 'path-exists' -import equals from 'ramda/src/equals' -import isEmpty from 'ramda/src/isEmpty' +import { equals, isEmpty } from 'ramda' import { iteratePkgsForVirtualStore } from './iteratePkgsForVirtualStore.js' const brokenModulesLogger = logger('_broken_node_modules') diff --git a/deps/graph-sequencer/package.json b/deps/graph-sequencer/package.json index 59e552a06e..b073d380f4 100644 --- a/deps/graph-sequencer/package.json +++ b/deps/graph-sequencer/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/deps/graph-sequencer/test/tsconfig.json b/deps/graph-sequencer/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/deps/graph-sequencer/test/tsconfig.json +++ b/deps/graph-sequencer/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/deps/status/package.json b/deps/status/package.json index 24bf0d60a7..54c73a698e 100644 --- a/deps/status/package.json +++ b/deps/status/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "start": "tsc --watch", diff --git a/deps/status/src/checkDepsStatus.ts b/deps/status/src/checkDepsStatus.ts index 04b6129fbc..98f6a9ce1a 100644 --- a/deps/status/src/checkDepsStatus.ts +++ b/deps/status/src/checkDepsStatus.ts @@ -1,10 +1,7 @@ import fs from 'fs' import path from 'path' import util from 'util' -import equals from 'ramda/src/equals' -import isEmpty from 'ramda/src/isEmpty' -import filter from 'ramda/src/filter' -import once from 'ramda/src/once' +import { equals, isEmpty, filter, once } from 'ramda' import { type Config, type OptionsFromRootManifest, getOptionsFromRootManifest } from '@pnpm/config' import { MANIFEST_BASE_NAMES, WANTED_LOCKFILE } from '@pnpm/constants' import { hashObjectNullableWithPrefix } from '@pnpm/crypto.object-hasher' diff --git a/deps/status/test/checkDepsStatus.test.ts b/deps/status/test/checkDepsStatus.test.ts index abc0719615..c9c2674e54 100644 --- a/deps/status/test/checkDepsStatus.test.ts +++ b/deps/status/test/checkDepsStatus.test.ts @@ -1,27 +1,45 @@ import { type Stats } from 'fs' -import { checkDepsStatus, type CheckDepsStatusOptions } from '@pnpm/deps.status' -import * as workspaceStateModule from '@pnpm/workspace.state' -import * as lockfileFs from '@pnpm/lockfile.fs' +import { type CheckDepsStatusOptions } from '@pnpm/deps.status' +import { type WorkspaceState } from '@pnpm/workspace.state' import { jest } from '@jest/globals' -import * as fsUtils from '../lib/safeStat.js' -import * as statManifestFileUtils from '../lib/statManifestFile.js' +import { type LockfileObject } from '@pnpm/lockfile.fs' -jest.mock('../lib/safeStat', () => ({ - ...jest.requireActual('../lib/safeStat'), - safeStatSync: jest.fn(), - safeStat: jest.fn(), -})) +{ + const original = await import('@pnpm/workspace.state') + jest.unstable_mockModule('@pnpm/workspace.state', () => ({ + ...original, + loadWorkspaceState: jest.fn(), + })) +} +{ + const original = await import('../lib/safeStat.js') + jest.unstable_mockModule('../lib/safeStat', () => ({ + ...original, + safeStatSync: jest.fn(), + safeStat: jest.fn(), + })) +} +{ + const original = await import('../lib/statManifestFile.js') + jest.unstable_mockModule('../lib/statManifestFile', () => ({ + ...original, + statManifestFile: jest.fn(), + })) +} +{ + const original = await import('@pnpm/lockfile.fs') + jest.unstable_mockModule('@pnpm/lockfile.fs', () => ({ + ...original, + readCurrentLockfile: jest.fn(), + readWantedLockfile: jest.fn(), + })) +} -jest.mock('../lib/statManifestFile', () => ({ - ...jest.requireActual('../lib/statManifestFile'), - statManifestFile: jest.fn(), -})) - -jest.mock('@pnpm/lockfile.fs', () => ({ - ...jest.requireActual('@pnpm/lockfile.fs'), - readCurrentLockfile: jest.fn(), - readWantedLockfile: jest.fn(), -})) +const { checkDepsStatus } = await import('@pnpm/deps.status') +const { loadWorkspaceState } = await import('@pnpm/workspace.state') +const lockfileFs = await import('@pnpm/lockfile.fs') +const fsUtils = await import('../lib/safeStat.js') +const statManifestFileUtils = await import('../lib/statManifestFile.js') describe('checkDepsStatus - pnpmfile modification', () => { beforeEach(() => { @@ -33,7 +51,7 @@ describe('checkDepsStatus - pnpmfile modification', () => { const lastValidatedTimestamp = Date.now() - 10_000 const beforeLastValidation = lastValidatedTimestamp - 10_000 const afterLastValidation = lastValidatedTimestamp + 1_000 - const mockWorkspaceState: workspaceStateModule.WorkspaceState = { + const mockWorkspaceState: WorkspaceState = { lastValidatedTimestamp, pnpmfiles: ['pnpmfile.js', 'modifiedPnpmfile.js'], settings: { @@ -45,7 +63,7 @@ describe('checkDepsStatus - pnpmfile modification', () => { filteredInstall: false, } - jest.spyOn(workspaceStateModule, 'loadWorkspaceState').mockReturnValue(mockWorkspaceState) + jest.mocked(loadWorkspaceState).mockReturnValue(mockWorkspaceState) jest.mocked(fsUtils.safeStatSync).mockImplementation((filePath: string) => { if (filePath === 'pnpmfile.js') { @@ -71,7 +89,7 @@ describe('checkDepsStatus - pnpmfile modification', () => { jest.mocked(statManifestFileUtils.statManifestFile).mockImplementation(async () => { return undefined }) - const returnEmptyLockfile = async () => ({} as lockfileFs.LockfileObject) + const returnEmptyLockfile = async () => ({} as LockfileObject) jest.mocked(lockfileFs.readCurrentLockfile).mockImplementation(returnEmptyLockfile) jest.mocked(lockfileFs.readWantedLockfile).mockImplementation(returnEmptyLockfile) diff --git a/deps/status/test/tsconfig.json b/deps/status/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/deps/status/test/tsconfig.json +++ b/deps/status/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/env/node.fetcher/package.json b/env/node.fetcher/package.json index 62777a136a..9a6225413a 100644 --- a/env/node.fetcher/package.json +++ b/env/node.fetcher/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/env/node.fetcher/test/node.test.ts b/env/node.fetcher/test/node.test.ts index 9d8e8f72aa..0f8d0ba85e 100644 --- a/env/node.fetcher/test/node.test.ts +++ b/env/node.fetcher/test/node.test.ts @@ -2,15 +2,17 @@ import AdmZip from 'adm-zip' import { Response } from 'node-fetch' import path from 'path' import { Readable } from 'stream' -import { fetchNode, type FetchNodeOptionsToDir as FetchNodeOptions } from '@pnpm/node.fetcher' +import { type FetchNodeOptionsToDir as FetchNodeOptions } from '@pnpm/node.fetcher' import { tempDir } from '@pnpm/prepare' import { jest } from '@jest/globals' -import { isNonGlibcLinux } from 'detect-libc' -jest.mock('detect-libc', () => ({ +jest.unstable_mockModule('detect-libc', () => ({ isNonGlibcLinux: jest.fn(), })) +const { fetchNode } = await import('@pnpm/node.fetcher') +const { isNonGlibcLinux } = await import('detect-libc') + const fetchMock = jest.fn(async (url: string) => { if (url.endsWith('.zip')) { // The Windows code path for pnpm's node bootstrapping expects a subdir diff --git a/env/node.fetcher/test/tsconfig.json b/env/node.fetcher/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/env/node.fetcher/test/tsconfig.json +++ b/env/node.fetcher/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/env/node.resolver/package.json b/env/node.resolver/package.json index 267e613291..dac0289796 100644 --- a/env/node.resolver/package.json +++ b/env/node.resolver/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/env/node.resolver/test/tsconfig.json b/env/node.resolver/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/env/node.resolver/test/tsconfig.json +++ b/env/node.resolver/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/env/path/package.json b/env/path/package.json index ad16b322cd..c6997602f6 100644 --- a/env/path/package.json +++ b/env/path/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/env/path/test/tsconfig.json b/env/path/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/env/path/test/tsconfig.json +++ b/env/path/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/env/plugin-commands-env/package.json b/env/plugin-commands-env/package.json index 18d6600d19..d27b1fb3fe 100644 --- a/env/plugin-commands-env/package.json +++ b/env/plugin-commands-env/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/env/plugin-commands-env/test/env.test.ts b/env/plugin-commands-env/test/env.test.ts index 34378f0fd8..6b404dc442 100644 --- a/env/plugin-commands-env/test/env.test.ts +++ b/env/plugin-commands-env/test/env.test.ts @@ -105,7 +105,7 @@ test('it re-attempts failed downloads', async () => { tempDir() // This fixture was retrieved from http://nodejs.org/download/release/index.json on 2021-12-12. - const testReleaseInfoPath = path.join(__dirname, './fixtures/node-16.4.0-release-info.json') + const testReleaseInfoPath = path.join(import.meta.dirname, './fixtures/node-16.4.0-release-info.json') const nockScope = nock('https://nodejs.org') // Using nock's persist option since the default fetcher retries requests. diff --git a/env/plugin-commands-env/test/node.test.ts b/env/plugin-commands-env/test/node.test.ts index 163d0b1967..dbbd272a80 100644 --- a/env/plugin-commands-env/test/node.test.ts +++ b/env/plugin-commands-env/test/node.test.ts @@ -3,17 +3,10 @@ import path from 'path' import fs from 'fs' import { Readable } from 'stream' import tar from 'tar-stream' -import { globalWarn } from '@pnpm/logger' import { jest } from '@jest/globals' import { ZipFile } from 'yazl' -import { - getNodeDir, - getNodeBinDir, - getNodeVersionsBaseDir, - type NvmNodeCommandOptions, - prepareExecutionEnv, -} from '../lib/node.js' import { tempDir } from '@pnpm/prepare' +import { type NvmNodeCommandOptions } from '../lib/node.js' const fetchMock = jest.fn(async (url: string) => { if (url.endsWith('SHASUMS256.txt')) { @@ -50,18 +43,26 @@ a08f3386090e6511772b949d41970b75a6b71d28abb551dff9854ceb1929dae1 node-v16.4.0-w return new Response(Readable.from(Buffer.alloc(0))) }) -jest.mock('@pnpm/fetch', () => ({ +jest.unstable_mockModule('@pnpm/fetch', () => ({ createFetchFromRegistry: () => fetchMock, })) -jest.mock('@pnpm/logger', () => { - const originalModule = jest.requireActual('@pnpm/logger') +const originalModule = await import('@pnpm/logger') +jest.unstable_mockModule('@pnpm/logger', () => { return { ...originalModule, globalWarn: jest.fn(), } }) +const { globalWarn } = await import('@pnpm/logger') +const { + getNodeDir, + getNodeBinDir, + getNodeVersionsBaseDir, + prepareExecutionEnv, +} = await import('../lib/node.js') + beforeEach(() => { fetchMock.mockClear() jest.mocked(globalWarn).mockClear() diff --git a/env/plugin-commands-env/test/tsconfig.json b/env/plugin-commands-env/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/env/plugin-commands-env/test/tsconfig.json +++ b/env/plugin-commands-env/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/env/system-node-version/package.json b/env/system-node-version/package.json index cb5bef7f18..8fcd86d8a6 100644 --- a/env/system-node-version/package.json +++ b/env/system-node-version/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/env/system-node-version/test/getSystemNodeVersion.test.ts b/env/system-node-version/test/getSystemNodeVersion.test.ts index a187fdf3cd..25e5cbdc2c 100644 --- a/env/system-node-version/test/getSystemNodeVersion.test.ts +++ b/env/system-node-version/test/getSystemNodeVersion.test.ts @@ -1,13 +1,14 @@ import { jest } from '@jest/globals' -import { getSystemNodeVersionNonCached } from '../lib/index.js' -import * as execa from 'execa' -jest.mock('execa', () => ({ +jest.unstable_mockModule('execa', () => ({ sync: jest.fn(() => ({ stdout: 'v10.0.0', })), })) +const { getSystemNodeVersionNonCached } = await import('../lib/index.js') +const execa = await import('execa') + test('getSystemNodeVersion() executed from an executable pnpm CLI', () => { // @ts-expect-error process['pkg'] = {} diff --git a/env/system-node-version/test/tsconfig.json b/env/system-node-version/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/env/system-node-version/test/tsconfig.json +++ b/env/system-node-version/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/exec/build-commands/package.json b/exec/build-commands/package.json index f1f9de3f20..967adda9e3 100644 --- a/exec/build-commands/package.json +++ b/exec/build-commands/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/exec/build-commands/src/approveBuilds.ts b/exec/build-commands/src/approveBuilds.ts index 399c409a23..28dccfbad5 100644 --- a/exec/build-commands/src/approveBuilds.ts +++ b/exec/build-commands/src/approveBuilds.ts @@ -4,7 +4,7 @@ import { type StrictModules, writeModulesManifest } from '@pnpm/modules-yaml' import { lexCompare } from '@pnpm/util.lex-comparator' import { type PnpmSettings } from '@pnpm/types' import renderHelp from 'render-help' -import { prompt } from 'enquirer' +import enquirer from 'enquirer' import chalk from 'chalk' import { rebuild, type RebuildCommandOpts } from '@pnpm/plugin-commands-rebuild' import { writeSettings } from '@pnpm/config.config-writer' @@ -54,7 +54,7 @@ export async function handler (opts: ApproveBuildsCommandOpts & RebuildCommandOp globalInfo('There are no packages awaiting approval') return } - const { result } = await prompt({ + const { result } = await enquirer.prompt({ choices: sortUniqueStrings([...automaticallyIgnoredBuilds]), indicator (state: any, choice: any) { // eslint-disable-line @typescript-eslint/no-explicit-any return ` ${choice.enabled ? '●' : '○'}` @@ -114,7 +114,7 @@ export async function handler (opts: ApproveBuildsCommandOpts & RebuildCommandOp } } if (buildPackages.length) { - const confirmed = await prompt<{ build: boolean }>({ + const confirmed = await enquirer.prompt<{ build: boolean }>({ type: 'confirm', name: 'build', message: `The next packages will now be built: ${buildPackages.join(', ')}. diff --git a/exec/build-commands/src/index.ts b/exec/build-commands/src/index.ts index f1c16141f3..ca1722dd39 100644 --- a/exec/build-commands/src/index.ts +++ b/exec/build-commands/src/index.ts @@ -1,4 +1,5 @@ import * as approveBuilds from './approveBuilds.js' import * as ignoredBuilds from './ignoredBuilds.js' +export type { ApproveBuildsCommandOpts } from './approveBuilds.js' export { approveBuilds, ignoredBuilds } diff --git a/exec/build-commands/test/approveBuilds.test.ts b/exec/build-commands/test/approveBuilds.test.ts index 8817e13c35..fbd2dd66d2 100644 --- a/exec/build-commands/test/approveBuilds.test.ts +++ b/exec/build-commands/test/approveBuilds.test.ts @@ -1,8 +1,7 @@ import fs from 'fs' import path from 'path' -import * as enquirer from 'enquirer' -import { approveBuilds } from '@pnpm/exec.build-commands' import { install } from '@pnpm/plugin-commands-installation' +import { type ApproveBuildsCommandOpts } from '@pnpm/exec.build-commands' import { type RebuildCommandOpts } from '@pnpm/plugin-commands-rebuild' import { prepare } from '@pnpm/prepare' import { type ProjectManifest } from '@pnpm/types' @@ -11,20 +10,21 @@ import { type Modules, readModulesManifest } from '@pnpm/modules-yaml' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import { jest } from '@jest/globals' import { sync as loadJsonFile } from 'load-json-file' -import omit from 'ramda/src/omit' +import { omit } from 'ramda' import { tempDir } from '@pnpm/prepare-temp-dir' import writePkg from 'write-pkg' import { sync as readYamlFile } from 'read-yaml-file' import { sync as writeYamlFile } from 'write-yaml-file' -jest.mock('enquirer', () => ({ prompt: jest.fn() })) +jest.unstable_mockModule('enquirer', () => ({ default: { prompt: jest.fn() } })) +const { default: enquirer } = await import('enquirer') +const { approveBuilds } = await import('@pnpm/exec.build-commands') -// eslint-disable-next-line -const prompt = enquirer.prompt as any +const prompt = jest.mocked(enquirer.prompt) -type ApproveBuildsOptions = Partial +type _ApproveBuildsOptions = Partial -async function approveSomeBuilds (opts?: ApproveBuildsOptions) { +async function approveSomeBuilds (opts?: _ApproveBuildsOptions) { const cliOptions = { argv: [], dir: process.cwd(), @@ -38,6 +38,7 @@ async function approveSomeBuilds (opts?: ApproveBuildsOptions) { storeDir: path.resolve('store'), cacheDir: path.resolve('cache'), pnpmfile: [], // this is only needed because the pnpmfile returned by getConfig is string | string[] + enableGlobalVirtualStore: false, } await install.handler({ ...config, argv: { original: [] } }) @@ -55,7 +56,7 @@ async function approveSomeBuilds (opts?: ApproveBuildsOptions) { await approveBuilds.handler({ ...config, ...opts }) } -async function approveNoBuilds (opts?: ApproveBuildsOptions) { +async function approveNoBuilds (opts?: _ApproveBuildsOptions) { const cliOptions = { argv: [], dir: process.cwd(), diff --git a/exec/build-commands/test/tsconfig.json b/exec/build-commands/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/exec/build-commands/test/tsconfig.json +++ b/exec/build-commands/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/exec/build-modules/package.json b/exec/build-modules/package.json index 53e8a74dcb..c48fbf0ff3 100644 --- a/exec/build-modules/package.json +++ b/exec/build-modules/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -30,7 +30,7 @@ "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/calc-dep-state": "workspace:*", diff --git a/exec/build-modules/src/buildSequence.ts b/exec/build-modules/src/buildSequence.ts index 875fc7d1c2..3f7b4aeb36 100644 --- a/exec/build-modules/src/buildSequence.ts +++ b/exec/build-modules/src/buildSequence.ts @@ -1,7 +1,7 @@ import { graphSequencer } from '@pnpm/deps.graph-sequencer' import { type PatchInfo } from '@pnpm/patching.types' import { type PkgIdWithPatchHash, type DepPath, type PackageManifest } from '@pnpm/types' -import filter from 'ramda/src/filter' +import { filter } from 'ramda' export interface DependenciesGraphNode { children: Record diff --git a/exec/build-modules/src/index.ts b/exec/build-modules/src/index.ts index ff1d52d431..44e815d95e 100644 --- a/exec/build-modules/src/index.ts +++ b/exec/build-modules/src/index.ts @@ -13,7 +13,7 @@ import { type StoreController } from '@pnpm/store-controller-types' import { applyPatchToDir } from '@pnpm/patching.apply-patch' import { type DependencyManifest } from '@pnpm/types' import pDefer, { type DeferredPromise } from 'p-defer' -import pickBy from 'ramda/src/pickBy' +import { pickBy } from 'ramda' import runGroups from 'run-groups' import { buildSequence, type DependenciesGraph, type DependenciesGraphNode } from './buildSequence.js' @@ -88,7 +88,7 @@ export async function buildModules ( } ) }) - await runGroups(getWorkspaceConcurrency(opts.childConcurrency), groups) + await runGroups.default(getWorkspaceConcurrency(opts.childConcurrency), groups) if (opts.ignoredBuiltDependencies?.length) { for (const ignoredBuild of opts.ignoredBuiltDependencies) { // We already ignore the build of this dependency. diff --git a/exec/build-modules/test/tsconfig.json b/exec/build-modules/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/exec/build-modules/test/tsconfig.json +++ b/exec/build-modules/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/exec/lifecycle/package.json b/exec/lifecycle/package.json index 2bdf42a484..d770592397 100644 --- a/exec/lifecycle/package.json +++ b/exec/lifecycle/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "fix": "tslint -c tslint.json src/**/*.ts test/**/*.ts --fix", diff --git a/exec/lifecycle/src/runLifecycleHooksConcurrently.ts b/exec/lifecycle/src/runLifecycleHooksConcurrently.ts index 3af38c75c0..3873ce3607 100644 --- a/exec/lifecycle/src/runLifecycleHooksConcurrently.ts +++ b/exec/lifecycle/src/runLifecycleHooksConcurrently.ts @@ -98,7 +98,7 @@ export async function runLifecycleHooksConcurrently ( } ) }) - await runGroups(childConcurrency, groups) + await runGroups.default(childConcurrency, groups) } async function scanDir (prefix: string, rootDir: string, currentDir: string, index: Record): Promise { diff --git a/exec/lifecycle/test/fixtures/escape-args/echo.js b/exec/lifecycle/test/fixtures/escape-args/echo.js new file mode 100644 index 0000000000..de0ffdfa9e --- /dev/null +++ b/exec/lifecycle/test/fixtures/escape-args/echo.js @@ -0,0 +1,6 @@ +#!/usr/bin/env node + +import fs from 'fs' +import path from 'path' + +fs.writeFileSync(path.join(import.meta.dirname, 'output.json'), JSON.stringify(process.argv.slice(2), null, 2)) diff --git a/exec/lifecycle/test/fixtures/escape-args/echo.sh b/exec/lifecycle/test/fixtures/escape-args/echo.sh deleted file mode 100644 index f91d8929c1..0000000000 --- a/exec/lifecycle/test/fixtures/escape-args/echo.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs'); -const path = require('path'); - -fs.writeFileSync(path.join(__dirname, 'output.json'), JSON.stringify(process.argv.slice(2), null, 2)) diff --git a/exec/lifecycle/test/fixtures/escape-args/package.json b/exec/lifecycle/test/fixtures/escape-args/package.json index 3dd742f4f1..9035e8f0ff 100644 --- a/exec/lifecycle/test/fixtures/escape-args/package.json +++ b/exec/lifecycle/test/fixtures/escape-args/package.json @@ -1,7 +1,8 @@ { "name": "issue-3907", "version": "1.0.0", + "type": "module", "scripts": { - "echo": "node echo.sh" + "echo": "node echo.js" } } diff --git a/exec/lifecycle/test/fixtures/escape-newline/echo.js b/exec/lifecycle/test/fixtures/escape-newline/echo.js new file mode 100644 index 0000000000..de0ffdfa9e --- /dev/null +++ b/exec/lifecycle/test/fixtures/escape-newline/echo.js @@ -0,0 +1,6 @@ +#!/usr/bin/env node + +import fs from 'fs' +import path from 'path' + +fs.writeFileSync(path.join(import.meta.dirname, 'output.json'), JSON.stringify(process.argv.slice(2), null, 2)) diff --git a/exec/lifecycle/test/fixtures/escape-newline/echo.sh b/exec/lifecycle/test/fixtures/escape-newline/echo.sh deleted file mode 100644 index f91d8929c1..0000000000 --- a/exec/lifecycle/test/fixtures/escape-newline/echo.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs'); -const path = require('path'); - -fs.writeFileSync(path.join(__dirname, 'output.json'), JSON.stringify(process.argv.slice(2), null, 2)) diff --git a/exec/lifecycle/test/fixtures/escape-newline/package.json b/exec/lifecycle/test/fixtures/escape-newline/package.json index 527a98420f..23f692f548 100644 --- a/exec/lifecycle/test/fixtures/escape-newline/package.json +++ b/exec/lifecycle/test/fixtures/escape-newline/package.json @@ -1,7 +1,8 @@ { "name": "issue-8980", "version": "1.0.0", + "type": "module", "scripts": { - "echo": "node echo.sh" + "echo": "node echo.js" } } diff --git a/exec/lifecycle/test/index.ts b/exec/lifecycle/test/index.ts index 40cd3c5ca7..26b8a6e6ad 100644 --- a/exec/lifecycle/test/index.ts +++ b/exec/lifecycle/test/index.ts @@ -12,13 +12,13 @@ import isWindows from 'is-windows' const skipOnWindows = isWindows() ? test.skip : test -const f = fixtures(path.join(__dirname, 'fixtures')) -const rootModulesDir = path.join(__dirname, '..', 'node_modules') +const f = fixtures(path.join(import.meta.dirname, 'fixtures')) +const rootModulesDir = path.join(import.meta.dirname, '..', 'node_modules') test('runLifecycleHook()', async () => { const pkgRoot = f.find('simple') await using server = await createTestIpcServer(path.join(pkgRoot, 'test.sock')) - const pkg = await import(path.join(pkgRoot, 'package.json')) + const { default: pkg } = await import(path.join(pkgRoot, 'package.json')) await runLifecycleHook('postinstall', pkg, { depPath: '/simple/1.0.0', optional: false, @@ -33,7 +33,7 @@ test('runLifecycleHook()', async () => { test('runLifecycleHook() escapes the args passed to the script', async () => { const pkgRoot = f.find('escape-args') - const pkg = await import(path.join(pkgRoot, 'package.json')) + const { default: pkg } = await import(path.join(pkgRoot, 'package.json')) await runLifecycleHook('echo', pkg, { depPath: '/escape-args/1.0.0', pkgRoot, @@ -48,7 +48,7 @@ test('runLifecycleHook() escapes the args passed to the script', async () => { test('runLifecycleHook() passes newline correctly', async () => { const pkgRoot = f.find('escape-newline') - const pkg = await import(path.join(pkgRoot, 'package.json')) + const { default: pkg } = await import(path.join(pkgRoot, 'package.json')) await runLifecycleHook('echo', pkg, { depPath: 'escape-newline@1.0.0', pkgRoot, @@ -66,7 +66,7 @@ test('runLifecycleHook() passes newline correctly', async () => { test('runLifecycleHook() sets frozen-lockfile to false', async () => { const pkgRoot = f.find('inspect-frozen-lockfile') await using server = await createTestIpcServer(path.join(pkgRoot, 'test.sock')) - const pkg = await import(path.join(pkgRoot, 'package.json')) + const { default: pkg } = await import(path.join(pkgRoot, 'package.json')) await runLifecycleHook('postinstall', pkg, { depPath: '/inspect-frozen-lockfile/1.0.0', pkgRoot, @@ -97,7 +97,7 @@ test('runPostinstallHooks()', async () => { test('runLifecycleHook() should throw an error while missing script start or file server.js', async () => { const pkgRoot = f.find('without-script-start-serverjs') - const pkg = await import(path.join(pkgRoot, 'package.json')) + const { default: pkg } = await import(path.join(pkgRoot, 'package.json')) await expect( runLifecycleHook('start', pkg, { depPath: '/without-script-start-serverjs/1.0.0', diff --git a/exec/lifecycle/test/tsconfig.json b/exec/lifecycle/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/exec/lifecycle/test/tsconfig.json +++ b/exec/lifecycle/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/exec/pkg-requires-build/package.json b/exec/pkg-requires-build/package.json index 0df5ac23d2..26b4ba0fd4 100644 --- a/exec/pkg-requires-build/package.json +++ b/exec/pkg-requires-build/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/exec/plugin-commands-rebuild/package.json b/exec/plugin-commands-rebuild/package.json index 80fc2cf0f9..ae08788290 100644 --- a/exec/plugin-commands-rebuild/package.json +++ b/exec/plugin-commands-rebuild/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts b/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts index 9f58df84f5..7ef11cca66 100644 --- a/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts +++ b/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts @@ -58,7 +58,7 @@ Pick & Pick => { const packageManager = opts.packageManager ?? - await loadJsonFile<{ name: string, version: string }>(path.join(__dirname, '../../package.json'))! + await loadJsonFile<{ name: string, version: string }>(path.join(import.meta.dirname, '../../package.json'))! const dir = opts.dir ?? process.cwd() const lockfileDir = opts.lockfileDir ?? dir return { diff --git a/exec/plugin-commands-rebuild/src/implementation/index.ts b/exec/plugin-commands-rebuild/src/implementation/index.ts index 22066919d3..64d99afeaf 100644 --- a/exec/plugin-commands-rebuild/src/implementation/index.ts +++ b/exec/plugin-commands-rebuild/src/implementation/index.ts @@ -433,7 +433,7 @@ async function _rebuild ( } )) - await runGroups(opts.childConcurrency || 5, groups) + await runGroups.default(opts.childConcurrency || 5, groups) if (builtDepPaths.size > 0) { // It may be optimized because some bins were already linked before running lifecycle scripts diff --git a/exec/plugin-commands-rebuild/src/rebuild.ts b/exec/plugin-commands-rebuild/src/rebuild.ts index a68b923ac9..7d75b75551 100644 --- a/exec/plugin-commands-rebuild/src/rebuild.ts +++ b/exec/plugin-commands-rebuild/src/rebuild.ts @@ -7,7 +7,7 @@ import { type CreateStoreControllerOptions, } from '@pnpm/store-connection-manager' import { type ProjectRootDir } from '@pnpm/types' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { rebuildProjects, diff --git a/exec/plugin-commands-rebuild/test/index.ts b/exec/plugin-commands-rebuild/test/index.ts index 630677073d..2e256732b3 100644 --- a/exec/plugin-commands-rebuild/test/index.ts +++ b/exec/plugin-commands-rebuild/test/index.ts @@ -14,8 +14,8 @@ import sinon from 'sinon' import { DEFAULT_OPTS } from './utils/index.js' const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}/` -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') -const f = fixtures(__dirname) +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') +const f = fixtures(import.meta.dirname) test('rebuilds dependencies', async () => { const project = prepare() @@ -28,6 +28,7 @@ test('rebuilds dependencies', async () => { '--save-dev', '@pnpm.e2e/pre-and-postinstall-scripts-example@1.0.0', 'pnpm/test-git-fetch#8b333f12d5357f4f25a654c305c826294cb073bf', + '--config.enableGlobalVirtualStore=false', `--registry=${REGISTRY}`, `--store-dir=${storeDir}`, '--ignore-scripts', @@ -104,6 +105,7 @@ test('skipIfHasSideEffectsCache', async () => { `--store-dir=${storeDir}`, '--ignore-scripts', `--cache-dir=${cacheDir}`, + '--config.enableGlobalVirtualStore=false', ]) const cacheIntegrityPath = getIndexFilePathInCafs(path.join(storeDir, STORE_VERSION), getIntegrity('@pnpm.e2e/pre-and-postinstall-scripts-example', '1.0.0'), '@pnpm.e2e/pre-and-postinstall-scripts-example@1.0.0') @@ -154,6 +156,7 @@ test('rebuild does not fail when a linked package is present', async () => { `--store-dir=${storeDir}`, `--cache-dir=${cacheDir}`, '--ignore-scripts', + '--config.enableGlobalVirtualStore=false', ]) const modulesManifest = project.readModulesManifest() @@ -183,6 +186,7 @@ test('rebuilds specific dependencies', async () => { `--store-dir=${storeDir}`, `--cache-dir=${cacheDir}`, '--ignore-scripts', + '--config.enableGlobalVirtualStore=false', ]) const modulesManifest = project.readModulesManifest() @@ -217,6 +221,7 @@ test('rebuild with pending option', async () => { `--store-dir=${storeDir}`, `--cache-dir=${cacheDir}`, '--ignore-scripts', + '--config.enableGlobalVirtualStore=false', ]) await execa('node', [ pnpmBin, @@ -226,6 +231,7 @@ test('rebuild with pending option', async () => { `--store-dir=${storeDir}`, `--cache-dir=${cacheDir}`, '--ignore-scripts', + '--config.enableGlobalVirtualStore=false', ]) let modules = project.readModulesManifest() @@ -283,6 +289,7 @@ test('rebuild dependencies in correct order', async () => { `--store-dir=${storeDir}`, `--cache-dir=${cacheDir}`, '--ignore-scripts', + '--config.enableGlobalVirtualStore=false', ]) let modules = project.readModulesManifest() @@ -322,6 +329,7 @@ test('rebuild links bins', async () => { `--store-dir=${storeDir}`, `--cache-dir=${cacheDir}`, '--ignore-scripts', + '--config.enableGlobalVirtualStore=false', ]) expect(fs.existsSync(path.resolve('node_modules/.bin/cmd1'))).toBeFalsy() @@ -366,6 +374,7 @@ test(`rebuild should not fail on incomplete ${WANTED_LOCKFILE}`, async () => { `--store-dir=${storeDir}`, `--cache-dir=${cacheDir}`, '--ignore-scripts', + '--config.enableGlobalVirtualStore=false', ]) const reporter = sinon.spy() @@ -399,6 +408,7 @@ test('never build neverBuiltDependencies', async () => { `--registry=${REGISTRY}`, `--store-dir=${storeDir}`, `--cache-dir=${cacheDir}`, + '--config.enableGlobalVirtualStore=false', ]) const modulesManifest = project.readModulesManifest() diff --git a/exec/plugin-commands-rebuild/test/recursive.ts b/exec/plugin-commands-rebuild/test/recursive.ts index 93527f921a..9fb8da7f48 100644 --- a/exec/plugin-commands-rebuild/test/recursive.ts +++ b/exec/plugin-commands-rebuild/test/recursive.ts @@ -9,7 +9,7 @@ import execa from 'execa' import { sync as writeYamlFile } from 'write-yaml-file' import { DEFAULT_OPTS, REGISTRY } from './utils/index.js' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') test('pnpm recursive rebuild', async () => { const projects = preparePackages([ @@ -41,6 +41,7 @@ test('pnpm recursive rebuild', async () => { `--cache-dir=${path.resolve(DEFAULT_OPTS.cacheDir)}`, '--ignore-scripts', '--reporter=append-only', + '--config.enableGlobalVirtualStore=false', ], { stdout: 'inherit' }) projects['project-1'].hasNot('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js') @@ -113,6 +114,7 @@ test('pnpm recursive rebuild with hoisted node linker', async () => { '--ignore-scripts', '--reporter=append-only', '--config.node-linker=hoisted', + '--config.enableGlobalVirtualStore=false', ], { stdout: 'inherit' }) const rootProject = assertProject(process.cwd()) @@ -203,6 +205,7 @@ test('rebuild multiple packages in correct order', async () => { '--store-dir', path.resolve(DEFAULT_OPTS.storeDir), '--ignore-scripts', + '--config.enableGlobalVirtualStore=false', ]) await rebuild.handler({ @@ -255,6 +258,7 @@ test('never build neverBuiltDependencies', async () => { `--cache-dir=${path.resolve(DEFAULT_OPTS.cacheDir)}`, '--ignore-scripts', '--reporter=append-only', + '--config.enableGlobalVirtualStore=false', ], { stdout: 'inherit' } ) @@ -349,6 +353,7 @@ test('only build onlyBuiltDependencies', async () => { `--cache-dir=${path.resolve(DEFAULT_OPTS.cacheDir)}`, '--ignore-scripts', '--reporter=append-only', + '--config.enableGlobalVirtualStore=false', ], { stdout: 'inherit' } ) diff --git a/exec/plugin-commands-rebuild/test/tsconfig.json b/exec/plugin-commands-rebuild/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/exec/plugin-commands-rebuild/test/tsconfig.json +++ b/exec/plugin-commands-rebuild/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/exec/plugin-commands-script-runners/package.json b/exec/plugin-commands-script-runners/package.json index cfc1f9e925..e6fc7c9a5a 100644 --- a/exec/plugin-commands-script-runners/package.json +++ b/exec/plugin-commands-script-runners/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "start": "tsc --watch", diff --git a/exec/plugin-commands-script-runners/src/create.ts b/exec/plugin-commands-script-runners/src/create.ts index 6798ed6af4..9b4f505b9f 100644 --- a/exec/plugin-commands-script-runners/src/create.ts +++ b/exec/plugin-commands-script-runners/src/create.ts @@ -2,7 +2,7 @@ import renderHelp from 'render-help' import { docsUrl } from '@pnpm/cli-utils' import { types } from '@pnpm/config' import { PnpmError } from '@pnpm/error' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import * as dlx from './dlx.js' export const commandNames = ['create'] diff --git a/exec/plugin-commands-script-runners/src/dlx.ts b/exec/plugin-commands-script-runners/src/dlx.ts index a518ca8339..f4833d30e4 100644 --- a/exec/plugin-commands-script-runners/src/dlx.ts +++ b/exec/plugin-commands-script-runners/src/dlx.ts @@ -14,7 +14,7 @@ import { getBinsFromPackageManifest } from '@pnpm/package-bins' import { type PackageManifest, type PnpmSettings, type SupportedArchitectures } from '@pnpm/types' import { lexCompare } from '@pnpm/util.lex-comparator' import execa from 'execa' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import symlinkDir from 'symlink-dir' import { makeEnv } from './makeEnv.js' diff --git a/exec/plugin-commands-script-runners/src/exec.ts b/exec/plugin-commands-script-runners/src/exec.ts index 359e172641..0209a7ba47 100644 --- a/exec/plugin-commands-script-runners/src/exec.ts +++ b/exec/plugin-commands-script-runners/src/exec.ts @@ -13,7 +13,7 @@ import { type Project, type ProjectsGraph, type ProjectRootDir, type ProjectRoot import execa from 'execa' import pLimit from 'p-limit' import { prependDirsToPath } from '@pnpm/env.path' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { existsInDir } from './existsInDir.js' import { makeEnv } from './makeEnv.js' diff --git a/exec/plugin-commands-script-runners/src/restart.ts b/exec/plugin-commands-script-runners/src/restart.ts index 9a2ac035e3..17b88b05f1 100644 --- a/exec/plugin-commands-script-runners/src/restart.ts +++ b/exec/plugin-commands-script-runners/src/restart.ts @@ -1,5 +1,5 @@ import { types as allTypes } from '@pnpm/config' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { handler as run, diff --git a/exec/plugin-commands-script-runners/src/run.ts b/exec/plugin-commands-script-runners/src/run.ts index 6fd25c3b9e..f27fea10de 100644 --- a/exec/plugin-commands-script-runners/src/run.ts +++ b/exec/plugin-commands-script-runners/src/run.ts @@ -18,7 +18,7 @@ import { } from '@pnpm/lifecycle' import { syncInjectedDeps } from '@pnpm/workspace.injected-deps-syncer' import { type PackageScripts, type ProjectManifest } from '@pnpm/types' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import realpathMissing from 'realpath-missing' import renderHelp from 'render-help' import { runRecursive, type RecursiveRunOpts, getSpecifiedScripts as getSpecifiedScriptWithoutStartCommand } from './runRecursive.js' diff --git a/exec/plugin-commands-script-runners/src/runDepsStatusCheck.ts b/exec/plugin-commands-script-runners/src/runDepsStatusCheck.ts index 297c6e61ef..9e9d897233 100644 --- a/exec/plugin-commands-script-runners/src/runDepsStatusCheck.ts +++ b/exec/plugin-commands-script-runners/src/runDepsStatusCheck.ts @@ -3,7 +3,7 @@ import { PnpmError } from '@pnpm/error' import { runPnpmCli } from '@pnpm/exec.pnpm-cli-runner' import { globalWarn } from '@pnpm/logger' import { checkDepsStatus, type CheckDepsStatusOptions, type WorkspaceStateSettings } from '@pnpm/deps.status' -import { prompt } from 'enquirer' +import enquirer from 'enquirer' export interface RunDepsStatusCheckOptions extends CheckDepsStatusOptions { dir: string @@ -27,7 +27,7 @@ export async function runDepsStatusCheck (opts: RunDepsStatusCheckOptions): Prom install() break case 'prompt': { - const confirmed = await prompt<{ runInstall: boolean }>({ + const confirmed = await enquirer.prompt<{ runInstall: boolean }>({ type: 'confirm', name: 'runInstall', message: `Your "node_modules" directory is out of sync with the "pnpm-lock.yaml" file. This can lead to issues during scripts execution. diff --git a/exec/plugin-commands-script-runners/test/create.ts b/exec/plugin-commands-script-runners/test/create.ts index 157e2f8e3c..6e0624e8e2 100644 --- a/exec/plugin-commands-script-runners/test/create.ts +++ b/exec/plugin-commands-script-runners/test/create.ts @@ -1,9 +1,10 @@ import { PnpmError } from '@pnpm/error' import { jest } from '@jest/globals' -import { create, dlx } from '../src/index.js' import { DLX_DEFAULT_OPTS as DEFAULT_OPTS } from './utils/index.js' -jest.mock('../src/dlx', () => ({ handler: jest.fn() })) +jest.unstable_mockModule('../src/dlx.js', () => ({ handler: jest.fn() })) + +const { create, dlx } = await import('../src/index.js') beforeEach(() => jest.mocked(dlx.handler).mockClear()) diff --git a/exec/plugin-commands-script-runners/test/dlx.e2e.ts b/exec/plugin-commands-script-runners/test/dlx.e2e.ts index dc1ff6c08e..5a1b329e4c 100644 --- a/exec/plugin-commands-script-runners/test/dlx.e2e.ts +++ b/exec/plugin-commands-script-runners/test/dlx.e2e.ts @@ -1,12 +1,24 @@ import fs from 'fs' import path from 'path' -import { add } from '@pnpm/plugin-commands-installation' -import { dlx } from '@pnpm/plugin-commands-script-runners' -import * as systemNodeVersion from '@pnpm/env.system-node-version' import { prepareEmpty } from '@pnpm/prepare' import { jest } from '@jest/globals' import { DLX_DEFAULT_OPTS as DEFAULT_OPTS } from './utils/index.js' +const { getSystemNodeVersion: originalGetSystemNodeVersion } = await import('@pnpm/env.system-node-version') +jest.unstable_mockModule('@pnpm/env.system-node-version', () => ({ + getSystemNodeVersion: jest.fn(originalGetSystemNodeVersion), +})) +const { add: originalAdd } = await import('@pnpm/plugin-commands-installation') +jest.unstable_mockModule('@pnpm/plugin-commands-installation', () => ({ + add: { + handler: jest.fn(originalAdd.handler), + }, +})) + +const systemNodeVersion = await import('@pnpm/env.system-node-version') +const { add } = await import('@pnpm/plugin-commands-installation') +const { dlx } = await import('@pnpm/plugin-commands-script-runners') + const testOnWindowsOnly = process.platform === 'win32' ? test : test.skip function sanitizeDlxCacheComponent (cacheName: string): string { @@ -208,7 +220,7 @@ testOnWindowsOnly('dlx should work when running in the root of a Windows Drive', test('dlx with cache', async () => { prepareEmpty() - const spy = jest.spyOn(add, 'handler') + const spy = jest.mocked(add.handler) await dlx.handler({ ...DEFAULT_OPTS, @@ -222,7 +234,7 @@ test('dlx with cache', async () => { verifyDlxCache(createCacheKey('shx@0.3.4')) expect(spy).toHaveBeenCalled() - spy.mockReset() + spy.mockClear() await dlx.handler({ ...DEFAULT_OPTS, @@ -236,10 +248,10 @@ test('dlx with cache', async () => { verifyDlxCache(createCacheKey('shx@0.3.4')) expect(spy).not.toHaveBeenCalled() - spy.mockRestore() + spy.mockClear() // Specify a node version that shx@0.3.4 does not support. Currently supported versions are >= 6. - const spySystemNodeVersion = jest.spyOn(systemNodeVersion, 'getSystemNodeVersion').mockReturnValue('v4.0.0') + jest.mocked(systemNodeVersion.getSystemNodeVersion).mockReturnValue('v4.0.0') await expect(dlx.handler({ ...DEFAULT_OPTS, @@ -250,7 +262,7 @@ test('dlx with cache', async () => { dlxCacheMaxAge: Infinity, }, ['shx@0.3.4', 'touch', 'foo'])).rejects.toThrow('Unsupported engine for') - spySystemNodeVersion.mockRestore() + jest.mocked(systemNodeVersion.getSystemNodeVersion).mockImplementation(originalGetSystemNodeVersion) }) test('dlx does not reuse expired cache', async () => { @@ -272,7 +284,7 @@ test('dlx does not reuse expired cache', async () => { const newDate = new Date(now.getTime() - 30 * 60_000) fs.lutimesSync(path.resolve('cache', 'dlx', createCacheKey('shx@0.3.4'), 'pkg'), newDate, newDate) - const spy = jest.spyOn(add, 'handler') + const spy = jest.mocked(add.handler) // main dlx execution await dlx.handler({ @@ -286,7 +298,7 @@ test('dlx does not reuse expired cache', async () => { expect(fs.existsSync('BAR')).toBe(true) expect(spy).toHaveBeenCalledWith(expect.anything(), ['shx@0.3.4']) - spy.mockRestore() + spy.mockClear() expect( fs.readdirSync(path.resolve('cache', 'dlx', createCacheKey('shx@0.3.4'))) diff --git a/exec/plugin-commands-script-runners/test/dlx.ts b/exec/plugin-commands-script-runners/test/dlx.ts index 5d3fe4dcb0..8abecddf2a 100644 --- a/exec/plugin-commands-script-runners/test/dlx.ts +++ b/exec/plugin-commands-script-runners/test/dlx.ts @@ -1,11 +1,15 @@ import path from 'path' -import execa from 'execa' -import { dlx } from '@pnpm/plugin-commands-script-runners' import { prepareEmpty } from '@pnpm/prepare' import { jest } from '@jest/globals' import { DLX_DEFAULT_OPTS as DEFAULT_OPTS } from './utils/index.js' -jest.mock('execa') +jest.unstable_mockModule('execa', () => ({ + default: jest.fn(), + sync: jest.fn(), +})) + +const { default: execa } = await import('execa') +const { dlx } = await import('@pnpm/plugin-commands-script-runners') beforeEach(() => jest.mocked(execa).mockClear()) diff --git a/exec/plugin-commands-script-runners/test/exec.e2e.ts b/exec/plugin-commands-script-runners/test/exec.e2e.ts index 690cf0f9e9..23e6ca8f36 100644 --- a/exec/plugin-commands-script-runners/test/exec.e2e.ts +++ b/exec/plugin-commands-script-runners/test/exec.e2e.ts @@ -9,7 +9,7 @@ import { type ProjectRootDirRealPath, type ProjectRootDir } from '@pnpm/types' import execa from 'execa' import { DEFAULT_OPTS, REGISTRY_URL } from './utils/index.js' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') const testOnPosixOnly = process.platform === 'win32' ? test.skip : test test('pnpm recursive exec', async () => { diff --git a/exec/plugin-commands-script-runners/test/exec.logs.ts b/exec/plugin-commands-script-runners/test/exec.logs.ts index 6a902d7507..b829fc5fbc 100644 --- a/exec/plugin-commands-script-runners/test/exec.logs.ts +++ b/exec/plugin-commands-script-runners/test/exec.logs.ts @@ -1,25 +1,25 @@ import fs from 'fs' import path from 'path' -import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir' -import { logger } from '@pnpm/logger' -import { exec } from '@pnpm/plugin-commands-script-runners' import { preparePackages } from '@pnpm/prepare' import { jest } from '@jest/globals' import writeYamlFile from 'write-yaml-file' import { DEFAULT_OPTS } from './utils/index.js' -jest.mock('@pnpm/logger', () => { - const debug = jest.fn() - +const debug = jest.fn() +jest.unstable_mockModule('@pnpm/logger', () => { return { logger: () => ({ debug }), + globalInfo: jest.fn(), + globalWarn: jest.fn(), + streamParser: jest.fn(), } }) -const lifecycleLogger = logger('lifecycle') +const { filterPackagesFromDir } = await import('@pnpm/workspace.filter-packages-from-dir') +const { exec } = await import('@pnpm/plugin-commands-script-runners') afterEach(() => { - jest.mocked(lifecycleLogger.debug).mockClear() + jest.mocked(debug).mockClear() }) test('pnpm exec --recursive --no-reporter-hide-prefix prints prefixes', async () => { @@ -62,22 +62,22 @@ test('pnpm exec --recursive --no-reporter-hide-prefix prints prefixes', async () depPath: name, stage: '(exec)', } - expect(lifecycleLogger.debug).toHaveBeenCalledWith({ + expect(debug).toHaveBeenCalledWith({ ...loggerOpts, line: 'hello from stdout', stdio: 'stdout', }) - expect(lifecycleLogger.debug).toHaveBeenCalledWith({ + expect(debug).toHaveBeenCalledWith({ ...loggerOpts, line: 'hello from stderr', stdio: 'stderr', }) - expect(lifecycleLogger.debug).toHaveBeenCalledWith({ + expect(debug).toHaveBeenCalledWith({ ...loggerOpts, line: `name is ${name}`, stdio: 'stdout', }) - expect(lifecycleLogger.debug).toHaveBeenCalledWith({ + expect(debug).toHaveBeenCalledWith({ ...loggerOpts, optional: false, exitCode: 0, @@ -119,7 +119,7 @@ test('pnpm exec --recursive --reporter-hide-prefix does not print prefixes', asy selectedProjectsGraph, }, [process.execPath, scriptFile]) - expect(lifecycleLogger.debug).not.toHaveBeenCalled() + expect(debug).not.toHaveBeenCalled() }) test('pnpm exec --recursive does not print prefixes by default', async () => { @@ -155,5 +155,5 @@ test('pnpm exec --recursive does not print prefixes by default', async () => { selectedProjectsGraph, }, [process.execPath, scriptFile]) - expect(lifecycleLogger.debug).not.toHaveBeenCalled() + expect(debug).not.toHaveBeenCalled() }) diff --git a/exec/plugin-commands-script-runners/test/exec.ts b/exec/plugin-commands-script-runners/test/exec.ts index 7501785d79..1b383cfda3 100644 --- a/exec/plugin-commands-script-runners/test/exec.ts +++ b/exec/plugin-commands-script-runners/test/exec.ts @@ -1,10 +1,14 @@ -import execa from 'execa' -import { exec } from '@pnpm/plugin-commands-script-runners' import { prepareEmpty } from '@pnpm/prepare' import { jest } from '@jest/globals' import { DEFAULT_OPTS } from './utils/index.js' -jest.mock('execa') +jest.unstable_mockModule('execa', () => ({ + default: jest.fn(), + sync: jest.fn(), +})) + +const { default: execa } = await import('execa') +const { exec } = await import('@pnpm/plugin-commands-script-runners') beforeEach(() => jest.mocked(execa).mockClear()) diff --git a/exec/plugin-commands-script-runners/test/index.ts b/exec/plugin-commands-script-runners/test/index.ts index a51ad791c4..8232029bbe 100644 --- a/exec/plugin-commands-script-runners/test/index.ts +++ b/exec/plugin-commands-script-runners/test/index.ts @@ -14,7 +14,7 @@ import isWindows from 'is-windows' import { sync as writeYamlFile } from 'write-yaml-file' import { DEFAULT_OPTS, REGISTRY_URL } from './utils/index.js' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') const skipOnWindows = isWindows() ? test.skip : test const onlyOnWindows = !isWindows() ? test.skip : test diff --git a/exec/plugin-commands-script-runners/test/runRecursive.ts b/exec/plugin-commands-script-runners/test/runRecursive.ts index fc66575994..0138a1afc8 100644 --- a/exec/plugin-commands-script-runners/test/runRecursive.ts +++ b/exec/plugin-commands-script-runners/test/runRecursive.ts @@ -10,7 +10,7 @@ import execa from 'execa' import { sync as writeYamlFile } from 'write-yaml-file' import { DEFAULT_OPTS, REGISTRY_URL } from './utils/index.js' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') test('pnpm recursive run', async () => { await using server1 = await createTestIpcServer() diff --git a/exec/plugin-commands-script-runners/test/testRecursive.ts b/exec/plugin-commands-script-runners/test/testRecursive.ts index 0ab18a3482..fea23a3dfd 100644 --- a/exec/plugin-commands-script-runners/test/testRecursive.ts +++ b/exec/plugin-commands-script-runners/test/testRecursive.ts @@ -7,7 +7,7 @@ import { createTestIpcServer } from '@pnpm/test-ipc-server' import execa from 'execa' import { DEFAULT_OPTS, REGISTRY_URL } from './utils/index.js' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') test('pnpm recursive test', async () => { await using server1 = await createTestIpcServer() diff --git a/exec/plugin-commands-script-runners/test/tsconfig.json b/exec/plugin-commands-script-runners/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/exec/plugin-commands-script-runners/test/tsconfig.json +++ b/exec/plugin-commands-script-runners/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/exec/plugin-commands-script-runners/test/verifyDepsBeforeRun.ts b/exec/plugin-commands-script-runners/test/verifyDepsBeforeRun.ts index 1a897f5398..313a89b4a7 100644 --- a/exec/plugin-commands-script-runners/test/verifyDepsBeforeRun.ts +++ b/exec/plugin-commands-script-runners/test/verifyDepsBeforeRun.ts @@ -1,25 +1,28 @@ import path from 'path' import fs from 'fs' -import { globalWarn } from '@pnpm/logger' import { type VerifyDepsBeforeRun } from '@pnpm/config' -import { run } from '@pnpm/plugin-commands-script-runners' import { prepare } from '@pnpm/prepare' import { jest } from '@jest/globals' -import { prompt } from 'enquirer' import { DEFAULT_OPTS } from './utils/index.js' -jest.mock('@pnpm/logger', () => { - const originalModule = jest.requireActual('@pnpm/logger') +const originalModule = await import('@pnpm/logger') +jest.unstable_mockModule('@pnpm/logger', () => { return { ...originalModule, globalWarn: jest.fn(), } }) -jest.mock('enquirer', () => ({ - prompt: jest.fn(), +jest.unstable_mockModule('enquirer', () => ({ + default: { + prompt: jest.fn(), + }, })) +const { run } = await import('@pnpm/plugin-commands-script-runners') +const { default: enquirer } = await import('enquirer') +const { globalWarn } = await import('@pnpm/logger') + const rootProjectManifest = { name: 'root', private: true, @@ -81,11 +84,11 @@ test('prompt the user if verifyDepsBeforeRun is set to prompt', async () => { prepare(rootProjectManifest) // Mock the user confirming the prompt - jest.mocked(prompt).mockResolvedValue({ runInstall: true }) + jest.mocked(enquirer.prompt).mockResolvedValue({ runInstall: true }) await runTest('prompt') - expect(prompt).toHaveBeenCalledWith({ + expect(enquirer.prompt).toHaveBeenCalledWith({ type: 'confirm', name: 'runInstall', message: expect.stringContaining( diff --git a/exec/pnpm-cli-runner/package.json b/exec/pnpm-cli-runner/package.json index 438f0a52b7..4aa896d312 100644 --- a/exec/pnpm-cli-runner/package.json +++ b/exec/pnpm-cli-runner/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/exec/pnpm-cli-runner/src/index.ts b/exec/pnpm-cli-runner/src/index.ts index 87594b1c9a..6d4fbceb27 100644 --- a/exec/pnpm-cli-runner/src/index.ts +++ b/exec/pnpm-cli-runner/src/index.ts @@ -9,7 +9,7 @@ export function runPnpmCli (command: string[], { cwd }: { cwd: string }): void { const execFileName = path.basename(process.execPath).toLowerCase() if (execFileName === 'pnpm' || execFileName === 'pnpm.exe') { execSync(process.execPath, command, execOpts) - } else if (path.basename(process.argv[1]) === 'pnpm.cjs') { + } else if (path.basename(process.argv[1]) === 'pnpm.mjs') { execSync(process.execPath, [process.argv[1], ...command], execOpts) } else { execSync('pnpm', command, execOpts) diff --git a/exec/prepare-package/package.json b/exec/prepare-package/package.json index 2c19c883b9..f8a1575288 100644 --- a/exec/prepare-package/package.json +++ b/exec/prepare-package/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/error": "workspace:*", diff --git a/exec/prepare-package/src/index.ts b/exec/prepare-package/src/index.ts index 3d228e417d..479524d200 100644 --- a/exec/prepare-package/src/index.ts +++ b/exec/prepare-package/src/index.ts @@ -8,7 +8,7 @@ import { safeReadPackageJsonFromDir } from '@pnpm/read-package-json' import { type PackageManifest } from '@pnpm/types' import rimraf from '@zkochan/rimraf' import preferredPM from 'preferred-pm' -import omit from 'ramda/src/omit' +import { omit } from 'ramda' // We don't run prepublishOnly to prepare the dependency. // This might be counterintuitive as prepublishOnly is where a lot of packages put their build scripts. diff --git a/exec/prepare-package/test/index.ts b/exec/prepare-package/test/index.ts index 00cd09211b..c08f5afc33 100644 --- a/exec/prepare-package/test/index.ts +++ b/exec/prepare-package/test/index.ts @@ -4,7 +4,7 @@ import { tempDir } from '@pnpm/prepare' import { createTestIpcServer } from '@pnpm/test-ipc-server' import { fixtures } from '@pnpm/test-fixtures' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('prepare package runs the prepublish script', async () => { const tmp = tempDir() diff --git a/exec/prepare-package/test/tsconfig.json b/exec/prepare-package/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/exec/prepare-package/test/tsconfig.json +++ b/exec/prepare-package/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/exec/run-npm/package.json b/exec/run-npm/package.json index 5d16a40176..c01ecafb25 100644 --- a/exec/run-npm/package.json +++ b/exec/run-npm/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/fetching/binary-fetcher/package.json b/fetching/binary-fetcher/package.json index 21a5bfc67a..dfd8bb9692 100644 --- a/fetching/binary-fetcher/package.json +++ b/fetching/binary-fetcher/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/fetching/directory-fetcher/package.json b/fetching/directory-fetcher/package.json index 662ac858b7..0de8433cd3 100644 --- a/fetching/directory-fetcher/package.json +++ b/fetching/directory-fetcher/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ "!*.map" ], "scripts": { - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/fetching/directory-fetcher/test/index.ts b/fetching/directory-fetcher/test/index.ts index 18e365253b..5e76693bb7 100644 --- a/fetching/directory-fetcher/test/index.ts +++ b/fetching/directory-fetcher/test/index.ts @@ -1,18 +1,17 @@ /// import fs from 'fs' import path from 'path' -import { createDirectoryFetcher } from '@pnpm/directory-fetcher' -// @ts-expect-error -import { debug } from '@pnpm/logger' import { fixtures } from '@pnpm/test-fixtures' import { sync as rimraf } from '@zkochan/rimraf' import { jest } from '@jest/globals' -const f = fixtures(__dirname) -jest.mock('@pnpm/logger', () => { - const debug = jest.fn() +const debug = jest.fn() +jest.unstable_mockModule('@pnpm/logger', () => { return ({ debug, logger: () => ({ debug }) }) }) +const { createDirectoryFetcher } = await import('@pnpm/directory-fetcher') + +const f = fixtures(import.meta.dirname) test('fetch including only package files', async () => { process.chdir(f.find('simple-pkg')) @@ -86,7 +85,7 @@ test('fetch a directory that has no package.json', async () => { }) test('fetch does not fail on package with broken symlink', async () => { - debug.mockClear() + jest.mocked(debug).mockClear() process.chdir(f.find('pkg-with-broken-symlink')) const fetcher = createDirectoryFetcher() diff --git a/fetching/directory-fetcher/test/tsconfig.json b/fetching/directory-fetcher/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/fetching/directory-fetcher/test/tsconfig.json +++ b/fetching/directory-fetcher/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/fetching/fetcher-base/package.json b/fetching/fetcher-base/package.json index 25cd25d373..4a96cc40a7 100644 --- a/fetching/fetcher-base/package.json +++ b/fetching/fetcher-base/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/fetching/git-fetcher/package.json b/fetching/git-fetcher/package.json index eb804b6ff0..f068babae7 100644 --- a/fetching/git-fetcher/package.json +++ b/fetching/git-fetcher/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ "!*.map" ], "scripts": { - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/fetching/git-fetcher/test/index.ts b/fetching/git-fetcher/test/index.ts index 32e6f5f663..9b47eb7fd6 100644 --- a/fetching/git-fetcher/test/index.ts +++ b/fetching/git-fetcher/test/index.ts @@ -1,28 +1,32 @@ /// import path from 'path' import { createCafsStore } from '@pnpm/create-cafs-store' -import { createGitFetcher } from '@pnpm/git-fetcher' -import { globalWarn } from '@pnpm/logger' import { jest } from '@jest/globals' import tempy from 'tempy' -import execa from 'execa' -jest.mock('execa', () => { - const originalModule = jest.requireActual('execa') // eslint-disable-line - return { - __esModule: true, - ...originalModule, - default: jest.fn(originalModule.default), - } -}) +{ + const originalModule = await import('execa') + jest.unstable_mockModule('execa', () => { + return { + __esModule: true, + ...originalModule, + default: jest.fn(originalModule.default), + } + }) +} +{ + const originalModule = await import('@pnpm/logger') + jest.unstable_mockModule('@pnpm/logger', () => { + return { + ...originalModule, + globalWarn: jest.fn(), + } + }) +} -jest.mock('@pnpm/logger', () => { - const originalModule = jest.requireActual('@pnpm/logger') - return { - ...originalModule, - globalWarn: jest.fn(), - } -}) +const { globalWarn } = await import('@pnpm/logger') +const { default: execa } = await import('execa') +const { createGitFetcher } = await import('@pnpm/git-fetcher') beforeEach(() => { jest.mocked(execa).mockClear() diff --git a/fetching/git-fetcher/test/tsconfig.json b/fetching/git-fetcher/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/fetching/git-fetcher/test/tsconfig.json +++ b/fetching/git-fetcher/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/fetching/pick-fetcher/package.json b/fetching/pick-fetcher/package.json index 3cbf80c400..192b1d4fda 100644 --- a/fetching/pick-fetcher/package.json +++ b/fetching/pick-fetcher/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/fetching/pick-fetcher/test/tsconfig.json b/fetching/pick-fetcher/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/fetching/pick-fetcher/test/tsconfig.json +++ b/fetching/pick-fetcher/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/fetching/tarball-fetcher/package.json b/fetching/tarball-fetcher/package.json index ab90a5181c..fac5aa969b 100644 --- a/fetching/tarball-fetcher/package.json +++ b/fetching/tarball-fetcher/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "compile": "tsc --build && pnpm run lint --fix" }, diff --git a/fetching/tarball-fetcher/test/fetch.ts b/fetching/tarball-fetcher/test/fetch.ts index ddd5b8264e..eaba699b9d 100644 --- a/fetching/tarball-fetcher/test/fetch.ts +++ b/fetching/tarball-fetcher/test/fetch.ts @@ -1,30 +1,31 @@ /// +import { jest } from '@jest/globals' import fs from 'fs' import path from 'path' import { FetchError, PnpmError } from '@pnpm/error' import { createFetchFromRegistry } from '@pnpm/fetch' import { createCafsStore } from '@pnpm/create-cafs-store' -import { globalWarn } from '@pnpm/logger' -import type * as Logger from '@pnpm/logger' import { fixtures } from '@pnpm/test-fixtures' -import { - createTarballFetcher, - BadTarballError, - TarballIntegrityError, -} from '@pnpm/tarball-fetcher' -import { jest } from '@jest/globals' import nock from 'nock' import ssri from 'ssri' import tempy from 'tempy' -jest.mock('@pnpm/logger', () => { - const originalModule = jest.requireActual('@pnpm/logger') +const originalModule = await import('@pnpm/logger') + +jest.unstable_mockModule('@pnpm/logger', async () => { return { ...originalModule, globalWarn: jest.fn(), } }) +const { globalWarn } = await import('@pnpm/logger') +const { + createTarballFetcher, + BadTarballError, + TarballIntegrityError, +} = await import('@pnpm/tarball-fetcher') + beforeEach(() => { jest.mocked(globalWarn).mockClear() }) @@ -33,7 +34,7 @@ const storeDir = tempy.directory() const filesIndexFile = path.join(storeDir, 'index.json') const cafs = createCafsStore(storeDir) -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const tarballPath = f.find('babel-helper-hoist-variables-6.24.1.tgz') const tarballSize = 1279 const tarballIntegrity = 'sha1-HssnaJydJVE+rbyZFKc/VAi+enY=' diff --git a/fetching/tarball-fetcher/test/tsconfig.json b/fetching/tarball-fetcher/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/fetching/tarball-fetcher/test/tsconfig.json +++ b/fetching/tarball-fetcher/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/fs/find-packages/README.md b/fs/find-packages/README.md index 440369c38b..1b3a8c2405 100644 --- a/fs/find-packages/README.md +++ b/fs/find-packages/README.md @@ -18,7 +18,7 @@ pnpm add @pnpm/fs.find-packages const path = require('path') const findPkgs = require('@pnpm/fs.find-packages') -findPkgs(path.join(__dirname, 'test', 'fixture')) +findPkgs(path.join(import.meta.dirname, 'test', 'fixture')) .then(pkgs => console.log(pkgs)) .catch(err => console.error(err)) //> [ { path: '/home/zkochan/src/find-packages/test/fixture/pkg', diff --git a/fs/find-packages/example.js b/fs/find-packages/example.js index 560c80015f..204862d55d 100644 --- a/fs/find-packages/example.js +++ b/fs/find-packages/example.js @@ -1,6 +1,6 @@ const path = require('path') const findPkgs = require('@pnpm/fs.find-packages') -findPkgs(path.join(__dirname, 'test/fixtures/one-pkg')) +findPkgs(path.join(import.meta.dirname, 'test/fixtures/one-pkg')) .then(pkgs => console.log(pkgs)) .catch(err => console.error(err)) diff --git a/fs/find-packages/package.json b/fs/find-packages/package.json index e54461d315..6d0696d991 100644 --- a/fs/find-packages/package.json +++ b/fs/find-packages/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/fs/find-packages/test/index.ts b/fs/find-packages/test/index.ts index 3af137a0fc..12907d7d70 100644 --- a/fs/find-packages/test/index.ts +++ b/fs/find-packages/test/index.ts @@ -8,7 +8,7 @@ function compare (a: string | undefined, b: string | undefined) { return a.localeCompare(b) } -const fixtures = path.join(__dirname, 'fixtures') +const fixtures = path.join(import.meta.dirname, 'fixtures') test('finds package', async () => { const root = path.join(fixtures, 'one-pkg') diff --git a/fs/find-packages/test/tsconfig.json b/fs/find-packages/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/fs/find-packages/test/tsconfig.json +++ b/fs/find-packages/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/fs/graceful-fs/package.json b/fs/graceful-fs/package.json index b440835055..664aa67ec1 100644 --- a/fs/graceful-fs/package.json +++ b/fs/graceful-fs/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/fs/hard-link-dir/package.json b/fs/hard-link-dir/package.json index c43e1adc34..2b66b3fcc6 100644 --- a/fs/hard-link-dir/package.json +++ b/fs/hard-link-dir/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/fs/hard-link-dir/test/tsconfig.json b/fs/hard-link-dir/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/fs/hard-link-dir/test/tsconfig.json +++ b/fs/hard-link-dir/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/fs/indexed-pkg-importer/package.json b/fs/indexed-pkg-importer/package.json index 969f5f4dcc..c32afff04c 100644 --- a/fs/indexed-pkg-importer/package.json +++ b/fs/indexed-pkg-importer/package.json @@ -20,7 +20,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -38,7 +38,7 @@ "fix": "tslint -c tslint.json src/**/*.ts test/**/*.ts --fix", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "pretest": "rimraf .tmp", - "_test": "pnpm pretest && jest", + "_test": "pnpm pretest && cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/fs/indexed-pkg-importer/src/importIndexedDir.ts b/fs/indexed-pkg-importer/src/importIndexedDir.ts index 695a53921d..6ed8ed682d 100644 --- a/fs/indexed-pkg-importer/src/importIndexedDir.ts +++ b/fs/indexed-pkg-importer/src/importIndexedDir.ts @@ -1,6 +1,6 @@ import fs from 'fs' import util from 'util' -import { copySync } from 'fs-extra' +import fsx from 'fs-extra' import path from 'path' import { globalWarn, logger } from '@pnpm/logger' import { sync as rimraf } from '@zkochan/rimraf' @@ -146,7 +146,7 @@ function renameEvenAcrossDevices (src: string, dest: string): void { fs.renameSync(src, dest) } catch (err: unknown) { if (!(util.types.isNativeError(err) && 'code' in err && err.code === 'EXDEV')) throw err - copySync(src, dest) + fsx.copySync(src, dest) } } diff --git a/fs/indexed-pkg-importer/test/createImportPackage.test.ts b/fs/indexed-pkg-importer/test/createImportPackage.test.ts index 45219cd214..1de811ee3e 100644 --- a/fs/indexed-pkg-importer/test/createImportPackage.test.ts +++ b/fs/indexed-pkg-importer/test/createImportPackage.test.ts @@ -1,13 +1,10 @@ import fs, { type BigIntStats } from 'fs' import path from 'path' -import { createIndexedPkgImporter } from '@pnpm/fs.indexed-pkg-importer' -import gfs from '@pnpm/graceful-fs' -import { globalInfo } from '@pnpm/logger' import { jest } from '@jest/globals' const testOnLinuxOnly = (process.platform === 'darwin' || process.platform === 'win32') ? test.skip : test -jest.mock('@pnpm/graceful-fs', () => { +jest.unstable_mockModule('@pnpm/graceful-fs', () => { const { access, promises } = jest.requireActual('fs') const fsMock = { mkdirSync: promises.mkdir, @@ -22,17 +19,23 @@ jest.mock('@pnpm/graceful-fs', () => { default: fsMock, } }) -jest.mock('path-temp', () => ({ fastPathTemp: (file: string) => `${file}_tmp` })) -jest.mock('rename-overwrite', () => ({ sync: jest.fn() })) -jest.mock('fs-extra', () => ({ - copySync: jest.fn(), +jest.unstable_mockModule('path-temp', () => ({ fastPathTemp: (file: string) => `${file}_tmp` })) +jest.unstable_mockModule('rename-overwrite', () => ({ default: { sync: jest.fn() } })) +jest.unstable_mockModule('fs-extra', () => ({ + default: { + copySync: jest.fn(), + }, })) -jest.mock('@pnpm/logger', () => ({ +jest.unstable_mockModule('@pnpm/logger', () => ({ logger: jest.fn(() => ({ debug: jest.fn() })), globalWarn: jest.fn(), globalInfo: jest.fn(), })) +const { default: gfs } = await import('@pnpm/graceful-fs') +const { createIndexedPkgImporter } = await import('@pnpm/fs.indexed-pkg-importer') +const { globalInfo } = await import('@pnpm/logger') + beforeEach(() => { jest.mocked(gfs.copyFileSync).mockClear() jest.mocked(gfs.linkSync).mockClear() diff --git a/fs/indexed-pkg-importer/test/importingPkgWithInvalidFiles.ts b/fs/indexed-pkg-importer/test/importingPkgWithInvalidFiles.ts index a63f77d334..73b2c8afea 100644 --- a/fs/indexed-pkg-importer/test/importingPkgWithInvalidFiles.ts +++ b/fs/indexed-pkg-importer/test/importingPkgWithInvalidFiles.ts @@ -9,8 +9,8 @@ test('importing a package with invalid files', () => { const target = path.resolve('target') importPackage(target, { filesMap: { - 'foo?bar/qar>zoo.txt': __filename, - '1*2.txt': __filename, + 'foo?bar/qar>zoo.txt': import.meta.filename, + '1*2.txt': import.meta.filename, }, force: false, resolvedFrom: 'remote', diff --git a/fs/indexed-pkg-importer/test/tsconfig.json b/fs/indexed-pkg-importer/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/fs/indexed-pkg-importer/test/tsconfig.json +++ b/fs/indexed-pkg-importer/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/fs/is-empty-dir-or-nothing/package.json b/fs/is-empty-dir-or-nothing/package.json index a541c01889..d08e60e8ad 100644 --- a/fs/is-empty-dir-or-nothing/package.json +++ b/fs/is-empty-dir-or-nothing/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/fs/is-empty-dir-or-nothing/test/index.test.ts b/fs/is-empty-dir-or-nothing/test/index.test.ts index af7091f476..3985257caf 100644 --- a/fs/is-empty-dir-or-nothing/test/index.test.ts +++ b/fs/is-empty-dir-or-nothing/test/index.test.ts @@ -6,7 +6,7 @@ import { isEmptyDirOrNothing } from '@pnpm/fs.is-empty-dir-or-nothing' describe('isEmptyDirOrNothing', () => { it('should return true on a non-existent path', () => { const nonExistentPath = path.resolve( - __dirname, + import.meta.dirname, './__fixtures__/not-exists' ) const result = isEmptyDirOrNothing(nonExistentPath) @@ -21,7 +21,7 @@ describe('isEmptyDirOrNothing', () => { it('should return false on a directory with a file in it', () => { const dirWithFilesPath = path.resolve( - __dirname, + import.meta.dirname, './__fixtures__/dir-with-files' ) const result = isEmptyDirOrNothing(dirWithFilesPath) @@ -30,7 +30,7 @@ describe('isEmptyDirOrNothing', () => { it('should return false on a directory with a directory', () => { const dirWithFilesPath = path.resolve( - __dirname, + import.meta.dirname, './__fixtures__/dir-with-dirs' ) const result = isEmptyDirOrNothing(dirWithFilesPath) diff --git a/fs/is-empty-dir-or-nothing/test/tsconfig.json b/fs/is-empty-dir-or-nothing/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/fs/is-empty-dir-or-nothing/test/tsconfig.json +++ b/fs/is-empty-dir-or-nothing/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/fs/packlist/package.json b/fs/packlist/package.json index 46d9c779dc..e3869a34c5 100644 --- a/fs/packlist/package.json +++ b/fs/packlist/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/fs/read-modules-dir/package.json b/fs/read-modules-dir/package.json index 84531b7063..e85d8c74e9 100644 --- a/fs/read-modules-dir/package.json +++ b/fs/read-modules-dir/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/fs/symlink-dependency/package.json b/fs/symlink-dependency/package.json index 3179befc79..3e2b77ae68 100644 --- a/fs/symlink-dependency/package.json +++ b/fs/symlink-dependency/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -32,7 +32,7 @@ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/core-loggers": "workspace:*", diff --git a/fs/symlink-dependency/test/tsconfig.json b/fs/symlink-dependency/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/fs/symlink-dependency/test/tsconfig.json +++ b/fs/symlink-dependency/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/hooks/pnpmfile/package.json b/hooks/pnpmfile/package.json index 714cc89b8c..b22eb1fe06 100644 --- a/hooks/pnpmfile/package.json +++ b/hooks/pnpmfile/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/hooks/pnpmfile/src/requirePnpmfile.ts b/hooks/pnpmfile/src/requirePnpmfile.ts index 7dfa91c04e..a33969d781 100644 --- a/hooks/pnpmfile/src/requirePnpmfile.ts +++ b/hooks/pnpmfile/src/requirePnpmfile.ts @@ -1,12 +1,15 @@ import assert from 'assert' import fs from 'fs' import util from 'util' +import { createRequire } from 'module' import { PnpmError } from '@pnpm/error' import { logger } from '@pnpm/logger' import { type PackageManifest } from '@pnpm/types' import chalk from 'chalk' import { type Hooks } from './Hooks.js' +const require = createRequire(import.meta.url) + export class BadReadPackageHookError extends PnpmError { public readonly pnpmfile: string @@ -33,7 +36,7 @@ export interface Pnpmfile { export function requirePnpmfile (pnpmFilePath: string, prefix: string): { pnpmfileModule: Pnpmfile | undefined } | undefined { try { - const pnpmfile: Pnpmfile = require(pnpmFilePath) // eslint-disable-line + const pnpmfile: Pnpmfile = require(pnpmFilePath) if (typeof pnpmfile === 'undefined') { logger.warn({ message: `Ignoring the pnpmfile at "${pnpmFilePath}". It exports "undefined".`, diff --git a/hooks/pnpmfile/test/__fixtures__/package.json b/hooks/pnpmfile/test/__fixtures__/package.json new file mode 100644 index 0000000000..5bbefffbab --- /dev/null +++ b/hooks/pnpmfile/test/__fixtures__/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/hooks/pnpmfile/test/index.ts b/hooks/pnpmfile/test/index.ts index b1d4b61e0c..3d04515d2c 100644 --- a/hooks/pnpmfile/test/index.ts +++ b/hooks/pnpmfile/test/index.ts @@ -6,13 +6,13 @@ import { requirePnpmfile } from '../src/requirePnpmfile.js' const defaultHookContext: HookContext = { log () {} } test('ignoring a pnpmfile that exports undefined', () => { - const { pnpmfileModule: pnpmfile } = requirePnpmfile(path.join(__dirname, '__fixtures__/undefined.js'), __dirname)! + const { pnpmfileModule: pnpmfile } = requirePnpmfile(path.join(import.meta.dirname, '__fixtures__/undefined.js'), import.meta.dirname)! expect(pnpmfile).toBeUndefined() }) test('readPackage hook run fails when returns undefined', () => { - const pnpmfilePath = path.join(__dirname, '__fixtures__/readPackageNoReturn.js') - const { pnpmfileModule: pnpmfile } = requirePnpmfile(pnpmfilePath, __dirname)! + const pnpmfilePath = path.join(import.meta.dirname, '__fixtures__/readPackageNoReturn.js') + const { pnpmfileModule: pnpmfile } = requirePnpmfile(pnpmfilePath, import.meta.dirname)! return expect( pnpmfile!.hooks!.readPackage!({}, defaultHookContext) @@ -20,17 +20,17 @@ test('readPackage hook run fails when returns undefined', () => { }) test('readPackage hook run fails when returned dependencies is not an object', () => { - const pnpmfilePath = path.join(__dirname, '__fixtures__/readPackageNoObject.js') - const { pnpmfileModule: pnpmfile } = requirePnpmfile(pnpmfilePath, __dirname)! + const pnpmfilePath = path.join(import.meta.dirname, '__fixtures__/readPackageNoObject.js') + const { pnpmfileModule: pnpmfile } = requirePnpmfile(pnpmfilePath, import.meta.dirname)! return expect( pnpmfile!.hooks!.readPackage!({}, defaultHookContext) ).rejects.toEqual(new BadReadPackageHookError(pnpmfilePath, 'readPackage hook returned package manifest object\'s property \'dependencies\' must be an object.')) }) test('filterLog hook combines with the global hook', () => { - const globalPnpmfile = path.join(__dirname, '__fixtures__/globalFilterLog.js') - const pnpmfile = path.join(__dirname, '__fixtures__/filterLog.js') - const { hooks } = requireHooks(__dirname, { globalPnpmfile, pnpmfiles: [pnpmfile] }) + const globalPnpmfile = path.join(import.meta.dirname, '__fixtures__/globalFilterLog.js') + const pnpmfile = path.join(import.meta.dirname, '__fixtures__/filterLog.js') + const { hooks } = requireHooks(import.meta.dirname, { globalPnpmfile, pnpmfiles: [pnpmfile] }) expect(hooks.filterLog).toBeDefined() expect(hooks.filterLog!).toHaveLength(2) @@ -48,38 +48,38 @@ test('filterLog hook combines with the global hook', () => { }) test('ignoring the default pnpmfile if tryLoadDefaultPnpmfile is not set', () => { - const { hooks } = requireHooks(path.join(__dirname, '__fixtures__/default'), {}) + const { hooks } = requireHooks(path.join(import.meta.dirname, '__fixtures__/default'), {}) expect(hooks.readPackage?.length).toBe(0) }) test('loading the default pnpmfile if tryLoadDefaultPnpmfile is set to true', () => { - const { hooks } = requireHooks(path.join(__dirname, '__fixtures__/default'), { tryLoadDefaultPnpmfile: true }) + const { hooks } = requireHooks(path.join(import.meta.dirname, '__fixtures__/default'), { tryLoadDefaultPnpmfile: true }) expect(hooks.readPackage?.length).toBe(1) }) test('calculatePnpmfileChecksum is undefined when pnpmfile does not exist', async () => { - const { hooks } = requireHooks(__dirname, {}) + const { hooks } = requireHooks(import.meta.dirname, {}) expect(hooks.calculatePnpmfileChecksum).toBeUndefined() }) test('calculatePnpmfileChecksum resolves to hash string for existing pnpmfile', async () => { - const pnpmfile = path.join(__dirname, '__fixtures__/readPackageNoObject.js') - const { hooks } = requireHooks(__dirname, { pnpmfiles: [pnpmfile] }) + const pnpmfile = path.join(import.meta.dirname, '__fixtures__/readPackageNoObject.js') + const { hooks } = requireHooks(import.meta.dirname, { pnpmfiles: [pnpmfile] }) expect(typeof await hooks.calculatePnpmfileChecksum?.()).toBe('string') }) test('calculatePnpmfileChecksum is undefined if pnpmfile even when it exports undefined', async () => { - const pnpmfile = path.join(__dirname, '__fixtures__/undefined.js') - const { hooks } = requireHooks(__dirname, { pnpmfiles: [pnpmfile] }) + const pnpmfile = path.join(import.meta.dirname, '__fixtures__/undefined.js') + const { hooks } = requireHooks(import.meta.dirname, { pnpmfiles: [pnpmfile] }) expect(hooks.calculatePnpmfileChecksum).toBeUndefined() }) test('updateConfig throws an error if it returns undefined', async () => { - const pnpmfile = path.join(__dirname, '__fixtures__/updateConfigReturnsUndefined.js') - const { hooks } = requireHooks(__dirname, { pnpmfiles: [pnpmfile] }) + const pnpmfile = path.join(import.meta.dirname, '__fixtures__/updateConfigReturnsUndefined.js') + const { hooks } = requireHooks(import.meta.dirname, { pnpmfiles: [pnpmfile] }) expect(() => hooks.updateConfig![0]!({})).toThrow('The updateConfig hook returned undefined') }) test('requireHooks throw an error if one of the specified pnpmfiles does not exist', async () => { - expect(() => requireHooks(__dirname, { pnpmfiles: ['does-not-exist.cjs'] })).toThrow('is not found') + expect(() => requireHooks(import.meta.dirname, { pnpmfiles: ['does-not-exist.cjs'] })).toThrow('is not found') }) diff --git a/hooks/pnpmfile/test/tsconfig.json b/hooks/pnpmfile/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/hooks/pnpmfile/test/tsconfig.json +++ b/hooks/pnpmfile/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/hooks/read-package-hook/package.json b/hooks/read-package-hook/package.json index fed05eaa8a..d9fb2fa082 100644 --- a/hooks/read-package-hook/package.json +++ b/hooks/read-package-hook/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/hooks/read-package-hook/src/createReadPackageHook.ts b/hooks/read-package-hook/src/createReadPackageHook.ts index b881ef4a30..1c375a742f 100644 --- a/hooks/read-package-hook/src/createReadPackageHook.ts +++ b/hooks/read-package-hook/src/createReadPackageHook.ts @@ -5,8 +5,7 @@ import { type ProjectManifest, type ReadPackageHook, } from '@pnpm/types' -import isEmpty from 'ramda/src/isEmpty' -import pipeWith from 'ramda/src/pipeWith' +import { isEmpty, pipeWith } from 'ramda' import { createOptionalDependenciesRemover } from './createOptionalDependenciesRemover.js' import { createPackageExtender } from './createPackageExtender.js' import { createVersionsOverrider, type VersionOverrideWithoutRawSelector } from './createVersionsOverrider.js' diff --git a/hooks/read-package-hook/src/createVersionsOverrider.ts b/hooks/read-package-hook/src/createVersionsOverrider.ts index ebea199256..2744db78d5 100644 --- a/hooks/read-package-hook/src/createVersionsOverrider.ts +++ b/hooks/read-package-hook/src/createVersionsOverrider.ts @@ -1,6 +1,6 @@ import path from 'path' import semver from 'semver' -import partition from 'ramda/src/partition' +import { partition } from 'ramda' import { type Dependencies, type PackageManifest, type ReadPackageHook } from '@pnpm/types' import { type PackageSelector, type VersionOverride as VersionOverrideBase } from '@pnpm/parse-overrides' import { isValidPeerRange } from '@pnpm/semver.peer-range' diff --git a/hooks/read-package-hook/test/createVersionOverrider.test.ts b/hooks/read-package-hook/test/createVersionOverrider.test.ts index d8880ad40f..40b6b3659a 100644 --- a/hooks/read-package-hook/test/createVersionOverrider.test.ts +++ b/hooks/read-package-hook/test/createVersionOverrider.test.ts @@ -436,7 +436,7 @@ test('createVersionsOverrider() overrides dependencies with file with relative p }) test('createVersionsOverrider() overrides dependencies with file specified with absolute path', () => { - const absolutePath = path.join(__dirname, 'qar') + const absolutePath = path.join(import.meta.dirname, 'qar') const overrider = createVersionsOverrider([ { targetPkg: { diff --git a/hooks/read-package-hook/test/tsconfig.json b/hooks/read-package-hook/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/hooks/read-package-hook/test/tsconfig.json +++ b/hooks/read-package-hook/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/hooks/types/package.json b/hooks/types/package.json index 002f35e35d..0116ee8539 100644 --- a/hooks/types/package.json +++ b/hooks/types/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/lockfile/audit/package.json b/lockfile/audit/package.json index b895bc3edc..f6ff70e789 100644 --- a/lockfile/audit/package.json +++ b/lockfile/audit/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/lockfile/audit/src/lockfileToAuditTree.ts b/lockfile/audit/src/lockfileToAuditTree.ts index a2c14b8b2c..269a044c43 100644 --- a/lockfile/audit/src/lockfileToAuditTree.ts +++ b/lockfile/audit/src/lockfileToAuditTree.ts @@ -5,7 +5,7 @@ import { lockfileWalkerGroupImporterSteps, type LockfileWalkerStep } from '@pnpm import { detectDepTypes, type DepTypes, DepType } from '@pnpm/lockfile.detect-dep-types' import { type DependenciesField, type ProjectId } from '@pnpm/types' import { safeReadProjectManifestOnly } from '@pnpm/read-project-manifest' -import mapValues from 'ramda/src/map' +import { map as mapValues } from 'ramda' export interface AuditNode { version?: string diff --git a/lockfile/audit/test/index.ts b/lockfile/audit/test/index.ts index 7475602f9b..6ce35575e5 100644 --- a/lockfile/audit/test/index.ts +++ b/lockfile/audit/test/index.ts @@ -6,7 +6,7 @@ import { type DepPath, type ProjectId } from '@pnpm/types' import nock from 'nock' import { lockfileToAuditTree } from '../lib/lockfileToAuditTree.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) describe('audit', () => { test('lockfileToAuditTree()', async () => { diff --git a/lockfile/audit/test/tsconfig.json b/lockfile/audit/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/lockfile/audit/test/tsconfig.json +++ b/lockfile/audit/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/lockfile/detect-dep-types/package.json b/lockfile/detect-dep-types/package.json index 5e7dfd9668..566c12bbc2 100644 --- a/lockfile/detect-dep-types/package.json +++ b/lockfile/detect-dep-types/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/lockfile/filtering/package.json b/lockfile/filtering/package.json index 514a19a03c..79b85182a0 100644 --- a/lockfile/filtering/package.json +++ b/lockfile/filtering/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/lockfile/filtering/src/filterLockfileByImportersAndEngine.ts b/lockfile/filtering/src/filterLockfileByImportersAndEngine.ts index c1491eec03..95a55615ae 100644 --- a/lockfile/filtering/src/filterLockfileByImportersAndEngine.ts +++ b/lockfile/filtering/src/filterLockfileByImportersAndEngine.ts @@ -9,9 +9,7 @@ import { logger } from '@pnpm/logger' import { packageIsInstallable } from '@pnpm/package-is-installable' import { type DepPath, type SupportedArchitectures, type DependenciesField, type ProjectId } from '@pnpm/types' import * as dp from '@pnpm/dependency-path' -import mapValues from 'ramda/src/map' -import pickBy from 'ramda/src/pickBy' -import unnest from 'ramda/src/unnest' +import { map as mapValues, pickBy, unnest } from 'ramda' import { filterImporter } from './filterImporter.js' const lockfileLogger = logger('lockfile') diff --git a/lockfile/filtering/test/filterByImportersAndEngine.ts b/lockfile/filtering/test/filterByImportersAndEngine.ts index 970718adcc..8c143e16a9 100644 --- a/lockfile/filtering/test/filterByImportersAndEngine.ts +++ b/lockfile/filtering/test/filterByImportersAndEngine.ts @@ -1,5 +1,4 @@ import { LOCKFILE_VERSION } from '@pnpm/constants' -import { filterLockfileByImportersAndEngine } from '@pnpm/lockfile.filtering' import { type DepPath, type ProjectId } from '@pnpm/types' import { jest } from '@jest/globals' @@ -14,6 +13,8 @@ jest.mock('detect-libc', () => { } }) +const { filterLockfileByImportersAndEngine } = await import('@pnpm/lockfile.filtering') + afterEach(() => { Object.defineProperties(process, { platform: { diff --git a/lockfile/filtering/test/tsconfig.json b/lockfile/filtering/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/lockfile/filtering/test/tsconfig.json +++ b/lockfile/filtering/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/lockfile/fs/package.json b/lockfile/fs/package.json index 1df321e59c..5ba905fa1f 100644 --- a/lockfile/fs/package.json +++ b/lockfile/fs/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", diff --git a/lockfile/fs/src/index.ts b/lockfile/fs/src/index.ts index bda604bd9e..116d9f8f48 100644 --- a/lockfile/fs/src/index.ts +++ b/lockfile/fs/src/index.ts @@ -7,7 +7,7 @@ export { } from './write.js' export { existsNonEmptyWantedLockfile } from './existsWantedLockfile.js' export { getLockfileImporterId } from './getLockfileImporterId.js' -export * from '@pnpm/lockfile.types' +export * from '@pnpm/lockfile.types' // eslint-disable-line export * from './read.js' export { cleanGitBranchLockfiles } from './gitBranchLockfile.js' export { convertToLockfileFile } from './lockfileFormatConverters.js' diff --git a/lockfile/fs/src/lockfileFormatConverters.ts b/lockfile/fs/src/lockfileFormatConverters.ts index b81d7eaa8d..8c599a9ad7 100644 --- a/lockfile/fs/src/lockfileFormatConverters.ts +++ b/lockfile/fs/src/lockfileFormatConverters.ts @@ -11,11 +11,7 @@ import { type PackageSnapshots, } from '@pnpm/lockfile.types' import { type DepPath, DEPENDENCIES_FIELDS } from '@pnpm/types' -import isEmpty from 'ramda/src/isEmpty' -import _mapValues from 'ramda/src/map' -import omit from 'ramda/src/omit' -import pickBy from 'ramda/src/pickBy' -import pick from 'ramda/src/pick' +import { isEmpty, map as _mapValues, omit, pickBy, pick } from 'ramda' import { LOCKFILE_VERSION } from '@pnpm/constants' export function convertToLockfileFile (lockfile: LockfileObject): LockfileFile { diff --git a/lockfile/fs/src/write.ts b/lockfile/fs/src/write.ts index 65479c6cf8..314ee442e6 100644 --- a/lockfile/fs/src/write.ts +++ b/lockfile/fs/src/write.ts @@ -4,7 +4,7 @@ import { type LockfileObject, type LockfileFile } from '@pnpm/lockfile.types' import { WANTED_LOCKFILE } from '@pnpm/constants' import rimraf from '@zkochan/rimraf' import yaml from 'js-yaml' -import isEmpty from 'ramda/src/isEmpty' +import { isEmpty } from 'ramda' import writeFileAtomicCB from 'write-file-atomic' import { lockfileLogger as logger } from './logger.js' import { sortLockfileKeys } from './sortLockfileKeys.js' diff --git a/lockfile/fs/test/gitBranchLockfile.test.ts b/lockfile/fs/test/gitBranchLockfile.test.ts index 459310ee1d..5e26cfed64 100644 --- a/lockfile/fs/test/gitBranchLockfile.test.ts +++ b/lockfile/fs/test/gitBranchLockfile.test.ts @@ -1,7 +1,7 @@ import path from 'path' import { getGitBranchLockfileNames } from '../lib/gitBranchLockfile.js' -process.chdir(__dirname) +process.chdir(import.meta.dirname) test('getGitBranchLockfileNames()', async () => { const lockfileDir: string = path.join('fixtures', '6') diff --git a/lockfile/fs/test/lockfileName.test.ts b/lockfile/fs/test/lockfileName.test.ts index 88ec8450f6..c2daa239d8 100644 --- a/lockfile/fs/test/lockfileName.test.ts +++ b/lockfile/fs/test/lockfileName.test.ts @@ -1,9 +1,10 @@ import { WANTED_LOCKFILE } from '@pnpm/constants' -import { getCurrentBranch } from '@pnpm/git-utils' import { jest } from '@jest/globals' -import { getWantedLockfileName } from '../lib/lockfileName.js' -jest.mock('@pnpm/git-utils', () => ({ getCurrentBranch: jest.fn() })) +jest.unstable_mockModule('@pnpm/git-utils', () => ({ getCurrentBranch: jest.fn() })) + +const { getCurrentBranch } = await import('@pnpm/git-utils') +const { getWantedLockfileName } = await import('../lib/lockfileName.js') describe('lockfileName', () => { afterEach(() => { diff --git a/lockfile/fs/test/read.test.ts b/lockfile/fs/test/read.test.ts index 821b1cd79c..786eda160d 100644 --- a/lockfile/fs/test/read.test.ts +++ b/lockfile/fs/test/read.test.ts @@ -1,19 +1,20 @@ import path from 'path' -import { getCurrentBranch } from '@pnpm/git-utils' -import { +import { type DepPath, type ProjectId } from '@pnpm/types' +import { jest } from '@jest/globals' +import tempy from 'tempy' + +jest.unstable_mockModule('@pnpm/git-utils', () => ({ getCurrentBranch: jest.fn() })) + +const { getCurrentBranch } = await import('@pnpm/git-utils') +const { existsNonEmptyWantedLockfile, readCurrentLockfile, readWantedLockfile, writeCurrentLockfile, writeWantedLockfile, -} from '@pnpm/lockfile.fs' -import { type DepPath, type ProjectId } from '@pnpm/types' -import { jest } from '@jest/globals' -import tempy from 'tempy' +} = await import('@pnpm/lockfile.fs') -jest.mock('@pnpm/git-utils', () => ({ getCurrentBranch: jest.fn() })) - -process.chdir(__dirname) +process.chdir(import.meta.dirname) test('readWantedLockfile()', async () => { { diff --git a/lockfile/fs/test/tsconfig.json b/lockfile/fs/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/lockfile/fs/test/tsconfig.json +++ b/lockfile/fs/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/lockfile/fs/test/write.test.ts b/lockfile/fs/test/write.test.ts index d7c712390f..66ea0d6da2 100644 --- a/lockfile/fs/test/write.test.ts +++ b/lockfile/fs/test/write.test.ts @@ -1,17 +1,18 @@ import fs from 'fs' import path from 'path' import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' -import { - readCurrentLockfile, - readWantedLockfile, - writeLockfiles, -} from '@pnpm/lockfile.fs' import { jest } from '@jest/globals' import tempy from 'tempy' import yaml from 'yaml-tag' -import { getCurrentBranch } from '@pnpm/git-utils' -jest.mock('@pnpm/git-utils', () => ({ getCurrentBranch: jest.fn() })) +jest.unstable_mockModule('@pnpm/git-utils', () => ({ getCurrentBranch: jest.fn() })) + +const { getCurrentBranch } = await import('@pnpm/git-utils') +const { + readCurrentLockfile, + readWantedLockfile, + writeLockfiles, +} = await import('@pnpm/lockfile.fs') test('writeLockfiles()', async () => { const projectPath = tempy.directory() diff --git a/lockfile/lockfile-to-pnp/package.json b/lockfile/lockfile-to-pnp/package.json index 1a0c4feb83..9d881c2c2b 100644 --- a/lockfile/lockfile-to-pnp/package.json +++ b/lockfile/lockfile-to-pnp/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -29,7 +29,7 @@ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "compile": "tsc --build && pnpm run lint --fix" }, "dependencies": { diff --git a/lockfile/lockfile-to-pnp/test/tsconfig.json b/lockfile/lockfile-to-pnp/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/lockfile/lockfile-to-pnp/test/tsconfig.json +++ b/lockfile/lockfile-to-pnp/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/lockfile/merger/package.json b/lockfile/merger/package.json index f7a772a998..c98ddd359d 100644 --- a/lockfile/merger/package.json +++ b/lockfile/merger/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/lockfile/merger/test/tsconfig.json b/lockfile/merger/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/lockfile/merger/test/tsconfig.json +++ b/lockfile/merger/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/lockfile/plugin-commands-audit/package.json b/lockfile/plugin-commands-audit/package.json index ba3007258e..9e0f5128e1 100644 --- a/lockfile/plugin-commands-audit/package.json +++ b/lockfile/plugin-commands-audit/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", diff --git a/lockfile/plugin-commands-audit/src/audit.ts b/lockfile/plugin-commands-audit/src/audit.ts index 8617f6f59c..15d9bf0e56 100644 --- a/lockfile/plugin-commands-audit/src/audit.ts +++ b/lockfile/plugin-commands-audit/src/audit.ts @@ -8,9 +8,7 @@ import { readWantedLockfile } from '@pnpm/lockfile.fs' import { type Registries } from '@pnpm/types' import { table } from '@zkochan/table' import chalk from 'chalk' -import difference from 'ramda/src/difference' -import pick from 'ramda/src/pick' -import pickBy from 'ramda/src/pickBy' +import { difference, pick, pickBy } from 'ramda' import renderHelp from 'render-help' import { fix } from './fix.js' import { ignore } from './ignore.js' diff --git a/lockfile/plugin-commands-audit/src/fix.ts b/lockfile/plugin-commands-audit/src/fix.ts index 64ce352f60..9b4b821044 100644 --- a/lockfile/plugin-commands-audit/src/fix.ts +++ b/lockfile/plugin-commands-audit/src/fix.ts @@ -1,6 +1,6 @@ import { type AuditReport, type AuditAdvisory } from '@pnpm/audit' import { writeSettings } from '@pnpm/config.config-writer' -import difference from 'ramda/src/difference' +import { difference } from 'ramda' import { type AuditOptions } from './audit.js' export async function fix (auditReport: AuditReport, opts: AuditOptions): Promise> { diff --git a/lockfile/plugin-commands-audit/src/ignore.ts b/lockfile/plugin-commands-audit/src/ignore.ts index b665186c32..8d0422021b 100644 --- a/lockfile/plugin-commands-audit/src/ignore.ts +++ b/lockfile/plugin-commands-audit/src/ignore.ts @@ -1,7 +1,7 @@ import { type AuditAdvisory, type AuditReport } from '@pnpm/audit' import { type ProjectManifest, type AuditConfig } from '@pnpm/types' import { writeSettings } from '@pnpm/config.config-writer' -import difference from 'ramda/src/difference' +import { difference } from 'ramda' export interface IgnoreVulnerabilitiesOptions { dir: string diff --git a/lockfile/plugin-commands-audit/test/fix.ts b/lockfile/plugin-commands-audit/test/fix.ts index 41302ad429..e724b41cad 100644 --- a/lockfile/plugin-commands-audit/test/fix.ts +++ b/lockfile/plugin-commands-audit/test/fix.ts @@ -5,7 +5,7 @@ import { sync as readYamlFile } from 'read-yaml-file' import nock from 'nock' import * as responses from './utils/responses/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const registries = { default: 'https://registry.npmjs.org/', } diff --git a/lockfile/plugin-commands-audit/test/ignore.ts b/lockfile/plugin-commands-audit/test/ignore.ts index 7ea3234179..e884ea045a 100644 --- a/lockfile/plugin-commands-audit/test/ignore.ts +++ b/lockfile/plugin-commands-audit/test/ignore.ts @@ -5,7 +5,7 @@ import nock from 'nock' import { sync as readYamlFile } from 'read-yaml-file' import * as responses from './utils/responses/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const registries = { default: 'https://registry.npmjs.org/', } diff --git a/lockfile/plugin-commands-audit/test/index.ts b/lockfile/plugin-commands-audit/test/index.ts index fcfc7656ca..26adc9b52d 100644 --- a/lockfile/plugin-commands-audit/test/index.ts +++ b/lockfile/plugin-commands-audit/test/index.ts @@ -7,7 +7,7 @@ import nock from 'nock' import { stripVTControlCharacters as stripAnsi } from 'util' import * as responses from './utils/responses/index.js' -const f = fixtures(path.join(__dirname, 'fixtures')) +const f = fixtures(path.join(import.meta.dirname, 'fixtures')) const registries = { default: 'https://registry.npmjs.org/', } diff --git a/lockfile/plugin-commands-audit/test/tsconfig.json b/lockfile/plugin-commands-audit/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/lockfile/plugin-commands-audit/test/tsconfig.json +++ b/lockfile/plugin-commands-audit/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/lockfile/plugin-commands-audit/test/utils/responses/index.ts b/lockfile/plugin-commands-audit/test/utils/responses/index.ts index a9dfa6046f..8b30f581e9 100644 --- a/lockfile/plugin-commands-audit/test/utils/responses/index.ts +++ b/lockfile/plugin-commands-audit/test/utils/responses/index.ts @@ -2,8 +2,8 @@ import path from 'path' import loadJsonFile from 'load-json-file' // eslint-disable-next-line -export const DEV_VULN_ONLY_RESP = loadJsonFile.sync(path.join(__dirname, 'dev-vulnerabilities-only-response.json')) +export const DEV_VULN_ONLY_RESP = loadJsonFile.sync(path.join(import.meta.dirname, 'dev-vulnerabilities-only-response.json')) // eslint-disable-next-line -export const ALL_VULN_RESP = loadJsonFile.sync(path.join(__dirname, 'all-vulnerabilities-response.json')) +export const ALL_VULN_RESP = loadJsonFile.sync(path.join(import.meta.dirname, 'all-vulnerabilities-response.json')) // eslint-disable-next-line -export const NO_VULN_RESP = loadJsonFile.sync(path.join(__dirname, 'no-vulnerabilities-response.json')) +export const NO_VULN_RESP = loadJsonFile.sync(path.join(import.meta.dirname, 'no-vulnerabilities-response.json')) diff --git a/lockfile/plugin-commands-audit/test/utils/responses/update.ts b/lockfile/plugin-commands-audit/test/utils/responses/update.ts index 246edff788..53b8fac9fb 100644 --- a/lockfile/plugin-commands-audit/test/utils/responses/update.ts +++ b/lockfile/plugin-commands-audit/test/utils/responses/update.ts @@ -4,7 +4,7 @@ import { audit } from '@pnpm/audit' import { readWantedLockfile } from '@pnpm/lockfile.fs' import { fixtures } from '@pnpm/test-fixtures' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) async function writeResponse (lockfileDir: string, filename: string, opts: { production?: boolean @@ -23,7 +23,7 @@ async function writeResponse (lockfileDir: string, filename: string, opts: { include, registry: 'https://registry.npmjs.org/', }) - fs.writeFileSync(path.join(__dirname, filename), JSON.stringify(auditReport, null, 2)) + fs.writeFileSync(path.join(import.meta.dirname, filename), JSON.stringify(auditReport, null, 2)) } // eslint-disable-next-line diff --git a/lockfile/preferred-versions/package.json b/lockfile/preferred-versions/package.json index a46b2d8f65..d123286816 100644 --- a/lockfile/preferred-versions/package.json +++ b/lockfile/preferred-versions/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/lockfile/pruner/package.json b/lockfile/pruner/package.json index e5498eb8d5..e79b3797c0 100644 --- a/lockfile/pruner/package.json +++ b/lockfile/pruner/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/lockfile/pruner/src/index.ts b/lockfile/pruner/src/index.ts index 7975ea8dd8..40f1dd5171 100644 --- a/lockfile/pruner/src/index.ts +++ b/lockfile/pruner/src/index.ts @@ -7,10 +7,9 @@ import { } from '@pnpm/lockfile.types' import { type DepPath, type PackageManifest, type ProjectId } from '@pnpm/types' import { refToRelative } from '@pnpm/dependency-path' -import difference from 'ramda/src/difference' -import isEmpty from 'ramda/src/isEmpty' -import unnest from 'ramda/src/unnest' +import { difference, isEmpty, unnest } from 'ramda' +// eslint-disable-next-line export * from '@pnpm/lockfile.types' // cannot import DependenciesGraph from @pnpm/resolve-dependencies due to circular dependency diff --git a/lockfile/pruner/test/tsconfig.json b/lockfile/pruner/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/lockfile/pruner/test/tsconfig.json +++ b/lockfile/pruner/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/lockfile/settings-checker/package.json b/lockfile/settings-checker/package.json index fc69a5819f..a6f0ef6c59 100644 --- a/lockfile/settings-checker/package.json +++ b/lockfile/settings-checker/package.json @@ -16,7 +16,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/lockfile/settings-checker/src/calcPatchHashes.ts b/lockfile/settings-checker/src/calcPatchHashes.ts index d93bea5793..6b3f71ef8c 100644 --- a/lockfile/settings-checker/src/calcPatchHashes.ts +++ b/lockfile/settings-checker/src/calcPatchHashes.ts @@ -4,7 +4,7 @@ import { createHexHashFromFile } from '@pnpm/crypto.hash' import { type PatchFile } from '@pnpm/lockfile.types' export async function calcPatchHashes (patches: Record, lockfileDir: string): Promise> { - return pMapValues(async (patchFilePath) => { + return pMapValues.default(async (patchFilePath) => { return { hash: await createHexHashFromFile(patchFilePath), path: path.relative(lockfileDir, patchFilePath).replaceAll('\\', '/'), diff --git a/lockfile/settings-checker/src/getOutdatedLockfileSetting.ts b/lockfile/settings-checker/src/getOutdatedLockfileSetting.ts index 473652652b..e5a8cbe09e 100644 --- a/lockfile/settings-checker/src/getOutdatedLockfileSetting.ts +++ b/lockfile/settings-checker/src/getOutdatedLockfileSetting.ts @@ -1,5 +1,5 @@ import { type LockfileObject, type PatchFile } from '@pnpm/lockfile.types' -import equals from 'ramda/src/equals' +import { equals } from 'ramda' export type ChangedField = | 'patchedDependencies' diff --git a/lockfile/types/package.json b/lockfile/types/package.json index 073a7bed3b..8761a19f6d 100644 --- a/lockfile/types/package.json +++ b/lockfile/types/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/lockfile/utils/package.json b/lockfile/utils/package.json index 658e274b6a..538a3c0ccd 100644 --- a/lockfile/utils/package.json +++ b/lockfile/utils/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/lockfile/utils/src/index.ts b/lockfile/utils/src/index.ts index 4a9fb33c38..fbb63826b9 100644 --- a/lockfile/utils/src/index.ts +++ b/lockfile/utils/src/index.ts @@ -6,7 +6,7 @@ export { packageIdFromSnapshot } from './packageIdFromSnapshot.js' export { packageIsIndependent } from './packageIsIndependent.js' export { pkgSnapshotToResolution } from './pkgSnapshotToResolution.js' export { refIsLocalTarball, refIsLocalDirectory } from './refIsLocalTarball.js' -export * from '@pnpm/lockfile.types' +export * from '@pnpm/lockfile.types' // eslint-disable-line // for backward compatibility export const getPkgShortId = refToRelative diff --git a/lockfile/utils/test/tsconfig.json b/lockfile/utils/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/lockfile/utils/test/tsconfig.json +++ b/lockfile/utils/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/lockfile/verification/package.json b/lockfile/verification/package.json index 85fd6f44d4..77358bce13 100644 --- a/lockfile/verification/package.json +++ b/lockfile/verification/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/lockfile/verification/src/allProjectsAreUpToDate.ts b/lockfile/verification/src/allProjectsAreUpToDate.ts index 6990e7621c..73f5f19d62 100644 --- a/lockfile/verification/src/allProjectsAreUpToDate.ts +++ b/lockfile/verification/src/allProjectsAreUpToDate.ts @@ -6,7 +6,7 @@ import { import { type WorkspacePackages } from '@pnpm/resolver-base' import { DEPENDENCIES_FIELDS, type ProjectId } from '@pnpm/types' import pEvery from 'p-every' -import isEmpty from 'ramda/src/isEmpty' +import { isEmpty } from 'ramda' import { allCatalogsAreUpToDate } from './allCatalogsAreUpToDate.js' import { getWorkspacePackagesByDirectory } from './getWorkspacePackagesByDirectory.js' import { linkedPackagesAreUpToDate } from './linkedPackagesAreUpToDate.js' @@ -49,7 +49,7 @@ export async function allProjectsAreUpToDate ( lockfilePackages: opts.wantedLockfile.packages, lockfileDir: opts.lockfileDir, }) - return pEvery(projects, async (project) => { + return pEvery.default(projects, async (project) => { const importer = opts.wantedLockfile.importers[project.id] if (importer == null) { return DEPENDENCIES_FIELDS.every((depType) => project.manifest[depType] == null || isEmpty(project.manifest[depType])) diff --git a/lockfile/verification/src/linkedPackagesAreUpToDate.ts b/lockfile/verification/src/linkedPackagesAreUpToDate.ts index f1b63fb971..681edf67e2 100644 --- a/lockfile/verification/src/linkedPackagesAreUpToDate.ts +++ b/lockfile/verification/src/linkedPackagesAreUpToDate.ts @@ -38,14 +38,14 @@ export async function linkedPackagesAreUpToDate ( snapshot: ProjectSnapshot } ): Promise { - return pEvery( + return pEvery.default( DEPENDENCIES_FIELDS, (depField) => { const lockfileDeps = project.snapshot[depField] const manifestDeps = project.manifest[depField] if ((lockfileDeps == null) || (manifestDeps == null)) return true const depNames = Object.keys(lockfileDeps) - return pEvery( + return pEvery.default( depNames, async (depName) => { const currentSpec = manifestDeps[depName] diff --git a/lockfile/verification/src/localTarballDepsAreUpToDate.ts b/lockfile/verification/src/localTarballDepsAreUpToDate.ts index 88c253d051..5ef71fa307 100644 --- a/lockfile/verification/src/localTarballDepsAreUpToDate.ts +++ b/lockfile/verification/src/localTarballDepsAreUpToDate.ts @@ -39,7 +39,7 @@ export async function localTarballDepsAreUpToDate ( snapshot: ProjectSnapshot } ): Promise { - return pEvery(DEPENDENCIES_FIELDS, (depField) => { + return pEvery.default(DEPENDENCIES_FIELDS, (depField) => { const lockfileDeps = project.snapshot[depField] // If the lockfile is missing a snapshot for this project's dependencies, we @@ -50,7 +50,7 @@ export async function localTarballDepsAreUpToDate ( return true } - return pEvery( + return pEvery.default( Object.entries(lockfileDeps), async ([depName, ref]) => { if (!ref.startsWith('file:')) { diff --git a/lockfile/verification/src/satisfiesPackageManifest.ts b/lockfile/verification/src/satisfiesPackageManifest.ts index 7178300951..bad6c82223 100644 --- a/lockfile/verification/src/satisfiesPackageManifest.ts +++ b/lockfile/verification/src/satisfiesPackageManifest.ts @@ -4,9 +4,7 @@ import { DEPENDENCIES_FIELDS, type ProjectManifest, } from '@pnpm/types' -import equals from 'ramda/src/equals' -import pickBy from 'ramda/src/pickBy' -import omit from 'ramda/src/omit' +import { equals, pickBy, omit } from 'ramda' import semver from 'semver' import { type Diff, diffFlatRecords, isEqual } from './diffFlatRecords.js' diff --git a/lockfile/verification/test/tsconfig.json b/lockfile/verification/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/lockfile/verification/test/tsconfig.json +++ b/lockfile/verification/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/lockfile/walker/package.json b/lockfile/walker/package.json index 6f95083eea..522ff21e66 100644 --- a/lockfile/walker/package.json +++ b/lockfile/walker/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/modules-mounter/daemon/package.json b/modules-mounter/daemon/package.json index ecfc1b03d8..024a8c5f6e 100644 --- a/modules-mounter/daemon/package.json +++ b/modules-mounter/daemon/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -31,8 +31,8 @@ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", - "pretest": "node ../../pnpm/dist/pnpm.cjs install --dir=test/__fixtures__/simple", - "_test": "pnpm pretest && jest", + "pretest": "node ../../pnpm/dist/pnpm.mjs install --dir=test/__fixtures__/simple --config.enableGlobalVirtualStore=false", + "_test": "pnpm pretest && cross-env NODE_OPTIONS=--experimental-vm-modules jest", "compile": "tsc --build && pnpm run lint --fix" }, "dependencies": { diff --git a/modules-mounter/daemon/src/createFuseHandlers.ts b/modules-mounter/daemon/src/createFuseHandlers.ts index 419b15e597..6e0ad48e51 100644 --- a/modules-mounter/daemon/src/createFuseHandlers.ts +++ b/modules-mounter/daemon/src/createFuseHandlers.ts @@ -6,7 +6,7 @@ import { nameVerFromPkgSnapshot, } from '@pnpm/lockfile.utils' import { type DepPath } from '@pnpm/types' -import * as schemas from 'hyperdrive-schemas' +import schemas from 'hyperdrive-schemas' import loadJsonFile from 'load-json-file' import Fuse from 'fuse-native' import * as cafsExplorer from './cafsExplorer.js' diff --git a/modules-mounter/daemon/test/createFuseHandlers.test.ts b/modules-mounter/daemon/test/createFuseHandlers.test.ts index e17dd52244..f65de392c1 100644 --- a/modules-mounter/daemon/test/createFuseHandlers.test.ts +++ b/modules-mounter/daemon/test/createFuseHandlers.test.ts @@ -1,18 +1,17 @@ import { STORE_VERSION } from '@pnpm/constants' import { jest } from '@jest/globals' import path from 'path' +import { type FuseHandlers } from '../src/createFuseHandlers.js' -jest.mock('fuse-native', () => ({ ENOENT: -2 })) +jest.unstable_mockModule('fuse-native', () => ({ default: { ENOENT: -2 } })) -// eslint-disable-next-line -import { type FuseHandlers, createFuseHandlers } from '../src/createFuseHandlers.js' -// eslint-disable-next-line -import Fuse from 'fuse-native' +const { default: Fuse } = await import('fuse-native') +const { createFuseHandlers } = await import('../src/createFuseHandlers.js') describe('FUSE handlers', () => { let handlers: FuseHandlers beforeAll(async () => { - const fixture = path.join(__dirname, '__fixtures__/simple') + const fixture = path.join(import.meta.dirname, '__fixtures__/simple') handlers = await createFuseHandlers(fixture, path.join(fixture, 'store', STORE_VERSION)) }) diff --git a/modules-mounter/daemon/test/makeVirtualNodeModules.test.ts b/modules-mounter/daemon/test/makeVirtualNodeModules.test.ts index 81a7f3e8c6..c8dee457d1 100644 --- a/modules-mounter/daemon/test/makeVirtualNodeModules.test.ts +++ b/modules-mounter/daemon/test/makeVirtualNodeModules.test.ts @@ -3,6 +3,6 @@ import { readWantedLockfile } from '@pnpm/lockfile.fs' import { makeVirtualNodeModules } from '../src/makeVirtualNodeModules.js' test('makeVirtualNodeModules', async () => { - const lockfile = await readWantedLockfile(path.join(__dirname, '__fixtures__/simple'), { ignoreIncompatible: true }) + const lockfile = await readWantedLockfile(path.join(import.meta.dirname, '__fixtures__/simple'), { ignoreIncompatible: true }) expect(makeVirtualNodeModules(lockfile!)).toMatchSnapshot() }) diff --git a/modules-mounter/daemon/test/tsconfig.json b/modules-mounter/daemon/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/modules-mounter/daemon/test/tsconfig.json +++ b/modules-mounter/daemon/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/network/auth-header/package.json b/network/auth-header/package.json index fa83f50492..74707ff223 100644 --- a/network/auth-header/package.json +++ b/network/auth-header/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/network/auth-header/test/getAuthHeadersFromConfig.test.ts b/network/auth-header/test/getAuthHeadersFromConfig.test.ts index c6234a1e3c..4dc7ed25dd 100644 --- a/network/auth-header/test/getAuthHeadersFromConfig.test.ts +++ b/network/auth-header/test/getAuthHeadersFromConfig.test.ts @@ -4,13 +4,13 @@ import { getAuthHeadersFromConfig } from '../src/getAuthHeadersFromConfig.js' import { Buffer } from 'safe-buffer' const osTokenHelper = { - linux: path.join(__dirname, 'utils/test-exec.js'), - win32: path.join(__dirname, 'utils/test-exec.bat'), + linux: path.join(import.meta.dirname, 'utils/test-exec.js'), + win32: path.join(import.meta.dirname, 'utils/test-exec.bat'), } const osErrorTokenHelper = { - linux: path.join(__dirname, 'utils/test-exec-error.js'), - win32: path.join(__dirname, 'utils/test-exec-error.bat'), + linux: path.join(import.meta.dirname, 'utils/test-exec-error.js'), + win32: path.join(import.meta.dirname, 'utils/test-exec-error.bat'), } // Only exception is win32, all others behave like linux diff --git a/network/auth-header/test/tsconfig.json b/network/auth-header/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/network/auth-header/test/tsconfig.json +++ b/network/auth-header/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/network/fetch/package.json b/network/fetch/package.json index 8aa8a5e912..0c0c80e4f2 100644 --- a/network/fetch/package.json +++ b/network/fetch/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/network/fetch/test/fetchFromRegistry.test.ts b/network/fetch/test/fetchFromRegistry.test.ts index 0ea1f0c124..b22e11455e 100644 --- a/network/fetch/test/fetchFromRegistry.test.ts +++ b/network/fetch/test/fetchFromRegistry.test.ts @@ -5,7 +5,7 @@ import nock from 'nock' import { ProxyServer } from 'https-proxy-server-express' import fs from 'fs' -const CERTS_DIR = path.join(__dirname, '__certs__') +const CERTS_DIR = path.join(import.meta.dirname, '__certs__') test('fetchFromRegistry', async () => { const fetchFromRegistry = createFetchFromRegistry({}) diff --git a/network/fetch/test/tsconfig.json b/network/fetch/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/network/fetch/test/tsconfig.json +++ b/network/fetch/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/network/fetching-types/package.json b/network/fetching-types/package.json index 2b845862b1..bd754827cc 100644 --- a/network/fetching-types/package.json +++ b/network/fetching-types/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/object/key-sorting/package.json b/object/key-sorting/package.json index e34f09ab75..c5d1b26437 100644 --- a/object/key-sorting/package.json +++ b/object/key-sorting/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", diff --git a/object/key-sorting/test/tsconfig.json b/object/key-sorting/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/object/key-sorting/test/tsconfig.json +++ b/object/key-sorting/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/object/property-path/package.json b/object/property-path/package.json index be1b4b0067..9f73f748fc 100644 --- a/object/property-path/package.json +++ b/object/property-path/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -29,7 +29,7 @@ "prepublishOnly": "pnpm run compile", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "compile": "tsc --build && pnpm run lint --fix", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/error": "workspace:*" diff --git a/object/property-path/test/tsconfig.json b/object/property-path/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/object/property-path/test/tsconfig.json +++ b/object/property-path/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/package.json b/package.json index 672d1c4bff..5cf87e0649 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "test-pkgs-main": "pnpm remove-temp-dir && pnpm run --no-sort --workspace-concurrency=1 -r _test", "test-branch": "pnpm pretest && pnpm lint && git remote set-branches --add origin v11 && git fetch origin v11 && pnpm run test-pkgs-branch", "test-pkgs-branch": "pnpm remove-temp-dir && pnpm --workspace-concurrency=1 --filter=...[origin/v11] run --no-sort _test", - "compile-only": "ts-node __utils__/scripts/src/typecheck-only.ts && pnpm -F pnpm compile", + "compile-only": "pnpm --config.useNodeVersion=24.6.0 exec ts-node __utils__/scripts/src/typecheck-only.ts && pnpm -F pnpm compile", "compile": "pnpm compile-only && pnpm run update-manifests", "watch": "pnpm --filter=@pnpm/fetch run compile && pnpm --filter=pnpm run compile --watch", "make-lcov": "shx mkdir -p coverage && lcov-result-merger './packages/*/coverage/lcov.info' 'coverage/lcov.info'", diff --git a/packages/calc-dep-state/package.json b/packages/calc-dep-state/package.json index 9d3615829e..b82b8fcb3a 100644 --- a/packages/calc-dep-state/package.json +++ b/packages/calc-dep-state/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/packages/calc-dep-state/test/tsconfig.json b/packages/calc-dep-state/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/packages/calc-dep-state/test/tsconfig.json +++ b/packages/calc-dep-state/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/packages/constants/package.json b/packages/constants/package.json index 8ed10d8358..ac76258932 100644 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/packages/core-loggers/package.json b/packages/core-loggers/package.json index 5888e5dce7..4e18ec7800 100644 --- a/packages/core-loggers/package.json +++ b/packages/core-loggers/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/packages/dependency-path/package.json b/packages/dependency-path/package.json index 464b03d88c..86a9cf7830 100644 --- a/packages/dependency-path/package.json +++ b/packages/dependency-path/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/packages/dependency-path/test/tsconfig.json b/packages/dependency-path/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/packages/dependency-path/test/tsconfig.json +++ b/packages/dependency-path/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/packages/error/package.json b/packages/error/package.json index 5a0fb3df1d..d78df42c70 100644 --- a/packages/error/package.json +++ b/packages/error/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/packages/error/test/tsconfig.json b/packages/error/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/packages/error/test/tsconfig.json +++ b/packages/error/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/packages/git-utils/package.json b/packages/git-utils/package.json index 5bc2d15270..c6434c3799 100644 --- a/packages/git-utils/package.json +++ b/packages/git-utils/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "fix": "tslint -c tslint.json src/**/*.ts test/**/*.ts --fix", diff --git a/packages/git-utils/test/tsconfig.json b/packages/git-utils/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/packages/git-utils/test/tsconfig.json +++ b/packages/git-utils/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/packages/logger/package.json b/packages/logger/package.json index 70f3d37f0a..b2c242362f 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/packages/logger/test/index.test.ts b/packages/logger/test/index.test.ts index 82be08517d..d89f588db3 100644 --- a/packages/logger/test/index.test.ts +++ b/packages/logger/test/index.test.ts @@ -1,4 +1,4 @@ -import { type LogBase, logger, streamParser } from '../src/index.js' +import { type LogBase, logger, streamParser } from '@pnpm/logger' test('logger logs', async () => { const promise = new Promise(resolve => { diff --git a/packages/logger/test/tsconfig.json b/packages/logger/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/packages/logger/test/tsconfig.json +++ b/packages/logger/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/packages/make-dedicated-lockfile/package.json b/packages/make-dedicated-lockfile/package.json index 16aee59364..02232e73e0 100644 --- a/packages/make-dedicated-lockfile/package.json +++ b/packages/make-dedicated-lockfile/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "bin": "./bin/make-dedicated-lockfile.js", "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/packages/make-dedicated-lockfile/src/index.ts b/packages/make-dedicated-lockfile/src/index.ts index f5793c5506..fe7ad32844 100644 --- a/packages/make-dedicated-lockfile/src/index.ts +++ b/packages/make-dedicated-lockfile/src/index.ts @@ -10,7 +10,7 @@ import { import { pruneSharedLockfile } from '@pnpm/lockfile.pruner' import { readProjectManifest } from '@pnpm/read-project-manifest' import { DEPENDENCIES_FIELDS, type ProjectId } from '@pnpm/types' -import pickBy from 'ramda/src/pickBy' +import { pickBy } from 'ramda' import renameOverwrite from 'rename-overwrite' export async function makeDedicatedLockfile (lockfileDir: string, projectDir: string): Promise { @@ -57,7 +57,7 @@ export async function makeDedicatedLockfile (lockfileDir: string, projectDir: st } try { - await pnpmExec([ + await pnpmExec.default([ 'install', '--frozen-lockfile', '--lockfile-dir=.', diff --git a/packages/make-dedicated-lockfile/test/index.ts b/packages/make-dedicated-lockfile/test/index.ts index 44244ffed8..b87ef8d89b 100644 --- a/packages/make-dedicated-lockfile/test/index.ts +++ b/packages/make-dedicated-lockfile/test/index.ts @@ -5,8 +5,8 @@ import { readWantedLockfile } from '@pnpm/lockfile.fs' import { fixtures } from '@pnpm/test-fixtures' import { makeDedicatedLockfile } from '../lib/index.js' -const f = fixtures(__dirname) -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const f = fixtures(import.meta.dirname) +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') test('makeDedicatedLockfile()', async () => { const tmp = f.prepare('fixture') diff --git a/packages/make-dedicated-lockfile/test/tsconfig.json b/packages/make-dedicated-lockfile/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/packages/make-dedicated-lockfile/test/tsconfig.json +++ b/packages/make-dedicated-lockfile/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/packages/parse-wanted-dependency/package.json b/packages/parse-wanted-dependency/package.json index e116fc7e1f..1aaf11c2d4 100644 --- a/packages/parse-wanted-dependency/package.json +++ b/packages/parse-wanted-dependency/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/packages/plugin-commands-doctor/package.json b/packages/plugin-commands-doctor/package.json index f599868afa..a92efed75d 100644 --- a/packages/plugin-commands-doctor/package.json +++ b/packages/plugin-commands-doctor/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/packages/plugin-commands-doctor/test/tsconfig.json b/packages/plugin-commands-doctor/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/packages/plugin-commands-doctor/test/tsconfig.json +++ b/packages/plugin-commands-doctor/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/packages/plugin-commands-init/package.json b/packages/plugin-commands-init/package.json index cc8d418d91..51c9e2f373 100644 --- a/packages/plugin-commands-init/package.json +++ b/packages/plugin-commands-init/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", diff --git a/packages/plugin-commands-init/src/init.ts b/packages/plugin-commands-init/src/init.ts index 205a41d056..128760026e 100644 --- a/packages/plugin-commands-init/src/init.ts +++ b/packages/plugin-commands-init/src/init.ts @@ -7,7 +7,7 @@ import { PnpmError } from '@pnpm/error' import { sortKeysByPriority } from '@pnpm/object.key-sorting' import { type ProjectManifest } from '@pnpm/types' import { writeProjectManifest } from '@pnpm/write-project-manifest' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { parseRawConfig } from './utils.js' diff --git a/packages/plugin-commands-init/test/tsconfig.json b/packages/plugin-commands-init/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/packages/plugin-commands-init/test/tsconfig.json +++ b/packages/plugin-commands-init/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/packages/plugin-commands-init/test/utils.test.ts b/packages/plugin-commands-init/test/utils.test.ts index b8afaac67f..e82fcfefaa 100644 --- a/packages/plugin-commands-init/test/utils.test.ts +++ b/packages/plugin-commands-init/test/utils.test.ts @@ -3,7 +3,7 @@ import fs from 'fs' import path from 'path' import { workWithInitModule, personToString } from '../lib/utils.js' -const f = fixtures(path.join(__dirname, '../fixtures')) +const f = fixtures(path.join(import.meta.dirname, '../fixtures')) test('run the workWithInitModule function', async () => { const dir = f.prepare('init-module') diff --git a/packages/plugin-commands-setup/package.json b/packages/plugin-commands-setup/package.json index 0f130c347b..e2eeb1072f 100644 --- a/packages/plugin-commands-setup/package.json +++ b/packages/plugin-commands-setup/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/packages/plugin-commands-setup/src/setup.ts b/packages/plugin-commands-setup/src/setup.ts index 99aa07425d..dcdbbcdc74 100644 --- a/packages/plugin-commands-setup/src/setup.ts +++ b/packages/plugin-commands-setup/src/setup.ts @@ -49,7 +49,7 @@ function getExecPath (): string { // Instead, we use the path to the exe file. return process.execPath } - return (require.main != null) ? require.main.filename : process.cwd() + return process.argv[1] ?? process.cwd() } function copyCli (currentLocation: string, targetDir: string): void { diff --git a/packages/plugin-commands-setup/test/setup.test.ts b/packages/plugin-commands-setup/test/setup.test.ts index 59a96bd93f..02ee08aaba 100644 --- a/packages/plugin-commands-setup/test/setup.test.ts +++ b/packages/plugin-commands-setup/test/setup.test.ts @@ -1,25 +1,25 @@ import { PnpmError } from '@pnpm/error' -import { setup } from '@pnpm/plugin-commands-setup' -import { addDirToEnvPath, type PathExtenderReport } from '@pnpm/os.env.path-extender' import { jest } from '@jest/globals' +import { type PathExtenderReport } from '@pnpm/os.env.path-extender' -jest.mock('@pnpm/os.env.path-extender', () => ({ +jest.unstable_mockModule('@pnpm/os.env.path-extender', () => ({ addDirToEnvPath: jest.fn(), })) -jest.mock('fs', () => { - const actualFs = jest.createMockFromModule('fs') +const actualFs = await import('fs') +jest.unstable_mockModule('fs', () => { return { - // @ts-expect-error ...actualFs, promises: { - // @ts-expect-error ...actualFs.promises, writeFile: jest.fn(), }, } }) +const { addDirToEnvPath } = await import('@pnpm/os.env.path-extender') +const { setup } = await import('@pnpm/plugin-commands-setup') + test('setup makes no changes', async () => { jest.mocked(addDirToEnvPath).mockReturnValue(Promise.resolve({ oldSettings: 'PNPM_HOME=dir', diff --git a/packages/plugin-commands-setup/test/tsconfig.json b/packages/plugin-commands-setup/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/packages/plugin-commands-setup/test/tsconfig.json +++ b/packages/plugin-commands-setup/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/packages/render-peer-issues/package.json b/packages/render-peer-issues/package.json index 179ea6b36a..7697d49333 100644 --- a/packages/render-peer-issues/package.json +++ b/packages/render-peer-issues/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -24,7 +24,7 @@ "!*.map" ], "scripts": { - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/packages/render-peer-issues/test/tsconfig.json b/packages/render-peer-issues/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/packages/render-peer-issues/test/tsconfig.json +++ b/packages/render-peer-issues/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/packages/types/package.json b/packages/types/package.json index f86fcdc610..e49ffd8411 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/patching/apply-patch/package.json b/patching/apply-patch/package.json index 2db9e4ae25..f6a8b16257 100644 --- a/patching/apply-patch/package.json +++ b/patching/apply-patch/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ "!*.map" ], "scripts": { - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", diff --git a/patching/apply-patch/test/applyPatchToDir.ts b/patching/apply-patch/test/applyPatchToDir.ts index 76e1a0a4f4..34539fed39 100644 --- a/patching/apply-patch/test/applyPatchToDir.ts +++ b/patching/apply-patch/test/applyPatchToDir.ts @@ -1,21 +1,22 @@ import fs from 'fs' import path from 'path' -import { applyPatchToDir } from '@pnpm/patching.apply-patch' import { fixtures } from '@pnpm/test-fixtures' import { tempDir } from '@pnpm/prepare' -import { globalWarn } from '@pnpm/logger' import { jest } from '@jest/globals' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) -jest.mock('@pnpm/logger', () => { - const originalModule = jest.requireActual('@pnpm/logger') +const originalModule = await import('@pnpm/logger') +jest.unstable_mockModule('@pnpm/logger', () => { return { ...originalModule, globalWarn: jest.fn(), } }) +const { globalWarn } = await import('@pnpm/logger') +const { applyPatchToDir } = await import('@pnpm/patching.apply-patch') + beforeEach(() => { jest.mocked(globalWarn).mockClear() }) diff --git a/patching/apply-patch/test/tsconfig.json b/patching/apply-patch/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/patching/apply-patch/test/tsconfig.json +++ b/patching/apply-patch/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/patching/config/package.json b/patching/config/package.json index 8e40967df3..821fa9a33f 100644 --- a/patching/config/package.json +++ b/patching/config/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ "!*.map" ], "scripts": { - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", diff --git a/patching/config/test/tsconfig.json b/patching/config/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/patching/config/test/tsconfig.json +++ b/patching/config/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/patching/plugin-commands-patching/package.json b/patching/plugin-commands-patching/package.json index e5240e7220..e04bf8f560 100644 --- a/patching/plugin-commands-patching/package.json +++ b/patching/plugin-commands-patching/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ "scripts": { "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/patching/plugin-commands-patching/src/getPatchedDependency.ts b/patching/plugin-commands-patching/src/getPatchedDependency.ts index f3e011ebff..e0c755d8ef 100644 --- a/patching/plugin-commands-patching/src/getPatchedDependency.ts +++ b/patching/plugin-commands-patching/src/getPatchedDependency.ts @@ -1,6 +1,6 @@ import path from 'path' import { parseWantedDependency, type ParseWantedDependencyResult } from '@pnpm/parse-wanted-dependency' -import { prompt } from 'enquirer' +import enquirer from 'enquirer' import { readCurrentLockfile, type TarballResolution } from '@pnpm/lockfile.fs' import { nameVerFromPkgSnapshot } from '@pnpm/lockfile.utils' import { PnpmError } from '@pnpm/error' @@ -29,7 +29,7 @@ export async function getPatchedDependency (rawDependency: string, opts: GetPatc dep.alias = dep.alias ?? rawDependency if (preferredVersions.length > 1) { - const { version, applyToAll } = await prompt<{ + const { version, applyToAll } = await enquirer.prompt<{ version: string applyToAll: boolean }>([{ diff --git a/patching/plugin-commands-patching/src/index.ts b/patching/plugin-commands-patching/src/index.ts index c0e02b588b..9d2fb164d1 100644 --- a/patching/plugin-commands-patching/src/index.ts +++ b/patching/plugin-commands-patching/src/index.ts @@ -1,5 +1,7 @@ import * as patch from './patch.js' import * as patchCommit from './patchCommit.js' import * as patchRemove from './patchRemove.js' +export { type PatchCommandOptions } from './patch.js' +export { type PatchRemoveCommandOptions } from './patchRemove.js' export { patch, patchCommit, patchRemove } diff --git a/patching/plugin-commands-patching/src/patch.ts b/patching/plugin-commands-patching/src/patch.ts index 7cc8a365a6..e9c6877451 100644 --- a/patching/plugin-commands-patching/src/patch.ts +++ b/patching/plugin-commands-patching/src/patch.ts @@ -7,7 +7,7 @@ import { type LogBase } from '@pnpm/logger' import { type CreateStoreControllerOptions, } from '@pnpm/store-connection-manager' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import chalk from 'chalk' import terminalLink from 'terminal-link' diff --git a/patching/plugin-commands-patching/src/patchCommit.ts b/patching/plugin-commands-patching/src/patchCommit.ts index 1eeb9f85fd..edd097384e 100644 --- a/patching/plugin-commands-patching/src/patchCommit.ts +++ b/patching/plugin-commands-patching/src/patchCommit.ts @@ -12,8 +12,7 @@ import { getStorePath } from '@pnpm/store-path' import { type ProjectRootDir } from '@pnpm/types' import { glob } from 'tinyglobby' import normalizePath from 'normalize-path' -import pick from 'ramda/src/pick' -import equals from 'ramda/src/equals' +import { pick, equals } from 'ramda' import execa from 'safe-execa' import escapeStringRegexp from 'escape-string-regexp' import makeEmptyDir from 'make-empty-dir' diff --git a/patching/plugin-commands-patching/src/patchRemove.ts b/patching/plugin-commands-patching/src/patchRemove.ts index 5efb301b3f..1d6a7fd3df 100644 --- a/patching/plugin-commands-patching/src/patchRemove.ts +++ b/patching/plugin-commands-patching/src/patchRemove.ts @@ -5,8 +5,8 @@ import { install } from '@pnpm/plugin-commands-installation' import { type Config, types as allTypes } from '@pnpm/config' import { PnpmError } from '@pnpm/error' import renderHelp from 'render-help' -import { prompt } from 'enquirer' -import pick from 'ramda/src/pick' +import enquirer from 'enquirer' +import { pick } from 'ramda' import { updatePatchedDependencies } from './updatePatchedDependencies.js' export function rcOptionsTypes (): Record { @@ -36,7 +36,7 @@ export async function handler (opts: PatchRemoveCommandOptions, params: string[] if (!params.length) { const allPatches = Object.keys(patchedDependencies) if (allPatches.length) { - ({ patches: patchesToRemove } = await prompt<{ + ({ patches: patchesToRemove } = await enquirer.prompt<{ patches: string[] }>({ type: 'multiselect', diff --git a/patching/plugin-commands-patching/test/patch.test.ts b/patching/plugin-commands-patching/test/patch.test.ts index 79276438cb..ccda3b33aa 100644 --- a/patching/plugin-commands-patching/test/patch.test.ts +++ b/patching/plugin-commands-patching/test/patch.test.ts @@ -6,20 +6,20 @@ import { install } from '@pnpm/plugin-commands-installation' import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir' import { sync as writeYamlFile } from 'write-yaml-file' import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest' +import { type PatchCommandOptions, type PatchRemoveCommandOptions } from '@pnpm/plugin-commands-patching' import tempy from 'tempy' -import { patch, patchCommit, patchRemove } from '@pnpm/plugin-commands-patching' import { readProjectManifest } from '@pnpm/read-project-manifest' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import { DEFAULT_OPTS } from './utils/index.js' import { fixtures } from '@pnpm/test-fixtures' import { jest } from '@jest/globals' -import * as enquirer from 'enquirer' -jest.mock('enquirer', () => ({ prompt: jest.fn() })) +jest.unstable_mockModule('enquirer', () => ({ default: { prompt: jest.fn() } })) +const { default: enquirer } = await import('enquirer') +const { patch, patchCommit, patchRemove } = await import('@pnpm/plugin-commands-patching') -// eslint-disable-next-line -const prompt = enquirer.prompt as any -const f = fixtures(__dirname) +const prompt = jest.mocked(enquirer.prompt) +const f = fixtures(import.meta.dirname) const basePatchOption = { pnpmHomeDir: '', @@ -33,7 +33,7 @@ const basePatchOption = { } describe('patch and commit', () => { - let defaultPatchOption: patch.PatchCommandOptions + let defaultPatchOption: PatchCommandOptions let cacheDir: string let storeDir: string @@ -624,7 +624,7 @@ describe('patch and commit', () => { }) describe('multiple versions', () => { - let defaultPatchOption: patch.PatchCommandOptions + let defaultPatchOption: PatchCommandOptions let cacheDir: string let storeDir: string beforeEach(() => { @@ -718,7 +718,7 @@ describe('multiple versions', () => { }) describe('prompt to choose version', () => { - let defaultPatchOption: patch.PatchCommandOptions + let defaultPatchOption: PatchCommandOptions let cacheDir: string let storeDir: string beforeEach(() => { @@ -874,7 +874,7 @@ describe('prompt to choose version', () => { }) describe('patching should work when there is a no EOL in the patched file', () => { - let defaultPatchOption: patch.PatchCommandOptions + let defaultPatchOption: PatchCommandOptions beforeEach(async () => { prepare({ @@ -960,7 +960,7 @@ describe('patching should work when there is a no EOL in the patched file', () = }) describe('patch and commit in workspaces', () => { - let defaultPatchOption: patch.PatchCommandOptions + let defaultPatchOption: PatchCommandOptions let cacheDir: string let storeDir: string @@ -1269,7 +1269,7 @@ describe('patch and commit in workspaces', () => { }) describe('patch with custom modules-dir and virtual-store-dir', () => { - let defaultPatchOption: patch.PatchCommandOptions + let defaultPatchOption: PatchCommandOptions let customModulesDirFixture: string let cacheDir: string let storeDir: string @@ -1329,7 +1329,7 @@ describe('patch with custom modules-dir and virtual-store-dir', () => { }) describe('patch-remove', () => { - let defaultPatchRemoveOption: patchRemove.PatchRemoveCommandOptions + let defaultPatchRemoveOption: PatchRemoveCommandOptions let cacheDir: string let storeDir: string @@ -1395,7 +1395,8 @@ describe('patch-remove', () => { rootProjectManifest: manifest, patchedDependencies: manifest.pnpm.patchedDependencies, }, []) - expect(prompt.mock.calls[0][0].choices).toEqual(expect.arrayContaining(['is-positive@1.0.0', 'chalk@4.1.2'])) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + expect((prompt.mock.calls[0][0] as any).choices).toEqual(expect.arrayContaining(['is-positive@1.0.0', 'chalk@4.1.2'])) prompt.mockClear() const { manifest: newManifest } = await readProjectManifest(process.cwd()) diff --git a/patching/plugin-commands-patching/test/tsconfig.json b/patching/plugin-commands-patching/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/patching/plugin-commands-patching/test/tsconfig.json +++ b/patching/plugin-commands-patching/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/patching/types/package.json b/patching/types/package.json index 913e770812..3cc7a64d68 100644 --- a/patching/types/package.json +++ b/patching/types/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/pkg-manager/client/package.json b/pkg-manager/client/package.json index 2459f9b492..29ae313056 100644 --- a/pkg-manager/client/package.json +++ b/pkg-manager/client/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/pkg-manager/client/src/index.ts b/pkg-manager/client/src/index.ts index 5e192f7f4e..17c840e73e 100644 --- a/pkg-manager/client/src/index.ts +++ b/pkg-manager/client/src/index.ts @@ -12,7 +12,7 @@ import { createGitFetcher } from '@pnpm/git-fetcher' import { createTarballFetcher, type TarballFetchers } from '@pnpm/tarball-fetcher' import { createGetAuthHeaderByURI } from '@pnpm/network.auth-header' import { createBinaryFetcher } from '@pnpm/fetching.binary-fetcher' -import mapValues from 'ramda/src/map' +import { map as mapValues } from 'ramda' export type { ResolveFunction } diff --git a/pkg-manager/client/test/tsconfig.json b/pkg-manager/client/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/client/test/tsconfig.json +++ b/pkg-manager/client/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manager/core/package.json b/pkg-manager/core/package.json index 1b906db84e..8887ccb1b1 100644 --- a/pkg-manager/core/package.json +++ b/pkg-manager/core/package.json @@ -33,7 +33,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -50,7 +50,7 @@ "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "test-with-preview": "preview && pnpm run test:e2e", - "_test": "cross-env PNPM_REGISTRY_MOCK_PORT=7769 jest", + "_test": "cross-env PNPM_REGISTRY_MOCK_PORT=7769 NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index e793c288a2..52b0e3b429 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -73,11 +73,7 @@ import { } from '@pnpm/types' import isSubdir from 'is-subdir' import pLimit from 'p-limit' -import mapValues from 'ramda/src/map' -import clone from 'ramda/src/clone' -import isEmpty from 'ramda/src/isEmpty' -import pipeWith from 'ramda/src/pipeWith' -import props from 'ramda/src/props' +import { map as mapValues, clone, isEmpty, pipeWith, props } from 'ramda' import { parseWantedDependencies } from '../parseWantedDependencies.js' import { removeDeps } from '../uninstall/removeDeps.js' import { diff --git a/pkg-manager/core/src/install/link.ts b/pkg-manager/core/src/install/link.ts index 0e17a1ed2c..a5764b0a38 100644 --- a/pkg-manager/core/src/install/link.ts +++ b/pkg-manager/core/src/install/link.ts @@ -32,12 +32,7 @@ import { import { symlinkAllModules } from '@pnpm/worker' import pLimit from 'p-limit' import pathExists from 'path-exists' -import equals from 'ramda/src/equals' -import isEmpty from 'ramda/src/isEmpty' -import difference from 'ramda/src/difference' -import pick from 'ramda/src/pick' -import pickBy from 'ramda/src/pickBy' -import props from 'ramda/src/props' +import { equals, isEmpty, difference, pick, pickBy, props } from 'ramda' import { type ImporterToUpdate } from './index.js' const brokenModulesLogger = logger('_broken_node_modules') diff --git a/pkg-manager/core/src/install/reportPeerDependencyIssues.ts b/pkg-manager/core/src/install/reportPeerDependencyIssues.ts index a8313fc67e..28cbb37c7b 100644 --- a/pkg-manager/core/src/install/reportPeerDependencyIssues.ts +++ b/pkg-manager/core/src/install/reportPeerDependencyIssues.ts @@ -3,7 +3,7 @@ import { createMatcher } from '@pnpm/matcher' import { peerDependencyIssuesLogger } from '@pnpm/core-loggers' import { type PeerDependencyIssuesByProjects, type PeerDependencyRules, type BadPeerDependencyIssue } from '@pnpm/types' import semver from 'semver' -import isEmpty from 'ramda/src/isEmpty' +import { isEmpty } from 'ramda' import { parseOverrides, type VersionOverride } from '@pnpm/parse-overrides' export function reportPeerDependencyIssues ( diff --git a/pkg-manager/core/src/install/validateModules.ts b/pkg-manager/core/src/install/validateModules.ts index 37d4d428dc..fe387e70bb 100644 --- a/pkg-manager/core/src/install/validateModules.ts +++ b/pkg-manager/core/src/install/validateModules.ts @@ -13,7 +13,7 @@ import { } from '@pnpm/types' import rimraf from '@zkochan/rimraf' import enquirer from 'enquirer' -import equals from 'ramda/src/equals' +import { equals } from 'ramda' import { checkCompatibility } from './checkCompatibility/index.js' interface ImporterToPurge { diff --git a/pkg-manager/core/src/pnpmPkgJson.ts b/pkg-manager/core/src/pnpmPkgJson.ts index a3e392da52..b59975dbc1 100644 --- a/pkg-manager/core/src/pnpmPkgJson.ts +++ b/pkg-manager/core/src/pnpmPkgJson.ts @@ -4,7 +4,7 @@ import { sync as loadJsonFileSync } from 'load-json-file' let pnpmPkgJson!: PackageManifest try { - pnpmPkgJson = loadJsonFileSync(path.resolve(__dirname, '../package.json')) + pnpmPkgJson = loadJsonFileSync(path.resolve(import.meta.dirname, '../package.json')) } catch (err: any) { // eslint-disable-line pnpmPkgJson = { name: 'pnpm', diff --git a/pkg-manager/core/test/brokenLockfileIntegrity.ts b/pkg-manager/core/test/brokenLockfileIntegrity.ts index 76e73dc321..bf8467a9da 100644 --- a/pkg-manager/core/test/brokenLockfileIntegrity.ts +++ b/pkg-manager/core/test/brokenLockfileIntegrity.ts @@ -5,7 +5,7 @@ import { addDistTag } from '@pnpm/registry-mock' import { type ProjectRootDir } from '@pnpm/types' import { sync as rimraf } from '@zkochan/rimraf' import { jest } from '@jest/globals' -import clone from 'ramda/src/clone' +import { clone } from 'ramda' import { addDependenciesToPackage, mutateModulesInSingleProject, diff --git a/pkg-manager/core/test/catalogs.ts b/pkg-manager/core/test/catalogs.ts index de56d79982..b5181242db 100644 --- a/pkg-manager/core/test/catalogs.ts +++ b/pkg-manager/core/test/catalogs.ts @@ -2,20 +2,22 @@ import { createPeerDepGraphHash } from '@pnpm/dependency-path' import { type ProjectRootDir, type ProjectId, type ProjectManifest } from '@pnpm/types' import { prepareEmpty } from '@pnpm/prepare' import { addDistTag } from '@pnpm/registry-mock' -import { type MutatedProject, mutateModules, type ProjectOptions, type MutateModulesOptions, addDependenciesToPackage } from '@pnpm/core' +import { type MutatedProject, type ProjectOptions, type MutateModulesOptions } from '@pnpm/core' import { type CatalogSnapshots } from '@pnpm/lockfile.types' -import { logger } from '@pnpm/logger' import { jest } from '@jest/globals' import { sync as loadJsonFile } from 'load-json-file' import path from 'path' import { testDefaults } from './utils/index.js' -jest.mock('@pnpm/logger', () => { - const originalModule = jest.requireActual('@pnpm/logger') // eslint-disable-line +const originalModule = await import('@pnpm/logger') +jest.unstable_mockModule('@pnpm/logger', () => { originalModule.logger.warn = jest.fn() return originalModule }) +const { logger } = await import('@pnpm/logger') +const { mutateModules, addDependenciesToPackage } = await import('@pnpm/core') + function preparePackagesAndReturnObjects (manifests: Array>>) { const project = prepareEmpty() const lockfileDir = process.cwd() diff --git a/pkg-manager/core/test/hoistedNodeLinker/install.ts b/pkg-manager/core/test/hoistedNodeLinker/install.ts index 80c17b9d0d..07b1bc39da 100644 --- a/pkg-manager/core/test/hoistedNodeLinker/install.ts +++ b/pkg-manager/core/test/hoistedNodeLinker/install.ts @@ -78,7 +78,7 @@ test('overwriting (is-positive@3.0.0 with is-positive@latest)', async () => { test('overwriting existing files in node_modules', async () => { prepareEmpty() - await symlinkDir(__dirname, path.resolve('node_modules/is-positive')) + await symlinkDir(import.meta.dirname, path.resolve('node_modules/is-positive')) const { updatedManifest: manifest } = await addDependenciesToPackage( {}, diff --git a/pkg-manager/core/test/install/bundledDependencies.ts b/pkg-manager/core/test/install/bundledDependencies.ts index be08272ad0..7e009231cd 100644 --- a/pkg-manager/core/test/install/bundledDependencies.ts +++ b/pkg-manager/core/test/install/bundledDependencies.ts @@ -3,7 +3,7 @@ import { fixtures } from '@pnpm/test-fixtures' import { addDependenciesToPackage } from '@pnpm/core' import { testDefaults } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('bundledDependencies (pkg-with-bundled-dependencies@1.0.0)', async () => { const project = prepareEmpty() diff --git a/pkg-manager/core/test/install/errors.ts b/pkg-manager/core/test/install/errors.ts index 9838da4f35..0b143e7fb3 100644 --- a/pkg-manager/core/test/install/errors.ts +++ b/pkg-manager/core/test/install/errors.ts @@ -8,7 +8,7 @@ import loadJsonFile from 'load-json-file' import nock from 'nock' import { testDefaults } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('fail if none of the available resolvers support a version spec', async () => { prepareEmpty() diff --git a/pkg-manager/core/test/install/excludeLinksFromLockfile.ts b/pkg-manager/core/test/install/excludeLinksFromLockfile.ts index 4fbfdc5e68..36c89bb83b 100644 --- a/pkg-manager/core/test/install/excludeLinksFromLockfile.ts +++ b/pkg-manager/core/test/install/excludeLinksFromLockfile.ts @@ -19,7 +19,7 @@ import { sync as readYamlFile } from 'read-yaml-file' import { sync as writeJsonFile } from 'write-json-file' import { testDefaults } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('links are not added to the lockfile when excludeLinksFromLockfile is true', async () => { const externalPkg1 = tempDir(false) diff --git a/pkg-manager/core/test/install/fromRepo.ts b/pkg-manager/core/test/install/fromRepo.ts index 2bf5202949..12c133e932 100644 --- a/pkg-manager/core/test/install/fromRepo.ts +++ b/pkg-manager/core/test/install/fromRepo.ts @@ -14,7 +14,7 @@ import { isCI } from 'ci-info' import sinon from 'sinon' import { testDefaults } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const withGitProtocolDepFixture = f.find('with-git-protocol-dep') test('from a github repo', async () => { diff --git a/pkg-manager/core/test/install/gitBranchLockfile.test.ts b/pkg-manager/core/test/install/gitBranchLockfile.test.ts index 0a6bbe4b9f..74e904d840 100644 --- a/pkg-manager/core/test/install/gitBranchLockfile.test.ts +++ b/pkg-manager/core/test/install/gitBranchLockfile.test.ts @@ -1,15 +1,16 @@ import fs from 'fs' import path from 'path' import { prepareEmpty, preparePackages } from '@pnpm/prepare' -import { install, mutateModules } from '@pnpm/core' import { testDefaults } from '../utils/index.js' import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { type ProjectRootDir, type ProjectManifest } from '@pnpm/types' -import { getCurrentBranch } from '@pnpm/git-utils' import { jest } from '@jest/globals' import { sync as writeYamlFile } from 'write-yaml-file' -jest.mock('@pnpm/git-utils', () => ({ getCurrentBranch: jest.fn() })) +jest.unstable_mockModule('@pnpm/git-utils', () => ({ getCurrentBranch: jest.fn() })) + +const { getCurrentBranch } = await import('@pnpm/git-utils') +const { install, mutateModules } = await import('@pnpm/core') test('install with git-branch-lockfile = true', async () => { prepareEmpty() diff --git a/pkg-manager/core/test/install/local.ts b/pkg-manager/core/test/install/local.ts index b6d61c9cf8..abe5dfb6a8 100644 --- a/pkg-manager/core/test/install/local.ts +++ b/pkg-manager/core/test/install/local.ts @@ -20,7 +20,7 @@ import { sync as readYamlFile } from 'read-yaml-file' import symlinkDir from 'symlink-dir' import { testDefaults } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('scoped modules from a directory', async () => { const project = prepareEmpty() @@ -237,7 +237,7 @@ test('update tarball local package when its integrity changes', async () => { const lockfile2 = project.readLockfile() expect(lockfile2.snapshots['tar-pkg-with-dep@file:../tar.tgz'].dependencies!['is-positive']).toBe('2.0.0') - const manifestOfTarballDep = await import(path.resolve('node_modules/tar-pkg-with-dep/package.json')) + const { default: manifestOfTarballDep } = await import(path.resolve('node_modules/tar-pkg-with-dep/package.json')) expect(manifestOfTarballDep.dependencies['is-positive']).toBe('^2.0.0') }) diff --git a/pkg-manager/core/test/install/lockfileDir.ts b/pkg-manager/core/test/install/lockfileDir.ts index a7f85e67d7..596845a5cc 100644 --- a/pkg-manager/core/test/install/lockfileDir.ts +++ b/pkg-manager/core/test/install/lockfileDir.ts @@ -9,7 +9,7 @@ import { type ProjectRootDir, type DepPath } from '@pnpm/types' import { sync as rimraf } from '@zkochan/rimraf' import { testDefaults } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test.skip('subsequent installation uses same lockfile directory by default', async () => { prepareEmpty() diff --git a/pkg-manager/core/test/install/misc.ts b/pkg-manager/core/test/install/misc.ts index eed8b840f9..a544e84a18 100644 --- a/pkg-manager/core/test/install/misc.ts +++ b/pkg-manager/core/test/install/misc.ts @@ -29,7 +29,7 @@ import deepRequireCwd from 'deep-require-cwd' import { sync as writeYamlFile } from 'write-yaml-file' import { testDefaults } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const IS_WINDOWS = isWindows() const testOnNonWindows = IS_WINDOWS ? test.skip : test diff --git a/pkg-manager/core/test/install/patch.ts b/pkg-manager/core/test/install/patch.ts index 5c52e586a4..67dc10f35f 100644 --- a/pkg-manager/core/test/install/patch.ts +++ b/pkg-manager/core/test/install/patch.ts @@ -13,7 +13,7 @@ import loadJsonFile from 'load-json-file' import sinon from 'sinon' import { testDefaults } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('patch package with exact version', async () => { const reporter = sinon.spy() diff --git a/pkg-manager/core/test/install/peerDependencies.ts b/pkg-manager/core/test/install/peerDependencies.ts index 3fd07fbb1e..b64e586217 100644 --- a/pkg-manager/core/test/install/peerDependencies.ts +++ b/pkg-manager/core/test/install/peerDependencies.ts @@ -23,7 +23,7 @@ import deepRequireCwd from 'deep-require-cwd' import { createPeerDepGraphHash, depPathToFilename } from '@pnpm/dependency-path' import { testDefaults } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test("don't fail when peer dependency is fetched from GitHub", async () => { prepareEmpty() diff --git a/pkg-manager/core/test/install/setExtraNodePath.ts b/pkg-manager/core/test/install/setExtraNodePath.ts index adb5366eb3..d33b037fa6 100644 --- a/pkg-manager/core/test/install/setExtraNodePath.ts +++ b/pkg-manager/core/test/install/setExtraNodePath.ts @@ -10,7 +10,7 @@ import { import { type ProjectRootDir } from '@pnpm/types' import { testDefaults } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('jest CLI should print the right version when multiple instances of jest are used in a workspace', async () => { preparePackages([ diff --git a/pkg-manager/core/test/link.ts b/pkg-manager/core/test/link.ts index 548b78c2b0..63d7b4503c 100644 --- a/pkg-manager/core/test/link.ts +++ b/pkg-manager/core/test/link.ts @@ -6,7 +6,7 @@ import { addDistTag } from '@pnpm/registry-mock' import symlinkDir from 'symlink-dir' import { testDefaults } from './utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('relative link is linked by the name of the alias', async () => { const linkedPkgName = 'hello-world-js-bin' diff --git a/pkg-manager/core/test/lockfile.ts b/pkg-manager/core/test/lockfile.ts index 4ebc225e87..fcbb5797dc 100644 --- a/pkg-manager/core/test/lockfile.ts +++ b/pkg-manager/core/test/lockfile.ts @@ -27,7 +27,7 @@ import sinon from 'sinon' import { sync as writeYamlFile } from 'write-yaml-file' import { testDefaults } from './utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const LOCKFILE_WARN_LOG = { level: 'warn', @@ -1059,7 +1059,7 @@ test('broken lockfile is fixed even if it seems like up to date at first. Unless expect(lockfile.packages).toHaveProperty(['@pnpm.e2e/dep-of-pkg-with-1-dep@100.0.0']) }) -const REGISTRY_MIRROR_DIR = path.join(__dirname, './registry-mirror') +const REGISTRY_MIRROR_DIR = path.join(import.meta.dirname, './registry-mirror') /* eslint-disable @typescript-eslint/no-explicit-any */ const isPositiveMeta = loadJsonFile.sync(path.join(REGISTRY_MIRROR_DIR, 'is-positive.json')) diff --git a/pkg-manager/core/test/prune.ts b/pkg-manager/core/test/prune.ts index 08a78c7a07..e6ba0494d3 100644 --- a/pkg-manager/core/test/prune.ts +++ b/pkg-manager/core/test/prune.ts @@ -12,7 +12,7 @@ import sinon from 'sinon' import symlinkDir from 'symlink-dir' import { testDefaults } from './utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('prune removes extraneous packages', async () => { const linkedPkg = f.prepare('hello-world-js-bin') diff --git a/pkg-manager/core/test/tsconfig.json b/pkg-manager/core/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/core/test/tsconfig.json +++ b/pkg-manager/core/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manager/core/test/uninstall.ts b/pkg-manager/core/test/uninstall.ts index f55a838a2e..2f6e5d2976 100644 --- a/pkg-manager/core/test/uninstall.ts +++ b/pkg-manager/core/test/uninstall.ts @@ -23,7 +23,7 @@ import writeJsonFile from 'write-json-file' import existsSymlink from 'exists-link' import { testDefaults } from './utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('uninstall package with no dependencies', async () => { const project = prepareEmpty() diff --git a/pkg-manager/direct-dep-linker/package.json b/pkg-manager/direct-dep-linker/package.json index 7ca2861128..c392f5b5f6 100644 --- a/pkg-manager/direct-dep-linker/package.json +++ b/pkg-manager/direct-dep-linker/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/pkg-manager/direct-dep-linker/src/linkDirectDeps.ts b/pkg-manager/direct-dep-linker/src/linkDirectDeps.ts index ddcefe1b31..2c757b75ce 100644 --- a/pkg-manager/direct-dep-linker/src/linkDirectDeps.ts +++ b/pkg-manager/direct-dep-linker/src/linkDirectDeps.ts @@ -2,7 +2,7 @@ import fs from 'fs' import path from 'path' import { rootLogger } from '@pnpm/core-loggers' import { symlinkDependency, symlinkDirectRootDependency } from '@pnpm/symlink-dependency' -import omit from 'ramda/src/omit' +import { omit } from 'ramda' import { readModulesDir } from '@pnpm/read-modules-dir' import rimraf from '@zkochan/rimraf' import resolveLinkTarget from 'resolve-link-target' diff --git a/pkg-manager/get-context/package.json b/pkg-manager/get-context/package.json index 6eb18aaf25..7415c47786 100644 --- a/pkg-manager/get-context/package.json +++ b/pkg-manager/get-context/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/pkg-manager/get-context/src/index.ts b/pkg-manager/get-context/src/index.ts index 22ff8f97aa..7adf2c19ca 100644 --- a/pkg-manager/get-context/src/index.ts +++ b/pkg-manager/get-context/src/index.ts @@ -20,7 +20,7 @@ import { type ProjectRootDirRealPath, } from '@pnpm/types' import pathAbsolute from 'path-absolute' -import clone from 'ramda/src/clone' +import { clone } from 'ramda' import { readLockfiles } from './readLockfiles.js' /** diff --git a/pkg-manager/get-context/src/readLockfiles.ts b/pkg-manager/get-context/src/readLockfiles.ts index dff1a924ec..2e5711f93d 100644 --- a/pkg-manager/get-context/src/readLockfiles.ts +++ b/pkg-manager/get-context/src/readLockfiles.ts @@ -13,8 +13,7 @@ import { } from '@pnpm/lockfile.fs' import { logger } from '@pnpm/logger' import { type ProjectId, type ProjectRootDir } from '@pnpm/types' -import clone from 'ramda/src/clone' -import equals from 'ramda/src/equals' +import { clone, equals } from 'ramda' export interface PnpmContext { currentLockfile: LockfileObject diff --git a/pkg-manager/get-context/test/index.ts b/pkg-manager/get-context/test/index.ts index 293f1165bf..6053208838 100644 --- a/pkg-manager/get-context/test/index.ts +++ b/pkg-manager/get-context/test/index.ts @@ -10,7 +10,7 @@ const DEFAULT_OPTIONS: GetContextOptions = { excludeLinksFromLockfile: false, extraBinPaths: [], force: false, - lockfileDir: path.join(__dirname, 'lockfile'), + lockfileDir: path.join(import.meta.dirname, 'lockfile'), nodeLinker: 'isolated', hoistPattern: ['*'], registries: { default: '' }, @@ -20,7 +20,7 @@ const DEFAULT_OPTIONS: GetContextOptions = { devDependencies: true, optionalDependencies: true, }, - storeDir: path.join(__dirname, 'store'), + storeDir: path.join(import.meta.dirname, 'store'), virtualStoreDirMaxLength: 120, peersSuffixMaxLength: 1000, } diff --git a/pkg-manager/get-context/test/tsconfig.json b/pkg-manager/get-context/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/get-context/test/tsconfig.json +++ b/pkg-manager/get-context/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manager/headless/package.json b/pkg-manager/headless/package.json index 91b44c51e8..9c92365b0d 100644 --- a/pkg-manager/headless/package.json +++ b/pkg-manager/headless/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -31,10 +31,10 @@ "scripts": { "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", - "runPrepareFixtures": "node ../../pnpm/bin/pnpm.cjs i -r -C test/fixtures --no-shared-workspace-lockfile --no-link-workspace-packages --lockfile-only --registry http://localhost:4873/ --ignore-scripts --force --no-strict-peer-dependencies", + "runPrepareFixtures": "node ../../pnpm/bin/pnpm.mjs i -r -C test/fixtures --no-shared-workspace-lockfile --no-link-workspace-packages --lockfile-only --registry http://localhost:4873/ --ignore-scripts --force --no-strict-peer-dependencies", "prepareFixtures": "git clean -fdx test/fixtures && rm -rf \"test/fixtures/*/pnpm-lock.yaml\" && registry-mock prepare && concurrently --success=first --kill-others registry-mock \"pnpm run runPrepareFixtures\"", "compile": "tsc --build && pnpm run lint --fix" }, diff --git a/pkg-manager/headless/src/index.ts b/pkg-manager/headless/src/index.ts index 7f88fcbeef..db0aa2c826 100644 --- a/pkg-manager/headless/src/index.ts +++ b/pkg-manager/headless/src/index.ts @@ -73,13 +73,7 @@ import * as dp from '@pnpm/dependency-path' import { symlinkAllModules } from '@pnpm/worker' import pLimit from 'p-limit' import pathAbsolute from 'path-absolute' -import equals from 'ramda/src/equals' -import isEmpty from 'ramda/src/isEmpty' -import omit from 'ramda/src/omit' -import pick from 'ramda/src/pick' -import pickBy from 'ramda/src/pickBy' -import props from 'ramda/src/props' -import union from 'ramda/src/union' +import { equals, isEmpty, omit, pick, pickBy, props, union } from 'ramda' import realpathMissing from 'realpath-missing' import { linkHoistedModules } from './linkHoistedModules.js' import { diff --git a/pkg-manager/headless/src/linkHoistedModules.ts b/pkg-manager/headless/src/linkHoistedModules.ts index 4d7e091e32..4eb5d71b1e 100644 --- a/pkg-manager/headless/src/linkHoistedModules.ts +++ b/pkg-manager/headless/src/linkHoistedModules.ts @@ -16,8 +16,7 @@ import { type StoreController, } from '@pnpm/store-controller-types' import pLimit from 'p-limit' -import difference from 'ramda/src/difference' -import isEmpty from 'ramda/src/isEmpty' +import { difference, isEmpty } from 'ramda' import rimraf from '@zkochan/rimraf' const limitLinking = pLimit(16) diff --git a/pkg-manager/headless/test/index.ts b/pkg-manager/headless/test/index.ts index b2be3ce69f..527d739aa2 100644 --- a/pkg-manager/headless/test/index.ts +++ b/pkg-manager/headless/test/index.ts @@ -26,7 +26,7 @@ import sinon from 'sinon' import writeJsonFile from 'write-json-file' import { testDefaults } from './utils/testDefaults.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('installing a simple project', async () => { const prefix = f.prepare('simple') diff --git a/pkg-manager/headless/test/tsconfig.json b/pkg-manager/headless/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/headless/test/tsconfig.json +++ b/pkg-manager/headless/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manager/hoist/package.json b/pkg-manager/hoist/package.json index ff2e61745f..db1388f86b 100644 --- a/pkg-manager/hoist/package.json +++ b/pkg-manager/hoist/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/pkg-manager/link-bins/package.json b/pkg-manager/link-bins/package.json index aba8034ea3..229d469472 100644 --- a/pkg-manager/link-bins/package.json +++ b/pkg-manager/link-bins/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "fix": "tslint -c tslint.json --project . --fix", diff --git a/pkg-manager/link-bins/src/index.ts b/pkg-manager/link-bins/src/index.ts index 8d821082ba..d82ab0c452 100644 --- a/pkg-manager/link-bins/src/index.ts +++ b/pkg-manager/link-bins/src/index.ts @@ -16,13 +16,10 @@ import isSubdir from 'is-subdir' import isWindows from 'is-windows' import normalizePath from 'normalize-path' import pSettle from 'p-settle' -import isEmpty from 'ramda/src/isEmpty' -import unnest from 'ramda/src/unnest' -import groupBy from 'ramda/src/groupBy' -import partition from 'ramda/src/partition' +import { isEmpty, unnest, groupBy, partition } from 'ramda' import semver from 'semver' import symlinkDir from 'symlink-dir' -import fixBin from 'bin-links/lib/fix-bin' +import fixBin from 'bin-links/lib/fix-bin.js' const binsConflictLogger = logger('bins-conflict') const IS_WINDOWS = isWindows() diff --git a/pkg-manager/link-bins/test/index.ts b/pkg-manager/link-bins/test/index.ts index 1422976613..7e391883de 100644 --- a/pkg-manager/link-bins/test/index.ts +++ b/pkg-manager/link-bins/test/index.ts @@ -1,12 +1,6 @@ /// import fs from 'fs' import path from 'path' -import { logger, globalWarn } from '@pnpm/logger' -import { - linkBins, - linkBinsOfPackages, - linkBinsOfPkgsByAliases, -} from '@pnpm/link-bins' import { fixtures } from '@pnpm/test-fixtures' import { jest } from '@jest/globals' import CMD_EXTENSION from 'cmd-extension' @@ -15,7 +9,7 @@ import normalizePath from 'normalize-path' import tempy from 'tempy' import { spawnSync } from 'child_process' -jest.mock('@pnpm/logger', () => { +jest.unstable_mockModule('@pnpm/logger', () => { const debug = jest.fn() const globalWarn = jest.fn() @@ -25,10 +19,17 @@ jest.mock('@pnpm/logger', () => { } }) +const { logger, globalWarn } = await import('@pnpm/logger') +const { + linkBins, + linkBinsOfPackages, + linkBinsOfPkgsByAliases, +} = await import('@pnpm/link-bins') + const binsConflictLogger = logger('bins-conflict') // The fixture directories are copied to before the tests run // This happens because the tests convert some of the files into executables -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) beforeEach(() => { jest.mocked(binsConflictLogger.debug).mockClear() diff --git a/pkg-manager/link-bins/test/tsconfig.json b/pkg-manager/link-bins/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/link-bins/test/tsconfig.json +++ b/pkg-manager/link-bins/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manager/modules-cleaner/package.json b/pkg-manager/modules-cleaner/package.json index 1b4318454f..fc3a40eea5 100644 --- a/pkg-manager/modules-cleaner/package.json +++ b/pkg-manager/modules-cleaner/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/pkg-manager/modules-cleaner/src/prune.ts b/pkg-manager/modules-cleaner/src/prune.ts index e0b43ef892..36495ea76b 100644 --- a/pkg-manager/modules-cleaner/src/prune.ts +++ b/pkg-manager/modules-cleaner/src/prune.ts @@ -24,10 +24,7 @@ import { } from '@pnpm/types' import { depPathToFilename } from '@pnpm/dependency-path' import rimraf from '@zkochan/rimraf' -import difference from 'ramda/src/difference' -import equals from 'ramda/src/equals' -import mergeAll from 'ramda/src/mergeAll' -import pickAll from 'ramda/src/pickAll' +import { difference, equals, mergeAll, pickAll } from 'ramda' import { removeDirectDependency, removeIfEmpty } from './removeDirectDependency.js' export async function prune ( diff --git a/pkg-manager/modules-yaml/package.json b/pkg-manager/modules-yaml/package.json index ae482b2cbb..c06c6e3342 100644 --- a/pkg-manager/modules-yaml/package.json +++ b/pkg-manager/modules-yaml/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "fix": "tslint -c tslint.json src/**/*.ts test/**/*.ts --fix", diff --git a/pkg-manager/modules-yaml/src/index.ts b/pkg-manager/modules-yaml/src/index.ts index 3413c8c053..5637190046 100644 --- a/pkg-manager/modules-yaml/src/index.ts +++ b/pkg-manager/modules-yaml/src/index.ts @@ -1,7 +1,7 @@ import path from 'path' import { type DepPath, type DependenciesField, type HoistedDependencies, type Registries } from '@pnpm/types' import readYamlFile from 'read-yaml-file' -import mapValues from 'ramda/src/map' +import { map as mapValues } from 'ramda' import isWindows from 'is-windows' import writeYamlFile from 'write-yaml-file' @@ -39,7 +39,7 @@ export async function readModulesManifest (modulesDir: string): Promise(modulesYamlPath) + modules = await readYamlFile.default(modulesYamlPath) if (!modules) return modules } catch (err: any) { // eslint-disable-line if ((err as NodeJS.ErrnoException).code !== 'ENOENT') { @@ -59,7 +59,7 @@ export async function readModulesManifest (modulesDir: string): Promise Object.fromEntries(aliases.map((alias) => [alias, 'public'])), + (aliases) => Object.fromEntries(aliases.map((alias) => [alias, 'public' as const])), modules.hoistedAliases ) } diff --git a/pkg-manager/modules-yaml/test/index.ts b/pkg-manager/modules-yaml/test/index.ts index 3cb7199683..188d51ae0a 100644 --- a/pkg-manager/modules-yaml/test/index.ts +++ b/pkg-manager/modules-yaml/test/index.ts @@ -39,7 +39,7 @@ test('writeModulesManifest() and readModulesManifest()', async () => { }) test('backward compatible read of .modules.yaml created with shamefully-hoist=true', async () => { - const modulesYaml = await readModulesManifest(path.join(__dirname, 'fixtures/old-shamefully-hoist')) + const modulesYaml = await readModulesManifest(path.join(import.meta.dirname, 'fixtures/old-shamefully-hoist')) if (modulesYaml == null) { fail('modulesYaml was nullish') } @@ -52,7 +52,7 @@ test('backward compatible read of .modules.yaml created with shamefully-hoist=tr }) test('backward compatible read of .modules.yaml created with shamefully-hoist=false', async () => { - const modulesYaml = await readModulesManifest(path.join(__dirname, 'fixtures/old-no-shamefully-hoist')) + const modulesYaml = await readModulesManifest(path.join(import.meta.dirname, 'fixtures/old-no-shamefully-hoist')) if (modulesYaml == null) { fail('modulesYaml was nullish') } @@ -121,6 +121,6 @@ test('readModulesManifest() should create a node_modules directory if makeModule }) test('readModulesManifest does not fail on empty file', async () => { - const modulesYaml = await readModulesManifest(path.join(__dirname, 'fixtures/empty-modules-yaml')) + const modulesYaml = await readModulesManifest(path.join(import.meta.dirname, 'fixtures/empty-modules-yaml')) expect(modulesYaml).toBeUndefined() }) diff --git a/pkg-manager/modules-yaml/test/tsconfig.json b/pkg-manager/modules-yaml/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/modules-yaml/test/tsconfig.json +++ b/pkg-manager/modules-yaml/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manager/package-bins/package.json b/pkg-manager/package-bins/package.json index 8d43d005b3..e392e86bc3 100644 --- a/pkg-manager/package-bins/package.json +++ b/pkg-manager/package-bins/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "fix": "tslint -c tslint.json --project . --fix", diff --git a/pkg-manager/package-bins/test/index.ts b/pkg-manager/package-bins/test/index.ts index 40ecf44a81..7f6deef3bb 100644 --- a/pkg-manager/package-bins/test/index.ts +++ b/pkg-manager/package-bins/test/index.ts @@ -32,7 +32,7 @@ test('getBinsFromPackageManifest() should allow $ as command name', async () => }) test('find all the bin files from a bin directory', async () => { - const fixtures = path.join(__dirname, 'fixtures') + const fixtures = path.join(import.meta.dirname, 'fixtures') expect( await getBinsFromPackageManifest({ name: 'bin-dir', diff --git a/pkg-manager/package-bins/test/tsconfig.json b/pkg-manager/package-bins/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/package-bins/test/tsconfig.json +++ b/pkg-manager/package-bins/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manager/package-requester/package.json b/pkg-manager/package-requester/package.json index 8492eb99a2..3c7fa5bc59 100644 --- a/pkg-manager/package-requester/package.json +++ b/pkg-manager/package-requester/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "scripts": { "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/pkg-manager/package-requester/src/packageRequester.ts b/pkg-manager/package-requester/src/packageRequester.ts index b4030fe178..3badeec465 100644 --- a/pkg-manager/package-requester/src/packageRequester.ts +++ b/pkg-manager/package-requester/src/packageRequester.ts @@ -49,7 +49,7 @@ import { familySync } from 'detect-libc' import PQueue from 'p-queue' import pDefer from 'p-defer' import pShare from 'promise-share' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import semver from 'semver' import ssri from 'ssri' import { equalOrSemverEqual } from './equalOrSemverEqual.js' diff --git a/pkg-manager/package-requester/test/index.ts b/pkg-manager/package-requester/test/index.ts index a69d9db776..b1129e2449 100644 --- a/pkg-manager/package-requester/test/index.ts +++ b/pkg-manager/package-requester/test/index.ts @@ -19,7 +19,7 @@ import tempy from 'tempy' import { type PkgResolutionId, type PkgRequestFetchResult, type RequestPackageOptions } from '@pnpm/store-controller-types' const registry = `http://localhost:${REGISTRY_MOCK_PORT}` -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const IS_POSITIVE_TARBALL = f.find('is-positive-1.0.0.tgz') const registries = { default: registry } diff --git a/pkg-manager/package-requester/test/tsconfig.json b/pkg-manager/package-requester/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/package-requester/test/tsconfig.json +++ b/pkg-manager/package-requester/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manager/plugin-commands-installation/package.json b/pkg-manager/plugin-commands-installation/package.json index 8a9d21ac41..e50c2928e8 100644 --- a/pkg-manager/plugin-commands-installation/package.json +++ b/pkg-manager/plugin-commands-installation/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ "scripts": { "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/pkg-manager/plugin-commands-installation/src/add.ts b/pkg-manager/plugin-commands-installation/src/add.ts index 959412366c..feb9265312 100644 --- a/pkg-manager/plugin-commands-installation/src/add.ts +++ b/pkg-manager/plugin-commands-installation/src/add.ts @@ -5,7 +5,7 @@ import { resolveConfigDeps } from '@pnpm/config.deps-installer' import { PnpmError } from '@pnpm/error' import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import { createOrConnectStoreController } from '@pnpm/store-connection-manager' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { getFetchFullMetadata } from './getFetchFullMetadata.js' import { type InstallCommandOptions } from './install.js' diff --git a/pkg-manager/plugin-commands-installation/src/dedupe.ts b/pkg-manager/plugin-commands-installation/src/dedupe.ts index 4ca7e8882c..4aa0807ae5 100644 --- a/pkg-manager/plugin-commands-installation/src/dedupe.ts +++ b/pkg-manager/plugin-commands-installation/src/dedupe.ts @@ -5,7 +5,7 @@ import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import renderHelp from 'render-help' import { type InstallCommandOptions, rcOptionsTypes as installCommandRcOptionsTypes } from './install.js' import { installDeps } from './installDeps.js' -import omit from 'ramda/src/omit' +import { omit } from 'ramda' // In general, the "pnpm dedupe" command should use .npmrc options that "pnpm install" would also accept. export function rcOptionsTypes (): Record { diff --git a/pkg-manager/plugin-commands-installation/src/import/index.ts b/pkg-manager/plugin-commands-installation/src/import/index.ts index 3fd9a57b30..cefeccdba6 100644 --- a/pkg-manager/plugin-commands-installation/src/import/index.ts +++ b/pkg-manager/plugin-commands-installation/src/import/index.ts @@ -17,9 +17,10 @@ import { logger } from '@pnpm/logger' import { sequenceGraph } from '@pnpm/sort-packages' import rimraf from '@zkochan/rimraf' import loadJsonFile from 'load-json-file' -import mapValues from 'ramda/src/map' +import { map as mapValues } from 'ramda' import renderHelp from 'render-help' -import { parse as parseYarnLock, type LockFileObject } from '@yarnpkg/lockfile' +import yarnLockfileLib from '@yarnpkg/lockfile' +import { type LockFileObject } from '@yarnpkg/lockfile' import * as structUtils from '@yarnpkg/core/structUtils' import { parseSyml } from '@yarnpkg/parsers' import { recursive } from '../recursive.js' @@ -190,7 +191,7 @@ async function readYarnLockFile (dir: string): Promise { const yarnLockFile = await gfs.readFile(path.join(dir, 'yarn.lock'), 'utf8') const yarnLockFileType = getYarnLockfileType(yarnLockFile) if (yarnLockFileType === YarnLockType.yarn) { - const lockJsonFile = parseYarnLock(yarnLockFile) + const lockJsonFile = yarnLockfileLib.parse(yarnLockFile) if (lockJsonFile.type === 'success') { return lockJsonFile.object } else { diff --git a/pkg-manager/plugin-commands-installation/src/install.ts b/pkg-manager/plugin-commands-installation/src/install.ts index fbded36549..57719e8a89 100644 --- a/pkg-manager/plugin-commands-installation/src/install.ts +++ b/pkg-manager/plugin-commands-installation/src/install.ts @@ -4,7 +4,7 @@ import { type Config, types as allTypes } from '@pnpm/config' import { WANTED_LOCKFILE } from '@pnpm/constants' import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import { type CreateStoreControllerOptions } from '@pnpm/store-connection-manager' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { getFetchFullMetadata } from './getFetchFullMetadata.js' import { installDeps, type InstallDepsOptions } from './installDeps.js' diff --git a/pkg-manager/plugin-commands-installation/src/link.ts b/pkg-manager/plugin-commands-installation/src/link.ts index 0dd26e0610..4dc1145f7b 100644 --- a/pkg-manager/plugin-commands-installation/src/link.ts +++ b/pkg-manager/plugin-commands-installation/src/link.ts @@ -14,8 +14,7 @@ import { type WorkspacePackages, } from '@pnpm/core' import { logger } from '@pnpm/logger' -import pick from 'ramda/src/pick' -import partition from 'ramda/src/partition' +import { pick, partition } from 'ramda' import renderHelp from 'render-help' import { createProjectManifestWriter } from './createProjectManifestWriter.js' import { getSaveType } from './getSaveType.js' diff --git a/pkg-manager/plugin-commands-installation/src/prune.ts b/pkg-manager/plugin-commands-installation/src/prune.ts index 151e0d0ae8..fb8f84c5f6 100644 --- a/pkg-manager/plugin-commands-installation/src/prune.ts +++ b/pkg-manager/plugin-commands-installation/src/prune.ts @@ -1,7 +1,7 @@ import { docsUrl } from '@pnpm/cli-utils' import { UNIVERSAL_OPTIONS, OPTIONS } from '@pnpm/common-cli-options-help' import { types as allTypes } from '@pnpm/config' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import * as install from './install.js' diff --git a/pkg-manager/plugin-commands-installation/src/remove.ts b/pkg-manager/plugin-commands-installation/src/remove.ts index 1269700fb0..d8ca43c1ef 100644 --- a/pkg-manager/plugin-commands-installation/src/remove.ts +++ b/pkg-manager/plugin-commands-installation/src/remove.ts @@ -13,8 +13,7 @@ import { getAllDependenciesFromManifest } from '@pnpm/manifest-utils' import { createOrConnectStoreController, type CreateStoreControllerOptions } from '@pnpm/store-connection-manager' import { type DependenciesField, type ProjectRootDir } from '@pnpm/types' import { mutateModulesInSingleProject } from '@pnpm/core' -import pick from 'ramda/src/pick' -import without from 'ramda/src/without' +import { pick, without } from 'ramda' import renderHelp from 'render-help' import { getSaveType } from './getSaveType.js' import { recursive } from './recursive.js' diff --git a/pkg-manager/plugin-commands-installation/src/update/getUpdateChoices.ts b/pkg-manager/plugin-commands-installation/src/update/getUpdateChoices.ts index 38b9d35c6e..9d82a040a7 100644 --- a/pkg-manager/plugin-commands-installation/src/update/getUpdateChoices.ts +++ b/pkg-manager/plugin-commands-installation/src/update/getUpdateChoices.ts @@ -2,8 +2,7 @@ import colorizeSemverDiff from '@pnpm/colorize-semver-diff' import { type OutdatedPackage } from '@pnpm/outdated' import semverDiff from '@pnpm/semver-diff' import { getBorderCharacters, table } from '@zkochan/table' -import { pipe, groupBy, pluck, uniqBy, pickBy, and } from 'ramda' -import isEmpty from 'ramda/src/isEmpty' +import { pipe, groupBy, pluck, uniqBy, pickBy, and, isEmpty } from 'ramda' export interface ChoiceRow { name: string @@ -96,10 +95,10 @@ interface RawChoice { } function buildPkgChoice (outdatedPkg: OutdatedPackage, workspacesEnabled: boolean): RawChoice { - const sdiff = semverDiff(outdatedPkg.wanted, outdatedPkg.latestManifest!.version) + const sdiff = semverDiff.default(outdatedPkg.wanted, outdatedPkg.latestManifest!.version) const nextVersion = sdiff.change === null ? outdatedPkg.latestManifest!.version - : colorizeSemverDiff(sdiff as any) // eslint-disable-line @typescript-eslint/no-explicit-any + : colorizeSemverDiff.default(sdiff as any) // eslint-disable-line @typescript-eslint/no-explicit-any const label = outdatedPkg.packageName const lineParts = { diff --git a/pkg-manager/plugin-commands-installation/src/update/index.ts b/pkg-manager/plugin-commands-installation/src/update/index.ts index 1a2e73b1e1..92cf306b70 100644 --- a/pkg-manager/plugin-commands-installation/src/update/index.ts +++ b/pkg-manager/plugin-commands-installation/src/update/index.ts @@ -12,11 +12,9 @@ import { outdatedDepsOfProjects } from '@pnpm/outdated' import { PnpmError } from '@pnpm/error' import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import { type IncludedDependencies, type ProjectRootDir } from '@pnpm/types' -import { prompt } from 'enquirer' +import enquirer from 'enquirer' import chalk from 'chalk' -import pick from 'ramda/src/pick' -import pluck from 'ramda/src/pluck' -import unnest from 'ramda/src/unnest' +import { pick, pluck, unnest } from 'ramda' import renderHelp from 'render-help' import { type InstallCommandOptions } from '../install.js' import { installDeps } from '../installDeps.js' @@ -215,7 +213,7 @@ async function interactiveUpdate ( } return 'All of your dependencies are already up to date inside the specified ranges. Use the --latest option to update the ranges in package.json' } - const { updateDependencies } = await prompt({ + const { updateDependencies } = await enquirer.prompt({ choices, footer: '\nEnter to start updating. Ctrl-c to cancel.', indicator (state: any, choice: any) { // eslint-disable-line @typescript-eslint/no-explicit-any diff --git a/pkg-manager/plugin-commands-installation/test/add.ts b/pkg-manager/plugin-commands-installation/test/add.ts index 2245dd9cf8..a970c363e8 100644 --- a/pkg-manager/plugin-commands-installation/test/add.ts +++ b/pkg-manager/plugin-commands-installation/test/add.ts @@ -66,9 +66,9 @@ test('installing with "workspace:" should work even if link-workspace-packages i workspaceDir: process.cwd(), }, ['project-2@workspace:*']) - const pkg = await import(path.resolve('project-1/package.json')) + const { default: pkg } = await import(path.resolve('project-1/package.json')) - expect(pkg?.dependencies).toStrictEqual({ 'project-2': 'workspace:^2.0.0' }) + expect(pkg?.dependencies).toEqual({ 'project-2': 'workspace:^2.0.0' }) projects['project-1'].has('project-2') }) @@ -93,9 +93,9 @@ test('installing with "workspace:" should work even if link-workspace-packages i workspaceDir: process.cwd(), }, ['project-2@workspace:*']) - const pkg = await import(path.resolve('project-1/package.json')) + const { default: pkg } = await import(path.resolve('project-1/package.json')) - expect(pkg?.dependencies).toStrictEqual({ 'project-2': 'workspace:*' }) + expect(pkg?.dependencies).toEqual({ 'project-2': 'workspace:*' }) projects['project-1'].has('project-2') }) @@ -121,9 +121,9 @@ test('installing with "workspace=true" should work even if link-workspace-packag workspaceDir: process.cwd(), }, ['project-2']) - const pkg = await import(path.resolve('project-1/package.json')) + const { default: pkg } = await import(path.resolve('project-1/package.json')) - expect(pkg?.dependencies).toStrictEqual({ 'project-2': 'workspace:^2.0.0' }) + expect(pkg?.dependencies).toEqual({ 'project-2': 'workspace:^2.0.0' }) projects['project-1'].has('project-2') }) @@ -210,9 +210,9 @@ test('installing with "workspace=true" with linkWorkspacePackages on and saveWor workspaceDir: process.cwd(), }, ['project-2']) - const pkg = await import(path.resolve('project-1/package.json')) + const { default: pkg } = await import(path.resolve('project-1/package.json')) - expect(pkg?.dependencies).toStrictEqual({ 'project-2': 'workspace:^2.0.0' }) + expect(pkg?.dependencies).toEqual({ 'project-2': 'workspace:^2.0.0' }) projects['project-1'].has('project-2') }) @@ -319,7 +319,7 @@ test('pnpm add - should add prefix when set in .npmrc when a range is not specif }, ['is-positive']) { - const manifest = (await import(path.resolve('package.json'))) + const { default: manifest } = (await import(path.resolve('package.json'))) expect( manifest.dependencies['is-positive'] diff --git a/pkg-manager/plugin-commands-installation/test/addRecursive.ts b/pkg-manager/plugin-commands-installation/test/addRecursive.ts index 0b82a7e862..2e32042b08 100644 --- a/pkg-manager/plugin-commands-installation/test/addRecursive.ts +++ b/pkg-manager/plugin-commands-installation/test/addRecursive.ts @@ -41,20 +41,20 @@ test('recursive add --save-dev, --save-peer on workspace with multiple lockfiles }, ['is-negative@1.0.0']) { - const manifest = (await import(path.resolve('project-1/package.json'))) + const { default: manifest } = (await import(path.resolve('project-1/package.json'))) expect( manifest.devDependencies - ).toStrictEqual( + ).toEqual( { 'is-positive': '1.0.0', 'is-negative': '1.0.0' } ) expect( manifest.peerDependencies - ).toStrictEqual( + ).toEqual( { 'is-negative': '1.0.0' } ) expect( projects['project-1'].readLockfile().importers['.'].devDependencies - ).toStrictEqual( + ).toEqual( { 'is-positive': { specifier: '1.0.0', @@ -69,20 +69,20 @@ test('recursive add --save-dev, --save-peer on workspace with multiple lockfiles } { - const manifest = (await import(path.resolve('project-2/package.json'))) + const { default: manifest } = (await import(path.resolve('project-2/package.json'))) expect( manifest.devDependencies - ).toStrictEqual( + ).toEqual( { 'is-positive': '1.0.0', 'is-negative': '1.0.0' } ) expect( manifest.peerDependencies - ).toStrictEqual( + ).toEqual( { 'is-negative': '1.0.0' } ) expect( projects['project-2'].readLockfile().importers['.'].devDependencies - ).toStrictEqual( + ).toEqual( { 'is-positive': { specifier: '1.0.0', @@ -133,29 +133,29 @@ test('recursive add --save-dev, --save-peer on workspace with single lockfile', }, ['is-negative@1.0.0']) { - const manifest = (await import(path.resolve('project-1/package.json'))) + const { default: manifest } = (await import(path.resolve('project-1/package.json'))) expect( manifest.devDependencies - ).toStrictEqual( + ).toEqual( { 'is-positive': '1.0.0', 'is-negative': '1.0.0' } ) expect( manifest.peerDependencies - ).toStrictEqual( + ).toEqual( { 'is-negative': '1.0.0' } ) } { - const manifest = (await import(path.resolve('project-2/package.json'))) + const { default: manifest } = (await import(path.resolve('project-2/package.json'))) expect( manifest.devDependencies - ).toStrictEqual( + ).toEqual( { 'is-positive': '1.0.0', 'is-negative': '1.0.0' } ) expect( manifest.peerDependencies - ).toStrictEqual( + ).toEqual( { 'is-negative': '1.0.0' } ) } @@ -163,7 +163,7 @@ test('recursive add --save-dev, --save-peer on workspace with single lockfile', const lockfile = readYamlFile('./pnpm-lock.yaml') expect( lockfile.importers['project-1' as ProjectId].devDependencies - ).toStrictEqual( + ).toEqual( { 'is-positive': { specifier: '1.0.0', diff --git a/pkg-manager/plugin-commands-installation/test/dedupe.ts b/pkg-manager/plugin-commands-installation/test/dedupe.ts index ec9d658ce6..c19064e1b3 100644 --- a/pkg-manager/plugin-commands-installation/test/dedupe.ts +++ b/pkg-manager/plugin-commands-installation/test/dedupe.ts @@ -11,7 +11,7 @@ import { diff } from 'jest-diff' import { sync as readYamlFile } from 'read-yaml-file' import { DEFAULT_OPTS } from './utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) describe('pnpm dedupe', () => { test('updates old resolutions from importers block and removes old packages', async () => { diff --git a/pkg-manager/plugin-commands-installation/test/global.ts b/pkg-manager/plugin-commands-installation/test/global.ts index da03cf814c..8000a6a498 100644 --- a/pkg-manager/plugin-commands-installation/test/global.ts +++ b/pkg-manager/plugin-commands-installation/test/global.ts @@ -52,7 +52,7 @@ test('globally installed package is linked with active version of Node.js', asyn pnpmHomeDir: path.dirname(nodeExecPath), }, ['@pnpm.e2e/hello-world-js-bin']) - const manifest = (await import(path.resolve('package.json'))) + const { default: manifest } = await import(path.resolve('package.json')) expect( manifest.dependenciesMeta['@pnpm.e2e/hello-world-js-bin']?.node @@ -72,7 +72,7 @@ test('globally installed package isn not linked with active version of Node.js i pnpmHomeDir: path.resolve('pnpm-home'), }, ['@pnpm.e2e/hello-world-js-bin']) - const manifest = (await import(path.resolve('package.json'))) + const { default: manifest } = await import(path.resolve('package.json')) expect(manifest.dependenciesMeta).toBeFalsy() }) diff --git a/pkg-manager/plugin-commands-installation/test/import.ts b/pkg-manager/plugin-commands-installation/test/import.ts index 393a69544b..88ed83f965 100644 --- a/pkg-manager/plugin-commands-installation/test/import.ts +++ b/pkg-manager/plugin-commands-installation/test/import.ts @@ -8,7 +8,7 @@ import { fixtures } from '@pnpm/test-fixtures' import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import tempy from 'tempy' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}` const TMP = tempy.directory() diff --git a/pkg-manager/plugin-commands-installation/test/importRecursive.ts b/pkg-manager/plugin-commands-installation/test/importRecursive.ts index 60343d6162..731705583e 100644 --- a/pkg-manager/plugin-commands-installation/test/importRecursive.ts +++ b/pkg-manager/plugin-commands-installation/test/importRecursive.ts @@ -7,7 +7,7 @@ import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir' import { fixtures } from '@pnpm/test-fixtures' import tempy from 'tempy' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}` const TMP = tempy.directory() diff --git a/pkg-manager/plugin-commands-installation/test/link.ts b/pkg-manager/plugin-commands-installation/test/link.ts index 3010f88b55..7b68fb0270 100644 --- a/pkg-manager/plugin-commands-installation/test/link.ts +++ b/pkg-manager/plugin-commands-installation/test/link.ts @@ -1,20 +1,33 @@ import fs from 'fs' import path from 'path' -import { install, link } from '@pnpm/plugin-commands-installation' import { prepare, preparePackages, prepareEmpty } from '@pnpm/prepare' import { isExecutable, assertProject } from '@pnpm/assert-project' import { fixtures } from '@pnpm/test-fixtures' -import { logger } from '@pnpm/logger' -import { jest } from '@jest/globals' import { sync as loadJsonFile } from 'load-json-file' import PATH from 'path-name' import { sync as readYamlFile } from 'read-yaml-file' import writePkg from 'write-pkg' -import { DEFAULT_OPTS } from './utils/index.js' import { type PnpmError } from '@pnpm/error' +import { jest } from '@jest/globals' import { sync as writeYamlFile } from 'write-yaml-file' +import { DEFAULT_OPTS } from './utils/index.js' -const f = fixtures(__dirname) +const original = await import('@pnpm/logger') +jest.unstable_mockModule('@pnpm/logger', () => { + const logger = { + ...original.logger, + warn: jest.fn(), + } + return { + ...original, + logger: Object.assign(() => logger, logger), + } +}) + +const { logger } = await import('@pnpm/logger') +const { install, link } = await import('@pnpm/plugin-commands-installation') + +const f = fixtures(import.meta.dirname) test('linking multiple packages', async () => { const project = prepare() @@ -260,8 +273,6 @@ test('link fails if nothing is linked', async () => { test('logger warns about peer dependencies when linking', async () => { prepare() - const warnMock = jest.spyOn(logger, 'warn') - process.chdir('..') const globalDir = path.resolve('global') @@ -292,18 +303,16 @@ test('logger warns about peer dependencies when linking', async () => { globalPkgDir: globalDir, }, ['linked-with-peer-deps']) - expect(warnMock).toHaveBeenCalledWith(expect.objectContaining({ + expect(logger.warn).toHaveBeenCalledWith(expect.objectContaining({ message: expect.stringContaining('has the following peerDependencies specified in its package.json'), })) - warnMock.mockRestore() + jest.mocked(logger.warn).mockRestore() }) test('logger should not warn about peer dependencies when it is an empty object', async () => { prepare() - const warnMock = jest.spyOn(logger, 'warn') - process.chdir('..') const globalDir = path.resolve('global') @@ -333,11 +342,11 @@ test('logger should not warn about peer dependencies when it is an empty object' rootProjectManifestDir: process.cwd(), }, ['linked-with-empty-peer-deps']) - expect(warnMock).not.toHaveBeenCalledWith(expect.objectContaining({ + expect(logger.warn).not.toHaveBeenCalledWith(expect.objectContaining({ message: expect.stringContaining('has the following peerDependencies specified in its package.json'), })) - warnMock.mockRestore() + jest.mocked(logger.warn).mockRestore() }) test('link: fail when global bin directory is not found', async () => { diff --git a/pkg-manager/plugin-commands-installation/test/miscRecursive.ts b/pkg-manager/plugin-commands-installation/test/miscRecursive.ts index 4c94f1da4f..83f2f0b5f8 100644 --- a/pkg-manager/plugin-commands-installation/test/miscRecursive.ts +++ b/pkg-manager/plugin-commands-installation/test/miscRecursive.ts @@ -532,11 +532,11 @@ test('installing with "workspace=true" should work even if link-workspace-packag }, ['project-2']) { - const pkg = await import(path.resolve('project-1/package.json')) - expect(pkg?.dependencies).toStrictEqual({ 'project-2': 'workspace:2.0.0' }) + const { default: pkg } = await import(path.resolve('project-1/package.json')) + expect(pkg?.dependencies).toEqual({ 'project-2': 'workspace:2.0.0' }) } { - const pkg = await import(path.resolve('project-2/package.json')) + const { default: pkg } = await import(path.resolve('project-2/package.json')) expect(pkg.dependencies).toBeFalsy() } @@ -573,11 +573,11 @@ test('installing with "workspace=true" should work even if link-workspace-packag }, ['project-2']) { - const pkg = await import(path.resolve('project-1/package.json')) - expect(pkg?.dependencies).toStrictEqual({ 'project-2': 'workspace:*' }) + const { default: pkg } = await import(path.resolve('project-1/package.json')) + expect(pkg?.dependencies).toEqual({ 'project-2': 'workspace:*' }) } { - const pkg = await import(path.resolve('project-2/package.json')) + const { default: pkg } = await import(path.resolve('project-2/package.json')) expect(pkg.dependencies).toBeFalsy() } diff --git a/pkg-manager/plugin-commands-installation/test/patchedDependencies.ts b/pkg-manager/plugin-commands-installation/test/patchedDependencies.ts index 11bfc75eb1..36ea2be0b2 100644 --- a/pkg-manager/plugin-commands-installation/test/patchedDependencies.ts +++ b/pkg-manager/plugin-commands-installation/test/patchedDependencies.ts @@ -1,26 +1,27 @@ import fs from 'fs' import path from 'path' import { type ProjectManifest } from '@pnpm/types' -import { globalWarn } from '@pnpm/logger' -import { add, install } from '@pnpm/plugin-commands-installation' import { prepareEmpty } from '@pnpm/prepare' import { fixtures } from '@pnpm/test-fixtures' import { jest } from '@jest/globals' import { DEFAULT_OPTS } from './utils/index.js' -jest.mock('@pnpm/logger', () => { - const originalModule = jest.requireActual('@pnpm/logger') +const originalModule = await import('@pnpm/logger') +jest.unstable_mockModule('@pnpm/logger', () => { return { ...originalModule, globalWarn: jest.fn(), } }) +const { globalWarn } = await import('@pnpm/logger') +const { add, install } = await import('@pnpm/plugin-commands-installation') + beforeEach(() => { jest.mocked(globalWarn).mockClear() }) -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) function addPatch (key: string, patchFixture: string, patchDest: string): ProjectManifest { fs.mkdirSync(path.dirname(patchDest), { recursive: true }) diff --git a/pkg-manager/plugin-commands-installation/test/prune.ts b/pkg-manager/plugin-commands-installation/test/prune.ts index 6535261ccd..6394896558 100644 --- a/pkg-manager/plugin-commands-installation/test/prune.ts +++ b/pkg-manager/plugin-commands-installation/test/prune.ts @@ -8,7 +8,7 @@ import symlinkDir from 'symlink-dir' import fs from 'fs' const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}` -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const DEFAULT_OPTIONS = { argv: { diff --git a/pkg-manager/plugin-commands-installation/test/remove/workspace.ts b/pkg-manager/plugin-commands-installation/test/remove/workspace.ts index ff3e44b8f5..d401887e0e 100644 --- a/pkg-manager/plugin-commands-installation/test/remove/workspace.ts +++ b/pkg-manager/plugin-commands-installation/test/remove/workspace.ts @@ -51,16 +51,16 @@ test('remove --filter only changes the specified dependency, when run with link- // project-1 should be unchanged { - const pkg = await import(path.resolve('project-1/package.json')) - expect(pkg?.dependencies).toStrictEqual({ + const { default: pkg } = await import(path.resolve('project-1/package.json')) + expect(pkg?.dependencies).toEqual({ 'is-negative': '1.0.0', }) } // project-2 has the is-negative dependency removed { - const pkg = await import(path.resolve('project-2/package.json')) - expect(pkg?.dependencies).toStrictEqual({ + const { default: pkg } = await import(path.resolve('project-2/package.json')) + expect(pkg?.dependencies).toEqual({ 'project-1': '1.0.0', }) } @@ -131,16 +131,16 @@ test('remove from within a workspace package dir only affects the specified depe // project-1 should be unchanged { - const pkg = await import(path.resolve('project-1/package.json')) - expect(pkg?.dependencies).toStrictEqual({ + const { default: pkg } = await import(path.resolve('project-1/package.json')) + expect(pkg?.dependencies).toEqual({ 'is-negative': '1.0.0', }) } // project-2 has the is-negative dependency removed { - const pkg = await import(path.resolve('project-2/package.json')) - expect(pkg?.dependencies).toStrictEqual({ + const { default: pkg } = await import(path.resolve('project-2/package.json')) + expect(pkg?.dependencies).toEqual({ 'project-1': '1.0.0', }) } diff --git a/pkg-manager/plugin-commands-installation/test/tsconfig.json b/pkg-manager/plugin-commands-installation/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/plugin-commands-installation/test/tsconfig.json +++ b/pkg-manager/plugin-commands-installation/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manager/plugin-commands-installation/test/update/interactive.ts b/pkg-manager/plugin-commands-installation/test/update/interactive.ts index 5d58a8b395..2adf711a2e 100644 --- a/pkg-manager/plugin-commands-installation/test/update/interactive.ts +++ b/pkg-manager/plugin-commands-installation/test/update/interactive.ts @@ -1,18 +1,17 @@ import path from 'path' import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir' import { type LockfileObject } from '@pnpm/lockfile.types' -import { add, install, update } from '@pnpm/plugin-commands-installation' import { prepare, preparePackages } from '@pnpm/prepare' import { REGISTRY_MOCK_PORT, addDistTag } from '@pnpm/registry-mock' import { jest } from '@jest/globals' import { sync as readYamlFile } from 'read-yaml-file' import chalk from 'chalk' -import * as enquirer from 'enquirer' -jest.mock('enquirer', () => ({ prompt: jest.fn() })) +jest.unstable_mockModule('enquirer', () => ({ default: { prompt: jest.fn() } })) +const { default: enquirer } = await import('enquirer') +const { add, install, update } = await import('@pnpm/plugin-commands-installation') -// eslint-disable-next-line -const prompt = enquirer.prompt as any +const prompt = jest.mocked(enquirer.prompt) const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}` @@ -95,7 +94,7 @@ test('interactively update', async () => { }) prompt.mockClear() - // t.comment('update to compatible versions') + // Update to compatible versions await update.handler({ ...DEFAULT_OPTIONS, cacheDir: path.resolve('cache'), @@ -105,7 +104,8 @@ test('interactively update', async () => { storeDir, }) - expect(prompt.mock.calls[0][0].choices).toStrictEqual([ + // eslint-disable-next-line + expect((prompt.mock.calls[0][0] as any).choices).toStrictEqual([ { choices: [ headerChoice, @@ -145,7 +145,7 @@ test('interactively update', async () => { expect(lockfile.packages['is-positive@2.0.0']).toBeTruthy() } - // t.comment('update to latest versions') + // Update to latest versions prompt.mockClear() await update.handler({ ...DEFAULT_OPTIONS, @@ -157,7 +157,8 @@ test('interactively update', async () => { storeDir, }) - expect(prompt.mock.calls[0][0].choices).toStrictEqual([ + // eslint-disable-next-line + expect((prompt.mock.calls[0][0] as any).choices).toStrictEqual([ { choices: [ headerChoice, @@ -318,7 +319,8 @@ test('interactively update should ignore dependencies from the ignoreDependencie }, }) - expect(prompt.mock.calls[0][0].choices).toStrictEqual( + // eslint-disable-next-line + expect((prompt.mock.calls[0][0] as any).choices as any).toStrictEqual( [ { choices: [ diff --git a/pkg-manager/plugin-commands-installation/test/update/issue-7415.ts b/pkg-manager/plugin-commands-installation/test/update/issue-7415.ts index 347c9ee558..344011c697 100644 --- a/pkg-manager/plugin-commands-installation/test/update/issue-7415.ts +++ b/pkg-manager/plugin-commands-installation/test/update/issue-7415.ts @@ -1,12 +1,13 @@ import path from 'path' import { preparePackages } from '@pnpm/prepare' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' -import { update, install } from '@pnpm/plugin-commands-installation' -import * as enquirer from 'enquirer' import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir' import { jest } from '@jest/globals' -jest.mock('enquirer', () => ({ prompt: jest.fn() })) +jest.unstable_mockModule('enquirer', () => ({ default: { prompt: jest.fn() } })) + +const { default: enquirer } = await import('enquirer') +const { update, install } = await import('@pnpm/plugin-commands-installation') const prompt = jest.mocked(enquirer.prompt) diff --git a/pkg-manager/plugin-commands-installation/test/warnCyclicDependencies.ts b/pkg-manager/plugin-commands-installation/test/warnCyclicDependencies.ts index d5c1d7c3af..e10b8d605f 100644 --- a/pkg-manager/plugin-commands-installation/test/warnCyclicDependencies.ts +++ b/pkg-manager/plugin-commands-installation/test/warnCyclicDependencies.ts @@ -1,16 +1,20 @@ -import { install } from '@pnpm/plugin-commands-installation' import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir' import { preparePackages } from '@pnpm/prepare' -import { logger } from '@pnpm/logger' import { jest } from '@jest/globals' import { DEFAULT_OPTS } from './utils/index.js' -beforeEach(() => { - jest.spyOn(logger, 'warn') -}) +const warn = jest.fn() +const info = jest.fn() +const debug = jest.fn() +const original = await import('@pnpm/logger') +jest.unstable_mockModule('@pnpm/logger', () => ({ + ...original, + logger: Object.assign(() => ({ warn, info, debug }), { warn, info, debug }), +})) +const { install } = await import('@pnpm/plugin-commands-installation') afterEach(() => { - jest.mocked(logger.warn).mockRestore() + jest.mocked(warn).mockRestore() }) test('should warn about cyclic dependencies', async () => { @@ -37,8 +41,8 @@ test('should warn about cyclic dependencies', async () => { workspaceDir: process.cwd(), }) - expect(logger.warn).toHaveBeenCalledTimes(1) - expect(logger.warn).toHaveBeenCalledWith({ + expect(warn).toHaveBeenCalledTimes(1) + expect(warn).toHaveBeenCalledWith({ message: expect.stringMatching(/^There are cyclic workspace dependencies: /), prefix: process.cwd(), }) @@ -69,7 +73,7 @@ test('should not warn about cyclic dependencies if ignore-workspace-cycles is se ignoreWorkspaceCycles: true, }) - expect(logger.warn).toHaveBeenCalledTimes(0) + expect(warn).toHaveBeenCalledTimes(0) }) test('should not warn about cyclic dependencies if there are not', async () => { @@ -95,5 +99,5 @@ test('should not warn about cyclic dependencies if there are not', async () => { workspaceDir: process.cwd(), }) - expect(logger.warn).toHaveBeenCalledTimes(0) + expect(warn).toHaveBeenCalledTimes(0) }) diff --git a/pkg-manager/read-projects-context/package.json b/pkg-manager/read-projects-context/package.json index 6c29306013..d433e80ad0 100644 --- a/pkg-manager/read-projects-context/package.json +++ b/pkg-manager/read-projects-context/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/pkg-manager/real-hoist/package.json b/pkg-manager/real-hoist/package.json index 89d03c18ba..9c0d3b452f 100644 --- a/pkg-manager/real-hoist/package.json +++ b/pkg-manager/real-hoist/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "start": "tsc --watch", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/pkg-manager/real-hoist/test/index.ts b/pkg-manager/real-hoist/test/index.ts index 6fba5c8110..c495eeca6b 100644 --- a/pkg-manager/real-hoist/test/index.ts +++ b/pkg-manager/real-hoist/test/index.ts @@ -3,7 +3,7 @@ import { readWantedLockfile } from '@pnpm/lockfile.fs' import { fixtures } from '@pnpm/test-fixtures' import { type ProjectId } from '@pnpm/types' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('hoist', async () => { const lockfile = await readWantedLockfile(f.find('fixture'), { ignoreIncompatible: true }) diff --git a/pkg-manager/real-hoist/test/tsconfig.json b/pkg-manager/real-hoist/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/real-hoist/test/tsconfig.json +++ b/pkg-manager/real-hoist/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manager/remove-bins/package.json b/pkg-manager/remove-bins/package.json index 9bba6538d1..79a15844e8 100644 --- a/pkg-manager/remove-bins/package.json +++ b/pkg-manager/remove-bins/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/pkg-manager/resolve-dependencies/package.json b/pkg-manager/resolve-dependencies/package.json index 8126898e1b..3454bf3fd4 100644 --- a/pkg-manager/resolve-dependencies/package.json +++ b/pkg-manager/resolve-dependencies/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -29,7 +29,7 @@ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/calc-dep-state": "workspace:*", diff --git a/pkg-manager/resolve-dependencies/src/getNonDevWantedDependencies.ts b/pkg-manager/resolve-dependencies/src/getNonDevWantedDependencies.ts index fb64c37747..a223a183dc 100644 --- a/pkg-manager/resolve-dependencies/src/getNonDevWantedDependencies.ts +++ b/pkg-manager/resolve-dependencies/src/getNonDevWantedDependencies.ts @@ -1,5 +1,5 @@ import { type Dependencies, type DependencyManifest, type DependenciesMeta } from '@pnpm/types' -import pickBy from 'ramda/src/pickBy' +import { pickBy } from 'ramda' export interface WantedDependency { alias: string diff --git a/pkg-manager/resolve-dependencies/src/index.ts b/pkg-manager/resolve-dependencies/src/index.ts index 83924c5332..18a0a02670 100644 --- a/pkg-manager/resolve-dependencies/src/index.ts +++ b/pkg-manager/resolve-dependencies/src/index.ts @@ -25,8 +25,7 @@ import { type ProjectRootDir, type DepPath, } from '@pnpm/types' -import difference from 'ramda/src/difference' -import zipWith from 'ramda/src/zipWith' +import { difference, zipWith } from 'ramda' import isSubdir from 'is-subdir' import { getWantedDependencies, type WantedDependency } from './getWantedDependencies.js' import { depPathToRef } from './depPathToRef.js' diff --git a/pkg-manager/resolve-dependencies/src/resolveDependencies.ts b/pkg-manager/resolve-dependencies/src/resolveDependencies.ts index 7e68f7147e..4454ee8692 100644 --- a/pkg-manager/resolve-dependencies/src/resolveDependencies.ts +++ b/pkg-manager/resolve-dependencies/src/resolveDependencies.ts @@ -47,9 +47,7 @@ import normalizePath from 'normalize-path' import exists from 'path-exists' import pDefer from 'p-defer' import pShare from 'promise-share' -import pickBy from 'ramda/src/pickBy' -import omit from 'ramda/src/omit' -import zipWith from 'ramda/src/zipWith' +import { pickBy, omit, zipWith } from 'ramda' import semver from 'semver' import { getNonDevWantedDependencies, type WantedDependency } from './getNonDevWantedDependencies.js' import { safeIntersect } from './mergePeers.js' diff --git a/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts b/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts index 7fc8c10a5e..250c5f2ff6 100644 --- a/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts +++ b/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts @@ -16,8 +16,7 @@ import { type Registries, type ProjectRootDir, } from '@pnpm/types' -import partition from 'ramda/src/partition' -import zipObj from 'ramda/src/zipObj' +import { partition, zipObj } from 'ramda' import { type WantedDependency } from './getNonDevWantedDependencies.js' import { type NodeId, nextNodeId } from './nextNodeId.js' import { parentIdsContainSequence } from './parentIdsContainSequence.js' diff --git a/pkg-manager/resolve-dependencies/src/resolvePeers.ts b/pkg-manager/resolve-dependencies/src/resolvePeers.ts index 3147462b44..b949ebf8da 100644 --- a/pkg-manager/resolve-dependencies/src/resolvePeers.ts +++ b/pkg-manager/resolve-dependencies/src/resolvePeers.ts @@ -13,8 +13,7 @@ import { type ProjectRootDir, } from '@pnpm/types' import { depPathToFilename, createPeerDepGraphHash, type PeerId } from '@pnpm/dependency-path' -import partition from 'ramda/src/partition' -import pick from 'ramda/src/pick' +import { partition, pick } from 'ramda' import { type NodeId } from './nextNodeId.js' import { type ChildrenMap, diff --git a/pkg-manager/resolve-dependencies/src/updateLockfile.ts b/pkg-manager/resolve-dependencies/src/updateLockfile.ts index e0a792799a..04d834e188 100644 --- a/pkg-manager/resolve-dependencies/src/updateLockfile.ts +++ b/pkg-manager/resolve-dependencies/src/updateLockfile.ts @@ -10,7 +10,7 @@ import { type DepPath, type Registries } from '@pnpm/types' import * as dp from '@pnpm/dependency-path' import getNpmTarballUrl from 'get-npm-tarball-url' import { type KeyValuePair } from 'ramda' -import partition from 'ramda/src/partition' +import { partition } from 'ramda' import { depPathToRef } from './depPathToRef.js' import { type ResolvedPackage } from './resolveDependencies.js' import { type DependenciesGraph } from './index.js' diff --git a/pkg-manager/resolve-dependencies/test/tsconfig.json b/pkg-manager/resolve-dependencies/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manager/resolve-dependencies/test/tsconfig.json +++ b/pkg-manager/resolve-dependencies/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manifest/exportable-manifest/package.json b/pkg-manifest/exportable-manifest/package.json index 1bd8c9fe5a..8b5e040d17 100644 --- a/pkg-manifest/exportable-manifest/package.json +++ b/pkg-manifest/exportable-manifest/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/catalogs.resolver": "workspace:*", diff --git a/pkg-manifest/exportable-manifest/src/index.ts b/pkg-manifest/exportable-manifest/src/index.ts index 77c9d3e4b6..528e33a9c7 100644 --- a/pkg-manifest/exportable-manifest/src/index.ts +++ b/pkg-manifest/exportable-manifest/src/index.ts @@ -5,7 +5,7 @@ import { PnpmError } from '@pnpm/error' import { parseJsrSpecifier } from '@pnpm/resolving.jsr-specifier-parser' import { tryReadProjectManifest } from '@pnpm/read-project-manifest' import { type Dependencies, type ProjectManifest } from '@pnpm/types' -import omit from 'ramda/src/omit' +import { omit } from 'ramda' import pMapValues from 'p-map-values' import { overridePublishConfig } from './overridePublishConfig.js' @@ -95,7 +95,7 @@ async function makePublishDependencies ( { modulesDir, convertDependencyForPublish }: MakePublishDependenciesOpts ): Promise { if (dependencies == null) return dependencies - const publishDependencies = await pMapValues( + const publishDependencies = await pMapValues.default( async (depSpec, depName) => convertDependencyForPublish(depName, depSpec, dir, modulesDir), dependencies ) diff --git a/pkg-manifest/exportable-manifest/src/overridePublishConfig.ts b/pkg-manifest/exportable-manifest/src/overridePublishConfig.ts index 0f54a523da..0bfa3c5299 100644 --- a/pkg-manifest/exportable-manifest/src/overridePublishConfig.ts +++ b/pkg-manifest/exportable-manifest/src/overridePublishConfig.ts @@ -1,5 +1,5 @@ import { type ProjectManifest } from '@pnpm/types' -import isEmpty from 'ramda/src/isEmpty' +import { isEmpty } from 'ramda' // property keys that are copied from publishConfig into the manifest const PUBLISH_CONFIG_WHITELIST = new Set([ diff --git a/pkg-manifest/exportable-manifest/test/index.test.ts b/pkg-manifest/exportable-manifest/test/index.test.ts index 42ac9eb17f..35c4e555f6 100644 --- a/pkg-manifest/exportable-manifest/test/index.test.ts +++ b/pkg-manifest/exportable-manifest/test/index.test.ts @@ -7,7 +7,7 @@ import { type ProjectManifest } from '@pnpm/types' import crossSpawn from 'cross-spawn' import path from 'path' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') const defaultOpts: MakePublishManifestOptions = { catalogs: {}, diff --git a/pkg-manifest/exportable-manifest/test/tsconfig.json b/pkg-manifest/exportable-manifest/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manifest/exportable-manifest/test/tsconfig.json +++ b/pkg-manifest/exportable-manifest/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manifest/manifest-utils/package.json b/pkg-manifest/manifest-utils/package.json index 4c510d35ce..c73596d9c0 100644 --- a/pkg-manifest/manifest-utils/package.json +++ b/pkg-manifest/manifest-utils/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "start": "tsc --watch", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/pkg-manifest/manifest-utils/test/tsconfig.json b/pkg-manifest/manifest-utils/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manifest/manifest-utils/test/tsconfig.json +++ b/pkg-manifest/manifest-utils/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manifest/read-package-json/package.json b/pkg-manifest/read-package-json/package.json index ac61ff6308..1968fbbf64 100644 --- a/pkg-manifest/read-package-json/package.json +++ b/pkg-manifest/read-package-json/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/pkg-manifest/read-package-json/test/index.ts b/pkg-manifest/read-package-json/test/index.ts index effabb8b68..b8edbbd26c 100644 --- a/pkg-manifest/read-package-json/test/index.ts +++ b/pkg-manifest/read-package-json/test/index.ts @@ -2,14 +2,14 @@ import path from 'path' import { readPackageJson, readPackageJsonFromDir } from '@pnpm/read-package-json' -const fixtures = path.join(__dirname, 'fixtures') +const fixtures = path.join(import.meta.dirname, 'fixtures') test('readPackageJson()', async () => { - expect((await readPackageJson(path.join(__dirname, '..', 'package.json'))).name).toBe('@pnpm/read-package-json') + expect((await readPackageJson(path.join(import.meta.dirname, '..', 'package.json'))).name).toBe('@pnpm/read-package-json') }) test('fromDir()', async () => { - expect((await readPackageJsonFromDir(path.join(__dirname, '..'))).name).toBe('@pnpm/read-package-json') + expect((await readPackageJsonFromDir(path.join(import.meta.dirname, '..'))).name).toBe('@pnpm/read-package-json') }) test('readPackageJson() throw error when name is invalid', async () => { diff --git a/pkg-manifest/read-package-json/test/tsconfig.json b/pkg-manifest/read-package-json/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manifest/read-package-json/test/tsconfig.json +++ b/pkg-manifest/read-package-json/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manifest/read-project-manifest/package.json b/pkg-manifest/read-project-manifest/package.json index 5cef129783..bba196e8a9 100644 --- a/pkg-manifest/read-project-manifest/package.json +++ b/pkg-manifest/read-project-manifest/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,18 +25,18 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" }, "dependencies": { - "@gwhitney/detect-indent": "catalog:", "@pnpm/error": "workspace:*", "@pnpm/graceful-fs": "workspace:*", "@pnpm/text.comments-parser": "workspace:*", "@pnpm/types": "workspace:*", "@pnpm/write-project-manifest": "workspace:*", + "detect-indent": "catalog:", "fast-deep-equal": "catalog:", "is-windows": "catalog:", "json5": "catalog:", diff --git a/pkg-manifest/read-project-manifest/src/index.ts b/pkg-manifest/read-project-manifest/src/index.ts index 6fd39473ad..9c1b16c7d4 100644 --- a/pkg-manifest/read-project-manifest/src/index.ts +++ b/pkg-manifest/read-project-manifest/src/index.ts @@ -6,7 +6,7 @@ import { type ProjectManifest, type DevEngineDependency } from '@pnpm/types' import { extractComments, type CommentSpecifier } from '@pnpm/text.comments-parser' import { writeProjectManifest } from '@pnpm/write-project-manifest' import readYamlFile from 'read-yaml-file' -import detectIndent from '@gwhitney/detect-indent' +import detectIndent from 'detect-indent' import equal from 'fast-deep-equal' import isWindows from 'is-windows' import { @@ -188,7 +188,7 @@ export async function readExactProjectManifest (manifestPath: string): Promise { try { - return await readYamlFile(filePath) + return await readYamlFile.default(filePath) } catch (err: any) { // eslint-disable-line if (err.name !== 'YAMLException') throw err err.message = `${err.message as string}\nin ${filePath}` diff --git a/pkg-manifest/read-project-manifest/test/index.ts b/pkg-manifest/read-project-manifest/test/index.ts index 33452400ef..db71a18d8c 100644 --- a/pkg-manifest/read-project-manifest/test/index.ts +++ b/pkg-manifest/read-project-manifest/test/index.ts @@ -6,7 +6,7 @@ import { fixtures } from '@pnpm/test-fixtures' import tempy from 'tempy' import { type ProjectManifest } from '@pnpm/types' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('readProjectManifest()', async () => { expect( @@ -28,7 +28,7 @@ test('readProjectManifest()', async () => { ) expect( - (await tryReadProjectManifest(__dirname)).manifest + (await tryReadProjectManifest(import.meta.dirname)).manifest ).toBeNull() }) diff --git a/pkg-manifest/read-project-manifest/test/tsconfig.json b/pkg-manifest/read-project-manifest/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manifest/read-project-manifest/test/tsconfig.json +++ b/pkg-manifest/read-project-manifest/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pkg-manifest/write-project-manifest/package.json b/pkg-manifest/write-project-manifest/package.json index ddede5bf26..02233cc702 100644 --- a/pkg-manifest/write-project-manifest/package.json +++ b/pkg-manifest/write-project-manifest/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/pkg-manifest/write-project-manifest/test/tsconfig.json b/pkg-manifest/write-project-manifest/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/pkg-manifest/write-project-manifest/test/tsconfig.json +++ b/pkg-manifest/write-project-manifest/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b0d02393a0..633cbc815f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,9 +33,6 @@ catalogs: '@eslint/js': specifier: 9.9.1 version: 9.9.1 - '@gwhitney/detect-indent': - specifier: 7.0.1 - version: 7.0.1 '@jest/globals': specifier: 30.0.5 version: 30.0.5 @@ -345,6 +342,9 @@ catalogs: delay: specifier: ^5.0.0 version: 5.0.0 + detect-indent: + specifier: 7.0.1 + version: 7.0.1 detect-libc: specifier: ^2.0.3 version: 2.0.3 @@ -364,8 +364,8 @@ catalogs: specifier: ^2.4.1 version: 2.4.1 esbuild: - specifier: ^0.25.0 - version: 0.25.0 + specifier: ^0.25.9 + version: 0.25.9 escape-string-regexp: specifier: ^4.0.0 version: 4.0.0 @@ -394,8 +394,8 @@ catalogs: specifier: 2.7.0 version: 2.7.0 execa: - specifier: npm:safe-execa@0.1.2 - version: 0.1.2 + specifier: npm:safe-execa@0.2.0 + version: 0.2.0 exists-link: specifier: 2.0.0 version: 2.0.0 @@ -475,8 +475,8 @@ catalogs: specifier: ^29.7.0 version: 29.7.0 js-yaml: - specifier: npm:@zkochan/js-yaml@0.0.9 - version: 0.0.9 + specifier: npm:@zkochan/js-yaml@0.0.10 + version: 0.0.10 json5: specifier: ^2.2.3 version: 2.2.3 @@ -520,8 +520,8 @@ catalogs: specifier: 13.3.4 version: 13.3.4 node-fetch: - specifier: npm:@pnpm/node-fetch@1.0.0 - version: 1.0.0 + specifier: ^3.3.2 + version: 3.3.2 normalize-newline: specifier: 3.0.0 version: 3.0.0 @@ -562,8 +562,8 @@ catalogs: specifier: 4.0.1 version: 4.0.1 p-queue: - specifier: ^6.6.2 - version: 6.6.2 + specifier: ^8.1.0 + version: 8.1.0 p-settle: specifier: ^4.1.1 version: 4.1.1 @@ -658,8 +658,8 @@ catalogs: specifier: 5.2.1 version: 5.2.1 safe-execa: - specifier: ^0.1.4 - version: 0.1.4 + specifier: ^0.2.0 + version: 0.2.0 safe-promise-defer: specifier: ^1.0.1 version: 1.0.1 @@ -676,8 +676,8 @@ catalogs: specifier: ^1.1.4 version: 1.1.4 shlex: - specifier: ^2.1.2 - version: 2.1.2 + specifier: ^3.0.0 + version: 3.0.0 shx: specifier: ^0.3.4 version: 0.3.4 @@ -800,7 +800,7 @@ overrides: hosted-git-info@1: npm:@pnpm/hosted-git-info@1.0.0 http-proxy-middleware@<2.0.7: ^2.0.7 istanbul-reports: npm:@zkochan/istanbul-reports - js-yaml@^4.0.0: npm:@zkochan/js-yaml@0.0.9 + js-yaml@^4.0.0: npm:@zkochan/js-yaml@0.0.10 json5@<2.2.2: ^2.2.3 jsonwebtoken@<=8.5.1: '>=9.0.0' nopt@5: npm:@pnpm/nopt@^0.2.1 @@ -822,6 +822,9 @@ packageExtensionsChecksum: sha256-1qxck4M+gjHKVxNHtl5ISCI+egyJsA5Hru0aRTpMm9I= pnpmfileChecksum: sha256-mx8+uzkaD2WO2V3h9zTchFZZX3QdTTMrkVNvy8svgCY= patchedDependencies: + '@pnpm/npm-lifecycle': + hash: 9ca23edf604c5e8ff290e3c0a5443646b5f9865624042a5c41d9b2beb8f98972 + path: __patches__/@pnpm__npm-lifecycle.patch '@yao-pkg/pkg': hash: ab0601976c8cb8df34650a3e9cb6bf5789ed5c381e473dcbda313b2511aa560e path: __patches__/pkg.patch @@ -1184,7 +1187,7 @@ importers: version: 1000.1.1 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 fast-glob: specifier: 'catalog:' version: 3.3.2 @@ -1234,7 +1237,7 @@ importers: version: 22.15.30 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 __utils__/tsconfig: devDependencies: @@ -1317,7 +1320,7 @@ importers: version: 3.0.2 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 catalogs/config: dependencies: @@ -1873,7 +1876,7 @@ importers: version: 2.0.3 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 mem: specifier: 'catalog:' version: 8.1.1 @@ -2266,7 +2269,7 @@ importers: version: 0.5.16 node-fetch: specifier: 'catalog:' - version: '@pnpm/node-fetch@1.0.0' + version: 3.3.2 env/node.resolver: dependencies: @@ -2407,13 +2410,13 @@ importers: version: 3.3.0 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 nock: specifier: 'catalog:' version: 13.3.4 node-fetch: specifier: 'catalog:' - version: '@pnpm/node-fetch@1.0.0' + version: 3.3.2 path-name: specifier: 'catalog:' version: 1.0.0 @@ -2431,7 +2434,7 @@ importers: version: link:../../cli/cli-meta execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 mem: specifier: 'catalog:' version: 8.1.1 @@ -2590,7 +2593,7 @@ importers: version: link:../../pkg-manager/link-bins '@pnpm/npm-lifecycle': specifier: 'catalog:' - version: 1000.0.4(typanion@3.14.0) + version: 1000.0.4(patch_hash=9ca23edf604c5e8ff290e3c0a5443646b5f9865624042a5c41d9b2beb8f98972)(typanion@3.14.0) '@pnpm/read-package-json': specifier: workspace:* version: link:../../pkg-manifest/read-package-json @@ -2611,7 +2614,7 @@ importers: version: 3.0.1 shlex: specifier: 'catalog:' - version: 2.1.2 + version: 3.0.0 devDependencies: '@pnpm/lifecycle': specifier: workspace:* @@ -2797,7 +2800,7 @@ importers: version: 10.0.20 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 sinon: specifier: 'catalog:' version: 16.1.3 @@ -2890,7 +2893,7 @@ importers: version: 2.4.1 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 p-limit: specifier: 'catalog:' version: 3.1.0 @@ -2960,7 +2963,7 @@ importers: dependencies: execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 devDependencies: '@pnpm/exec.pnpm-cli-runner': specifier: workspace:* @@ -2985,7 +2988,7 @@ importers: version: 3.0.2 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 preferred-pm: specifier: 'catalog:' version: 3.1.4 @@ -3140,7 +3143,7 @@ importers: version: 3.0.2 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 devDependencies: '@jest/globals': specifier: 'catalog:' @@ -3694,7 +3697,7 @@ importers: version: 1.0.0 js-yaml: specifier: 'catalog:' - version: '@zkochan/js-yaml@0.0.9' + version: '@zkochan/js-yaml@0.0.10' normalize-path: specifier: 'catalog:' version: 3.0.0 @@ -4197,7 +4200,7 @@ importers: version: 0.2.0 node-fetch: specifier: 'catalog:' - version: '@pnpm/node-fetch@1.0.0' + version: 3.3.2 devDependencies: '@pnpm/fetch': specifier: workspace:* @@ -4219,7 +4222,7 @@ importers: version: 0.2.0 node-fetch: specifier: 'catalog:' - version: '@pnpm/node-fetch@1.0.0' + version: 3.3.2 devDependencies: '@pnpm/fetching-types': specifier: workspace:* @@ -4325,7 +4328,7 @@ importers: dependencies: execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 devDependencies: '@pnpm/git-utils': specifier: workspace:* @@ -4394,7 +4397,7 @@ importers: version: 0.29.12 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 packages/parse-wanted-dependency: dependencies: @@ -4686,7 +4689,7 @@ importers: version: 1.0.3 safe-execa: specifier: 'catalog:' - version: 0.1.4 + version: 0.2.0 semver: specifier: 'catalog:' version: 7.7.1 @@ -5052,7 +5055,7 @@ importers: version: 1.0.0 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 exists-link: specifier: 'catalog:' version: 2.0.0 @@ -5612,7 +5615,7 @@ importers: version: 3.1.0 p-queue: specifier: 'catalog:' - version: 6.6.2 + version: 8.1.0 promise-share: specifier: 'catalog:' version: 1.0.0 @@ -6255,9 +6258,6 @@ importers: pkg-manifest/read-project-manifest: dependencies: - '@gwhitney/detect-indent': - specifier: 'catalog:' - version: 7.0.1 '@pnpm/error': specifier: workspace:* version: link:../../packages/error @@ -6276,6 +6276,9 @@ importers: '@pnpm/write-project-manifest': specifier: workspace:* version: link:../write-project-manifest + detect-indent: + specifier: 'catalog:' + version: 7.0.1 fast-deep-equal: specifier: 'catalog:' version: 3.1.3 @@ -6572,10 +6575,10 @@ importers: version: 2.0.0 esbuild: specifier: 'catalog:' - version: 0.25.0 + version: 0.25.9 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 exists-link: specifier: 'catalog:' version: 2.0.0 @@ -6651,7 +6654,7 @@ importers: version: 'link:' execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 pkg: specifier: 'catalog:' version: '@yao-pkg/pkg@6.6.0(patch_hash=ab0601976c8cb8df34650a3e9cb6bf5789ed5c381e473dcbda313b2511aa560e)(encoding@0.1.13)' @@ -6724,7 +6727,7 @@ importers: version: link:../../workspace/read-manifest esbuild: specifier: 'catalog:' - version: 0.25.0 + version: 0.25.9 devDependencies: pd: specifier: workspace:* @@ -6885,7 +6888,7 @@ importers: version: 2.4.1 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 p-filter: specifier: 'catalog:' version: 2.1.0 @@ -7735,7 +7738,7 @@ importers: version: 0.29.12 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 write-yaml-file: specifier: 'catalog:' version: 5.0.0 @@ -8183,7 +8186,7 @@ importers: version: 3.0.2 execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 ssri: specifier: 'catalog:' version: 10.0.5 @@ -8241,7 +8244,7 @@ importers: version: link:../../__utils__/prepare execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 tempy: specifier: 'catalog:' version: 1.0.1 @@ -8299,7 +8302,7 @@ importers: version: 6.2.0 node-fetch: specifier: 'catalog:' - version: '@pnpm/node-fetch@1.0.0' + version: 3.3.2 tempy: specifier: 'catalog:' version: 1.0.1 @@ -8563,7 +8566,7 @@ importers: version: 3.1.0 shlex: specifier: 'catalog:' - version: 2.1.2 + version: 3.0.0 devDependencies: '@pnpm/logger': specifier: workspace:* @@ -8613,7 +8616,7 @@ importers: version: link:../pkgs-graph execa: specifier: 'catalog:' - version: safe-execa@0.1.2 + version: safe-execa@0.2.0 find-up: specifier: 'catalog:' version: 5.0.0 @@ -9492,152 +9495,158 @@ packages: '@emnapi/wasi-threads@1.0.4': resolution: {integrity: sha512-PJR+bOmMOPH8AtcTGAyYNiuJ3/Fcoj2XN/gBEWzDIKh254XO+mM9XoXHk5GNEhodxeMznbg7BlRojVbKN+gC6g==} - '@esbuild/aix-ppc64@0.25.0': - resolution: {integrity: sha512-O7vun9Sf8DFjH2UtqK8Ku3LkquL9SZL8OLY1T5NZkA34+wG3OQF7cl4Ql8vdNzM6fzBbYfLaiRLIOZ+2FOCgBQ==} + '@esbuild/aix-ppc64@0.25.9': + resolution: {integrity: sha512-OaGtL73Jck6pBKjNIe24BnFE6agGl+6KxDtTfHhy1HmhthfKouEcOhqpSL64K4/0WCtbKFLOdzD/44cJ4k9opA==} engines: {node: '>=18'} cpu: [ppc64] os: [aix] - '@esbuild/android-arm64@0.25.0': - resolution: {integrity: sha512-grvv8WncGjDSyUBjN9yHXNt+cq0snxXbDxy5pJtzMKGmmpPxeAmAhWxXI+01lU5rwZomDgD3kJwulEnhTRUd6g==} + '@esbuild/android-arm64@0.25.9': + resolution: {integrity: sha512-IDrddSmpSv51ftWslJMvl3Q2ZT98fUSL2/rlUXuVqRXHCs5EUF1/f+jbjF5+NG9UffUDMCiTyh8iec7u8RlTLg==} engines: {node: '>=18'} cpu: [arm64] os: [android] - '@esbuild/android-arm@0.25.0': - resolution: {integrity: sha512-PTyWCYYiU0+1eJKmw21lWtC+d08JDZPQ5g+kFyxP0V+es6VPPSUhM6zk8iImp2jbV6GwjX4pap0JFbUQN65X1g==} + '@esbuild/android-arm@0.25.9': + resolution: {integrity: sha512-5WNI1DaMtxQ7t7B6xa572XMXpHAaI/9Hnhk8lcxF4zVN4xstUgTlvuGDorBguKEnZO70qwEcLpfifMLoxiPqHQ==} engines: {node: '>=18'} cpu: [arm] os: [android] - '@esbuild/android-x64@0.25.0': - resolution: {integrity: sha512-m/ix7SfKG5buCnxasr52+LI78SQ+wgdENi9CqyCXwjVR2X4Jkz+BpC3le3AoBPYTC9NHklwngVXvbJ9/Akhrfg==} + '@esbuild/android-x64@0.25.9': + resolution: {integrity: sha512-I853iMZ1hWZdNllhVZKm34f4wErd4lMyeV7BLzEExGEIZYsOzqDWDf+y082izYUE8gtJnYHdeDpN/6tUdwvfiw==} engines: {node: '>=18'} cpu: [x64] os: [android] - '@esbuild/darwin-arm64@0.25.0': - resolution: {integrity: sha512-mVwdUb5SRkPayVadIOI78K7aAnPamoeFR2bT5nszFUZ9P8UpK4ratOdYbZZXYSqPKMHfS1wdHCJk1P1EZpRdvw==} + '@esbuild/darwin-arm64@0.25.9': + resolution: {integrity: sha512-XIpIDMAjOELi/9PB30vEbVMs3GV1v2zkkPnuyRRURbhqjyzIINwj+nbQATh4H9GxUgH1kFsEyQMxwiLFKUS6Rg==} engines: {node: '>=18'} cpu: [arm64] os: [darwin] - '@esbuild/darwin-x64@0.25.0': - resolution: {integrity: sha512-DgDaYsPWFTS4S3nWpFcMn/33ZZwAAeAFKNHNa1QN0rI4pUjgqf0f7ONmXf6d22tqTY+H9FNdgeaAa+YIFUn2Rg==} + '@esbuild/darwin-x64@0.25.9': + resolution: {integrity: sha512-jhHfBzjYTA1IQu8VyrjCX4ApJDnH+ez+IYVEoJHeqJm9VhG9Dh2BYaJritkYK3vMaXrf7Ogr/0MQ8/MeIefsPQ==} engines: {node: '>=18'} cpu: [x64] os: [darwin] - '@esbuild/freebsd-arm64@0.25.0': - resolution: {integrity: sha512-VN4ocxy6dxefN1MepBx/iD1dH5K8qNtNe227I0mnTRjry8tj5MRk4zprLEdG8WPyAPb93/e4pSgi1SoHdgOa4w==} + '@esbuild/freebsd-arm64@0.25.9': + resolution: {integrity: sha512-z93DmbnY6fX9+KdD4Ue/H6sYs+bhFQJNCPZsi4XWJoYblUqT06MQUdBCpcSfuiN72AbqeBFu5LVQTjfXDE2A6Q==} engines: {node: '>=18'} cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-x64@0.25.0': - resolution: {integrity: sha512-mrSgt7lCh07FY+hDD1TxiTyIHyttn6vnjesnPoVDNmDfOmggTLXRv8Id5fNZey1gl/V2dyVK1VXXqVsQIiAk+A==} + '@esbuild/freebsd-x64@0.25.9': + resolution: {integrity: sha512-mrKX6H/vOyo5v71YfXWJxLVxgy1kyt1MQaD8wZJgJfG4gq4DpQGpgTB74e5yBeQdyMTbgxp0YtNj7NuHN0PoZg==} engines: {node: '>=18'} cpu: [x64] os: [freebsd] - '@esbuild/linux-arm64@0.25.0': - resolution: {integrity: sha512-9QAQjTWNDM/Vk2bgBl17yWuZxZNQIF0OUUuPZRKoDtqF2k4EtYbpyiG5/Dk7nqeK6kIJWPYldkOcBqjXjrUlmg==} + '@esbuild/linux-arm64@0.25.9': + resolution: {integrity: sha512-BlB7bIcLT3G26urh5Dmse7fiLmLXnRlopw4s8DalgZ8ef79Jj4aUcYbk90g8iCa2467HX8SAIidbL7gsqXHdRw==} engines: {node: '>=18'} cpu: [arm64] os: [linux] - '@esbuild/linux-arm@0.25.0': - resolution: {integrity: sha512-vkB3IYj2IDo3g9xX7HqhPYxVkNQe8qTK55fraQyTzTX/fxaDtXiEnavv9geOsonh2Fd2RMB+i5cbhu2zMNWJwg==} + '@esbuild/linux-arm@0.25.9': + resolution: {integrity: sha512-HBU2Xv78SMgaydBmdor38lg8YDnFKSARg1Q6AT0/y2ezUAKiZvc211RDFHlEZRFNRVhcMamiToo7bDx3VEOYQw==} engines: {node: '>=18'} cpu: [arm] os: [linux] - '@esbuild/linux-ia32@0.25.0': - resolution: {integrity: sha512-43ET5bHbphBegyeqLb7I1eYn2P/JYGNmzzdidq/w0T8E2SsYL1U6un2NFROFRg1JZLTzdCoRomg8Rvf9M6W6Gg==} + '@esbuild/linux-ia32@0.25.9': + resolution: {integrity: sha512-e7S3MOJPZGp2QW6AK6+Ly81rC7oOSerQ+P8L0ta4FhVi+/j/v2yZzx5CqqDaWjtPFfYz21Vi1S0auHrap3Ma3A==} engines: {node: '>=18'} cpu: [ia32] os: [linux] - '@esbuild/linux-loong64@0.25.0': - resolution: {integrity: sha512-fC95c/xyNFueMhClxJmeRIj2yrSMdDfmqJnyOY4ZqsALkDrrKJfIg5NTMSzVBr5YW1jf+l7/cndBfP3MSDpoHw==} + '@esbuild/linux-loong64@0.25.9': + resolution: {integrity: sha512-Sbe10Bnn0oUAB2AalYztvGcK+o6YFFA/9829PhOCUS9vkJElXGdphz0A3DbMdP8gmKkqPmPcMJmJOrI3VYB1JQ==} engines: {node: '>=18'} cpu: [loong64] os: [linux] - '@esbuild/linux-mips64el@0.25.0': - resolution: {integrity: sha512-nkAMFju7KDW73T1DdH7glcyIptm95a7Le8irTQNO/qtkoyypZAnjchQgooFUDQhNAy4iu08N79W4T4pMBwhPwQ==} + '@esbuild/linux-mips64el@0.25.9': + resolution: {integrity: sha512-YcM5br0mVyZw2jcQeLIkhWtKPeVfAerES5PvOzaDxVtIyZ2NUBZKNLjC5z3/fUlDgT6w89VsxP2qzNipOaaDyA==} engines: {node: '>=18'} cpu: [mips64el] os: [linux] - '@esbuild/linux-ppc64@0.25.0': - resolution: {integrity: sha512-NhyOejdhRGS8Iwv+KKR2zTq2PpysF9XqY+Zk77vQHqNbo/PwZCzB5/h7VGuREZm1fixhs4Q/qWRSi5zmAiO4Fw==} + '@esbuild/linux-ppc64@0.25.9': + resolution: {integrity: sha512-++0HQvasdo20JytyDpFvQtNrEsAgNG2CY1CLMwGXfFTKGBGQT3bOeLSYE2l1fYdvML5KUuwn9Z8L1EWe2tzs1w==} engines: {node: '>=18'} cpu: [ppc64] os: [linux] - '@esbuild/linux-riscv64@0.25.0': - resolution: {integrity: sha512-5S/rbP5OY+GHLC5qXp1y/Mx//e92L1YDqkiBbO9TQOvuFXM+iDqUNG5XopAnXoRH3FjIUDkeGcY1cgNvnXp/kA==} + '@esbuild/linux-riscv64@0.25.9': + resolution: {integrity: sha512-uNIBa279Y3fkjV+2cUjx36xkx7eSjb8IvnL01eXUKXez/CBHNRw5ekCGMPM0BcmqBxBcdgUWuUXmVWwm4CH9kg==} engines: {node: '>=18'} cpu: [riscv64] os: [linux] - '@esbuild/linux-s390x@0.25.0': - resolution: {integrity: sha512-XM2BFsEBz0Fw37V0zU4CXfcfuACMrppsMFKdYY2WuTS3yi8O1nFOhil/xhKTmE1nPmVyvQJjJivgDT+xh8pXJA==} + '@esbuild/linux-s390x@0.25.9': + resolution: {integrity: sha512-Mfiphvp3MjC/lctb+7D287Xw1DGzqJPb/J2aHHcHxflUo+8tmN/6d4k6I2yFR7BVo5/g7x2Monq4+Yew0EHRIA==} engines: {node: '>=18'} cpu: [s390x] os: [linux] - '@esbuild/linux-x64@0.25.0': - resolution: {integrity: sha512-9yl91rHw/cpwMCNytUDxwj2XjFpxML0y9HAOH9pNVQDpQrBxHy01Dx+vaMu0N1CKa/RzBD2hB4u//nfc+Sd3Cw==} + '@esbuild/linux-x64@0.25.9': + resolution: {integrity: sha512-iSwByxzRe48YVkmpbgoxVzn76BXjlYFXC7NvLYq+b+kDjyyk30J0JY47DIn8z1MO3K0oSl9fZoRmZPQI4Hklzg==} engines: {node: '>=18'} cpu: [x64] os: [linux] - '@esbuild/netbsd-arm64@0.25.0': - resolution: {integrity: sha512-RuG4PSMPFfrkH6UwCAqBzauBWTygTvb1nxWasEJooGSJ/NwRw7b2HOwyRTQIU97Hq37l3npXoZGYMy3b3xYvPw==} + '@esbuild/netbsd-arm64@0.25.9': + resolution: {integrity: sha512-9jNJl6FqaUG+COdQMjSCGW4QiMHH88xWbvZ+kRVblZsWrkXlABuGdFJ1E9L7HK+T0Yqd4akKNa/lO0+jDxQD4Q==} engines: {node: '>=18'} cpu: [arm64] os: [netbsd] - '@esbuild/netbsd-x64@0.25.0': - resolution: {integrity: sha512-jl+qisSB5jk01N5f7sPCsBENCOlPiS/xptD5yxOx2oqQfyourJwIKLRA2yqWdifj3owQZCL2sn6o08dBzZGQzA==} + '@esbuild/netbsd-x64@0.25.9': + resolution: {integrity: sha512-RLLdkflmqRG8KanPGOU7Rpg829ZHu8nFy5Pqdi9U01VYtG9Y0zOG6Vr2z4/S+/3zIyOxiK6cCeYNWOFR9QP87g==} engines: {node: '>=18'} cpu: [x64] os: [netbsd] - '@esbuild/openbsd-arm64@0.25.0': - resolution: {integrity: sha512-21sUNbq2r84YE+SJDfaQRvdgznTD8Xc0oc3p3iW/a1EVWeNj/SdUCbm5U0itZPQYRuRTW20fPMWMpcrciH2EJw==} + '@esbuild/openbsd-arm64@0.25.9': + resolution: {integrity: sha512-YaFBlPGeDasft5IIM+CQAhJAqS3St3nJzDEgsgFixcfZeyGPCd6eJBWzke5piZuZ7CtL656eOSYKk4Ls2C0FRQ==} engines: {node: '>=18'} cpu: [arm64] os: [openbsd] - '@esbuild/openbsd-x64@0.25.0': - resolution: {integrity: sha512-2gwwriSMPcCFRlPlKx3zLQhfN/2WjJ2NSlg5TKLQOJdV0mSxIcYNTMhk3H3ulL/cak+Xj0lY1Ym9ysDV1igceg==} + '@esbuild/openbsd-x64@0.25.9': + resolution: {integrity: sha512-1MkgTCuvMGWuqVtAvkpkXFmtL8XhWy+j4jaSO2wxfJtilVCi0ZE37b8uOdMItIHz4I6z1bWWtEX4CJwcKYLcuA==} engines: {node: '>=18'} cpu: [x64] os: [openbsd] - '@esbuild/sunos-x64@0.25.0': - resolution: {integrity: sha512-bxI7ThgLzPrPz484/S9jLlvUAHYMzy6I0XiU1ZMeAEOBcS0VePBFxh1JjTQt3Xiat5b6Oh4x7UC7IwKQKIJRIg==} + '@esbuild/openharmony-arm64@0.25.9': + resolution: {integrity: sha512-4Xd0xNiMVXKh6Fa7HEJQbrpP3m3DDn43jKxMjxLLRjWnRsfxjORYJlXPO4JNcXtOyfajXorRKY9NkOpTHptErg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/sunos-x64@0.25.9': + resolution: {integrity: sha512-WjH4s6hzo00nNezhp3wFIAfmGZ8U7KtrJNlFMRKxiI9mxEK1scOMAaa9i4crUtu+tBr+0IN6JCuAcSBJZfnphw==} engines: {node: '>=18'} cpu: [x64] os: [sunos] - '@esbuild/win32-arm64@0.25.0': - resolution: {integrity: sha512-ZUAc2YK6JW89xTbXvftxdnYy3m4iHIkDtK3CLce8wg8M2L+YZhIvO1DKpxrd0Yr59AeNNkTiic9YLf6FTtXWMw==} + '@esbuild/win32-arm64@0.25.9': + resolution: {integrity: sha512-mGFrVJHmZiRqmP8xFOc6b84/7xa5y5YvR1x8djzXpJBSv/UsNK6aqec+6JDjConTgvvQefdGhFDAs2DLAds6gQ==} engines: {node: '>=18'} cpu: [arm64] os: [win32] - '@esbuild/win32-ia32@0.25.0': - resolution: {integrity: sha512-eSNxISBu8XweVEWG31/JzjkIGbGIJN/TrRoiSVZwZ6pkC6VX4Im/WV2cz559/TXLcYbcrDN8JtKgd9DJVIo8GA==} + '@esbuild/win32-ia32@0.25.9': + resolution: {integrity: sha512-b33gLVU2k11nVx1OhX3C8QQP6UHQK4ZtN56oFWvVXvz2VkDoe6fbG8TOgHFxEvqeqohmRnIHe5A1+HADk4OQww==} engines: {node: '>=18'} cpu: [ia32] os: [win32] - '@esbuild/win32-x64@0.25.0': - resolution: {integrity: sha512-ZENoHJBxA20C2zFzh6AI4fT6RraMzjYw4xKWemRTRmRVtN9c5DcH9r/f2ihEkMjOW5eGgrwCslG/+Y/3bL+DHQ==} + '@esbuild/win32-x64@0.25.9': + resolution: {integrity: sha512-PPOl1mi6lpLNQxnGoyAfschAodRFYXJ+9fs6WHXz7CSWKbOqiMZsubC+BQsVKuul+3vKLuwTHsS2c2y9EoKwxQ==} engines: {node: '>=18'} cpu: [x64] os: [win32] @@ -11153,8 +11162,8 @@ packages: resolution: {integrity: sha512-GeZZ9YNlvveT1CrMqe64s9+5hNF5p9Gj6J+PRQU3OnBS/9c2y5kSFavUZ9YAuoAgxFW8tKGKWIxJK4I6HBSigg==} engines: {node: '>=8'} - '@zkochan/js-yaml@0.0.9': - resolution: {integrity: sha512-SsdK25Upg5wLeGK2Wm8y5bDloMMxN/qE5H6aNOiPRh07a9/fQPYVhlLZz2zRFg9il9XOlpFdrnQnPKsU7FJIpQ==} + '@zkochan/js-yaml@0.0.10': + resolution: {integrity: sha512-pSVOuIjRa7PjIaCmL54Qaz68C3zvwdSxp0qMI5twIt1aw2c/PUVb2M46xnnLWsd2AEgsTbGNcOgHXsM9cENhjA==} hasBin: true '@zkochan/retry@0.2.0': @@ -11983,6 +11992,10 @@ packages: resolution: {integrity: sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==} engines: {node: '>= 6'} + data-uri-to-buffer@4.0.1: + resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} + engines: {node: '>= 12'} + data-view-buffer@1.0.2: resolution: {integrity: sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==} engines: {node: '>= 0.4'} @@ -12285,8 +12298,8 @@ packages: resolution: {integrity: sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==} engines: {node: '>= 0.4'} - esbuild@0.25.0: - resolution: {integrity: sha512-BXq5mqc8ltbaN34cDqWuYKyNhX8D/Z0J1xdtdQ8UcIIIyJyz+ZMKUt58tF3SrZ85jcfN/PZYhjR5uDQAYNVbuw==} + esbuild@0.25.9: + resolution: {integrity: sha512-CRbODhYyQx3qp7ZEwzxOk4JBqmD/seJrzPa/cGjY1VtIn5E09Oi9/dB4JwctnfZ8Q8iT7rioVv5k/FNT/uf54g==} engines: {node: '>=18'} hasBin: true @@ -12492,6 +12505,9 @@ packages: eventemitter3@4.0.7: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} + eventemitter3@5.0.1: + resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==} + events@3.3.0: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} @@ -12605,6 +12621,10 @@ packages: domexception: optional: true + fetch-blob@3.2.0: + resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} + engines: {node: ^12.20 || >= 14.13} + figures@2.0.0: resolution: {integrity: sha512-Oa2M9atig69ZkfwiApY8F2Yy+tzMbazyvqv21R0NsSC8floSOC09BbT1ITWAdoMGQvJ/aZnR1KMwdx9tvHnTNA==} engines: {node: '>=4'} @@ -12709,6 +12729,10 @@ packages: resolution: {integrity: sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==} engines: {node: '>= 6'} + formdata-polyfill@4.0.10: + resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} + engines: {node: '>=12.20.0'} + forwarded@0.2.0: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} @@ -14202,6 +14226,11 @@ packages: resolution: {integrity: sha512-OhYaY5sDsIka7H7AtijtI9jwGYLyl29eQn/W623DiN/MIv5sUqc4g7BIDThX+gb7di9f6xK02nkp8sdfFWZLTg==} engines: {node: '>=10'} + node-domexception@1.0.0: + resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} + engines: {node: '>=10.5.0'} + deprecated: Use your platform's native DOMException instead + node-fetch@2.6.7: resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==} engines: {node: 4.x || >=6.0.0} @@ -14220,6 +14249,10 @@ packages: encoding: optional: true + node-fetch@3.3.2: + resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + node-gyp-build@4.8.4: resolution: {integrity: sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==} hasBin: true @@ -14484,6 +14517,10 @@ packages: resolution: {integrity: sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ==} engines: {node: '>=8'} + p-queue@8.1.0: + resolution: {integrity: sha512-mxLDbbGIBEXTJL0zEx8JIylaj3xQ7Z/7eEVjcF9fJX4DBiH9oqe+oahYnlKKxm0Ci9TlWTyhSHgygxMxjIB2jw==} + engines: {node: '>=18'} + p-reflect@2.1.0: resolution: {integrity: sha512-paHV8NUz8zDHu5lhr/ngGWQiW067DK/+IbJ+RfZ4k+s8y4EKyYCz8pGYWjxCg35eHztpJAt+NUgvN4L+GCbPlg==} engines: {node: '>=8'} @@ -14500,6 +14537,10 @@ packages: resolution: {integrity: sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==} engines: {node: '>=8'} + p-timeout@6.1.4: + resolution: {integrity: sha512-MyIV3ZA/PmyBN/ud8vV9XzwTrNtR4jFrObymZYnZqMmW0zA8Z17vnT0rBgFE/TlohB+YCHqXMgZzb3Csp49vqg==} + engines: {node: '>=14.16'} + p-try@2.2.0: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} @@ -15098,6 +15139,10 @@ packages: resolution: {integrity: sha512-GI3k4zl4aLC3lxZNEEXAxxcXE6E3TfOsJ5xxJPhcAv9MWwnH2O9I0HrDmZFsVnu/C8wzRYSsTHdoVRmL0VicDw==} engines: {node: '>=12'} + safe-execa@0.2.0: + resolution: {integrity: sha512-JNG61R7tOc7LnCme+Ek5O5x0OEV9pWriDBOooih8E+3uLPHUNfw0wNoxxJs6Zmr5OgULBDqKYQ4mZJdwNl4+0A==} + engines: {node: '>=18'} + safe-promise-defer@1.0.1: resolution: {integrity: sha512-nKdAwtdSxWQpV2AIjU9rw5j/Pgt9+u+pegXJahWQY9D8G0tNvHnJnpL3zVJ1kKtWTo7s/Rvp9ZUDBtPPMpLctA==} engines: {node: '>=12'} @@ -15189,8 +15234,8 @@ packages: engines: {node: '>=4'} hasBin: true - shlex@2.1.2: - resolution: {integrity: sha512-Nz6gtibMVgYeMEhUjp2KuwAgqaJA1K155dU/HuDaEJUGgnmYfVtVZah+uerVWdH8UGnyahhDCgABbYTbs254+w==} + shlex@3.0.0: + resolution: {integrity: sha512-jHPXQQk9d/QXCvJuLPYMOYWez3c43sORAgcIEoV7bFv5AJSJRAOyw5lQO12PMfd385qiLRCaDt7OtEzgrIGZUA==} short-tree@1.0.0: resolution: {integrity: sha512-SPhGxbdypMMjYlmdVL/dzBUCT/5FboztmleoS4WPgvCI7DqZXv8xrLSTuJqzmmuAtCTkgxkIKzfZ+jfJR6ODZg==} @@ -16012,6 +16057,10 @@ packages: wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + web-streams-polyfill@3.3.3: + resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} + engines: {node: '>= 8'} + webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} @@ -17128,79 +17177,82 @@ snapshots: tslib: 2.8.1 optional: true - '@esbuild/aix-ppc64@0.25.0': + '@esbuild/aix-ppc64@0.25.9': optional: true - '@esbuild/android-arm64@0.25.0': + '@esbuild/android-arm64@0.25.9': optional: true - '@esbuild/android-arm@0.25.0': + '@esbuild/android-arm@0.25.9': optional: true - '@esbuild/android-x64@0.25.0': + '@esbuild/android-x64@0.25.9': optional: true - '@esbuild/darwin-arm64@0.25.0': + '@esbuild/darwin-arm64@0.25.9': optional: true - '@esbuild/darwin-x64@0.25.0': + '@esbuild/darwin-x64@0.25.9': optional: true - '@esbuild/freebsd-arm64@0.25.0': + '@esbuild/freebsd-arm64@0.25.9': optional: true - '@esbuild/freebsd-x64@0.25.0': + '@esbuild/freebsd-x64@0.25.9': optional: true - '@esbuild/linux-arm64@0.25.0': + '@esbuild/linux-arm64@0.25.9': optional: true - '@esbuild/linux-arm@0.25.0': + '@esbuild/linux-arm@0.25.9': optional: true - '@esbuild/linux-ia32@0.25.0': + '@esbuild/linux-ia32@0.25.9': optional: true - '@esbuild/linux-loong64@0.25.0': + '@esbuild/linux-loong64@0.25.9': optional: true - '@esbuild/linux-mips64el@0.25.0': + '@esbuild/linux-mips64el@0.25.9': optional: true - '@esbuild/linux-ppc64@0.25.0': + '@esbuild/linux-ppc64@0.25.9': optional: true - '@esbuild/linux-riscv64@0.25.0': + '@esbuild/linux-riscv64@0.25.9': optional: true - '@esbuild/linux-s390x@0.25.0': + '@esbuild/linux-s390x@0.25.9': optional: true - '@esbuild/linux-x64@0.25.0': + '@esbuild/linux-x64@0.25.9': optional: true - '@esbuild/netbsd-arm64@0.25.0': + '@esbuild/netbsd-arm64@0.25.9': optional: true - '@esbuild/netbsd-x64@0.25.0': + '@esbuild/netbsd-x64@0.25.9': optional: true - '@esbuild/openbsd-arm64@0.25.0': + '@esbuild/openbsd-arm64@0.25.9': optional: true - '@esbuild/openbsd-x64@0.25.0': + '@esbuild/openbsd-x64@0.25.9': optional: true - '@esbuild/sunos-x64@0.25.0': + '@esbuild/openharmony-arm64@0.25.9': optional: true - '@esbuild/win32-arm64@0.25.0': + '@esbuild/sunos-x64@0.25.9': optional: true - '@esbuild/win32-ia32@0.25.0': + '@esbuild/win32-arm64@0.25.9': optional: true - '@esbuild/win32-x64@0.25.0': + '@esbuild/win32-ia32@0.25.9': + optional: true + + '@esbuild/win32-x64@0.25.9': optional: true '@eslint-community/eslint-utils@4.7.0(eslint@8.57.1)': @@ -17218,7 +17270,7 @@ snapshots: globals: 13.24.0 ignore: 5.3.2 import-fresh: 3.3.1 - js-yaml: '@zkochan/js-yaml@0.0.9' + js-yaml: '@zkochan/js-yaml@0.0.10' minimatch: 3.1.2 strip-json-comments: 3.1.1 transitivePeerDependencies: @@ -17232,7 +17284,7 @@ snapshots: globals: 14.0.0 ignore: 5.3.2 import-fresh: 3.3.1 - js-yaml: '@zkochan/js-yaml@0.0.9' + js-yaml: '@zkochan/js-yaml@0.0.10' minimatch: 3.1.2 strip-json-comments: 3.1.1 transitivePeerDependencies: @@ -18035,7 +18087,7 @@ snapshots: '@pnpm/error': 1000.0.2 '@pnpm/link-bins': 1000.0.13(@pnpm/logger@1001.0.0) '@pnpm/logger': 1001.0.0 - '@pnpm/npm-lifecycle': 1000.0.4(typanion@3.14.0) + '@pnpm/npm-lifecycle': 1000.0.4(patch_hash=9ca23edf604c5e8ff290e3c0a5443646b5f9865624042a5c41d9b2beb8f98972)(typanion@3.14.0) '@pnpm/read-package-json': 1000.0.9 '@pnpm/store-controller-types': 1003.0.2 '@pnpm/types': 1000.6.0 @@ -18184,7 +18236,7 @@ snapshots: '@pnpm/network.ca-file': 1.0.2 config-chain: 1.1.13 - '@pnpm/npm-lifecycle@1000.0.4(typanion@3.14.0)': + '@pnpm/npm-lifecycle@1000.0.4(patch_hash=9ca23edf604c5e8ff290e3c0a5443646b5f9865624042a5c41d9b2beb8f98972)(typanion@3.14.0)': dependencies: '@pnpm/byline': 1.0.0 '@pnpm/error': 1000.0.2 @@ -18919,7 +18971,7 @@ snapshots: '@types/keyv@3.1.4': dependencies: - '@types/node': 22.15.29 + '@types/node': 22.15.30 '@types/lodash.kebabcase@4.1.9': dependencies: @@ -19266,7 +19318,7 @@ snapshots: dependencies: '@verdaccio/core': 8.0.0-next-8.19 debug: 4.4.1 - js-yaml: '@zkochan/js-yaml@0.0.9' + js-yaml: '@zkochan/js-yaml@0.0.10' lodash: 4.17.21 minimatch: 7.4.6 transitivePeerDependencies: @@ -19581,7 +19633,7 @@ snapshots: html-escaper: 2.0.2 istanbul-lib-report: 3.0.1 - '@zkochan/js-yaml@0.0.9': + '@zkochan/js-yaml@0.0.10': dependencies: argparse: 2.0.1 @@ -20451,7 +20503,7 @@ snapshots: cosmiconfig@8.3.6(typescript@5.9.2): dependencies: import-fresh: 3.3.1 - js-yaml: '@zkochan/js-yaml@0.0.9' + js-yaml: '@zkochan/js-yaml@0.0.10' parse-json: 5.2.0 path-type: 4.0.0 optionalDependencies: @@ -20574,6 +20626,8 @@ snapshots: data-uri-to-buffer@3.0.1: {} + data-uri-to-buffer@4.0.1: {} + data-view-buffer@1.0.2: dependencies: call-bound: 1.0.4 @@ -20891,33 +20945,34 @@ snapshots: is-date-object: 1.1.0 is-symbol: 1.1.1 - esbuild@0.25.0: + esbuild@0.25.9: optionalDependencies: - '@esbuild/aix-ppc64': 0.25.0 - '@esbuild/android-arm': 0.25.0 - '@esbuild/android-arm64': 0.25.0 - '@esbuild/android-x64': 0.25.0 - '@esbuild/darwin-arm64': 0.25.0 - '@esbuild/darwin-x64': 0.25.0 - '@esbuild/freebsd-arm64': 0.25.0 - '@esbuild/freebsd-x64': 0.25.0 - '@esbuild/linux-arm': 0.25.0 - '@esbuild/linux-arm64': 0.25.0 - '@esbuild/linux-ia32': 0.25.0 - '@esbuild/linux-loong64': 0.25.0 - '@esbuild/linux-mips64el': 0.25.0 - '@esbuild/linux-ppc64': 0.25.0 - '@esbuild/linux-riscv64': 0.25.0 - '@esbuild/linux-s390x': 0.25.0 - '@esbuild/linux-x64': 0.25.0 - '@esbuild/netbsd-arm64': 0.25.0 - '@esbuild/netbsd-x64': 0.25.0 - '@esbuild/openbsd-arm64': 0.25.0 - '@esbuild/openbsd-x64': 0.25.0 - '@esbuild/sunos-x64': 0.25.0 - '@esbuild/win32-arm64': 0.25.0 - '@esbuild/win32-ia32': 0.25.0 - '@esbuild/win32-x64': 0.25.0 + '@esbuild/aix-ppc64': 0.25.9 + '@esbuild/android-arm': 0.25.9 + '@esbuild/android-arm64': 0.25.9 + '@esbuild/android-x64': 0.25.9 + '@esbuild/darwin-arm64': 0.25.9 + '@esbuild/darwin-x64': 0.25.9 + '@esbuild/freebsd-arm64': 0.25.9 + '@esbuild/freebsd-x64': 0.25.9 + '@esbuild/linux-arm': 0.25.9 + '@esbuild/linux-arm64': 0.25.9 + '@esbuild/linux-ia32': 0.25.9 + '@esbuild/linux-loong64': 0.25.9 + '@esbuild/linux-mips64el': 0.25.9 + '@esbuild/linux-ppc64': 0.25.9 + '@esbuild/linux-riscv64': 0.25.9 + '@esbuild/linux-s390x': 0.25.9 + '@esbuild/linux-x64': 0.25.9 + '@esbuild/netbsd-arm64': 0.25.9 + '@esbuild/netbsd-x64': 0.25.9 + '@esbuild/openbsd-arm64': 0.25.9 + '@esbuild/openbsd-x64': 0.25.9 + '@esbuild/openharmony-arm64': 0.25.9 + '@esbuild/sunos-x64': 0.25.9 + '@esbuild/win32-arm64': 0.25.9 + '@esbuild/win32-ia32': 0.25.9 + '@esbuild/win32-x64': 0.25.9 escalade@3.2.0: {} @@ -21113,7 +21168,7 @@ snapshots: imurmurhash: 0.1.4 is-glob: 4.0.3 is-path-inside: 3.0.3 - js-yaml: '@zkochan/js-yaml@0.0.9' + js-yaml: '@zkochan/js-yaml@0.0.10' json-stable-stringify-without-jsonify: 1.0.1 levn: 0.4.1 lodash.merge: 4.6.2 @@ -21159,6 +21214,8 @@ snapshots: eventemitter3@4.0.7: {} + eventemitter3@5.0.1: {} + events@3.3.0: {} execa@5.1.1: @@ -21290,6 +21347,11 @@ snapshots: fetch-blob@2.1.2: {} + fetch-blob@3.2.0: + dependencies: + node-domexception: 1.0.0 + web-streams-polyfill: 3.3.3 + figures@2.0.0: dependencies: escape-string-regexp: 1.0.5 @@ -21408,6 +21470,10 @@ snapshots: hasown: 2.0.2 mime-types: 2.1.35 + formdata-polyfill@4.0.10: + dependencies: + fetch-blob: 3.2.0 + forwarded@0.2.0: {} fresh@0.5.2: {} @@ -23179,6 +23245,8 @@ snapshots: dependencies: semver: 7.7.2 + node-domexception@1.0.0: {} + node-fetch@2.6.7(encoding@0.1.13): dependencies: whatwg-url: 5.0.0 @@ -23191,6 +23259,12 @@ snapshots: optionalDependencies: encoding: 0.1.13 + node-fetch@3.3.2: + dependencies: + data-uri-to-buffer: 4.0.1 + fetch-blob: 3.2.0 + formdata-polyfill: 4.0.10 + node-gyp-build@4.8.4: optional: true @@ -23482,6 +23556,11 @@ snapshots: eventemitter3: 4.0.7 p-timeout: 3.2.0 + p-queue@8.1.0: + dependencies: + eventemitter3: 5.0.1 + p-timeout: 6.1.4 + p-reflect@2.1.0: {} p-settle@4.1.1: @@ -23498,6 +23577,8 @@ snapshots: dependencies: p-finally: 1.0.0 + p-timeout@6.1.4: {} + p-try@2.2.0: {} package-json-from-dist@1.0.1: {} @@ -23879,7 +23960,7 @@ snapshots: read-yaml-file@2.1.0: dependencies: - js-yaml: '@zkochan/js-yaml@0.0.9' + js-yaml: '@zkochan/js-yaml@0.0.10' strip-bom: 4.0.0 readable-stream@2.3.8: @@ -24123,6 +24204,12 @@ snapshots: execa: 5.1.1 path-name: 1.0.0 + safe-execa@0.2.0: + dependencies: + '@zkochan/which': 2.0.3 + execa: 5.1.1 + path-name: 1.0.0 + safe-promise-defer@1.0.1: dependencies: promise-share: 1.0.0 @@ -24235,7 +24322,7 @@ snapshots: interpret: 1.4.0 rechoir: 0.6.2 - shlex@2.1.2: {} + shlex@3.0.0: {} short-tree@1.0.0: dependencies: @@ -25234,6 +25321,8 @@ snapshots: dependencies: defaults: 1.0.4 + web-streams-polyfill@3.3.3: {} + webidl-conversions@3.0.1: {} whatwg-url@5.0.0: @@ -25389,12 +25478,12 @@ snapshots: write-yaml-file@4.2.0: dependencies: - js-yaml: '@zkochan/js-yaml@0.0.9' + js-yaml: '@zkochan/js-yaml@0.0.10' write-file-atomic: 3.0.3 write-yaml-file@5.0.0: dependencies: - js-yaml: '@zkochan/js-yaml@0.0.9' + js-yaml: '@zkochan/js-yaml@0.0.10' write-file-atomic: 5.0.1 xdg-basedir@5.1.0: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index b2d416fdc7..9e0e98eb0c 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -56,7 +56,6 @@ catalog: '@commitlint/prompt-cli': ^17.8.1 '@eslint/eslintrc': 3.1.0 '@eslint/js': 9.9.1 - '@gwhitney/detect-indent': 7.0.1 '@jest/globals': 30.0.5 '@pnpm/builder.policy': 3.0.1 '@pnpm/byline': ^1.0.0 @@ -160,13 +159,14 @@ catalog: cspell: 8.17.5 deep-require-cwd: 1.0.0 delay: ^5.0.0 + detect-indent: 7.0.1 detect-libc: ^2.0.3 didyoumean2: ^6.0.1 dint: ^5.1.0 dir-is-case-sensitive: ^2.0.0 encode-registry: ^3.0.1 enquirer: ^2.4.1 - esbuild: ^0.25.0 + esbuild: ^0.25.9 escape-string-regexp: ^4.0.0 eslint: ^8.57.1 eslint-config-standard-with-typescript: ^39.1.1 @@ -176,7 +176,7 @@ catalog: eslint-plugin-node: ^11.1.0 eslint-plugin-promise: ^6.6.0 eslint-plugin-regexp: 2.7.0 - execa: npm:safe-execa@0.1.2 + execa: npm:safe-execa@0.2.0 exists-link: 2.0.0 fast-deep-equal: ^3.1.3 fast-glob: ^3.3.2 @@ -203,7 +203,7 @@ catalog: isexe: 2.0.0 jest: ^30.0.5 jest-diff: ^29.7.0 - js-yaml: npm:@zkochan/js-yaml@0.0.9 + js-yaml: npm:@zkochan/js-yaml@0.0.10 json5: ^2.2.3 keyv: 4.5.4 lcov-result-merger: ^3.3.0 @@ -218,7 +218,7 @@ catalog: micromatch: ^4.0.8 ndjson: ^2.0.0 nock: 13.3.4 - node-fetch: npm:@pnpm/node-fetch@1.0.0 + node-fetch: ^3.3.2 node-gyp: ^11.0.0 normalize-newline: 3.0.0 normalize-package-data: ^7.0.1 @@ -233,7 +233,7 @@ catalog: p-limit: ^3.1.0 p-map-values: ^1.0.0 p-memoize: 4.0.1 - p-queue: ^6.6.2 + p-queue: ^8.1.0 p-settle: ^4.1.1 parse-json: ^5.2.0 parse-npm-tarball-url: ^3.0.0 @@ -266,13 +266,13 @@ catalog: run-groups: ^3.0.1 rxjs: ^7.8.1 safe-buffer: 5.2.1 - safe-execa: ^0.1.4 + safe-execa: ^0.2.0 safe-promise-defer: ^1.0.1 sanitize-filename: ^1.6.3 semver: ^7.7.1 semver-range-intersect: ^0.3.1 semver-utils: ^1.1.4 - shlex: ^2.1.2 + shlex: ^3.0.0 shx: ^0.3.4 signal-exit: ^3.0.7 sinon: ^16.1.3 @@ -386,6 +386,7 @@ packageExtensions: unified: '*' patchedDependencies: + '@pnpm/npm-lifecycle': __patches__/@pnpm__npm-lifecycle.patch '@yao-pkg/pkg': __patches__/pkg.patch graceful-fs@4.2.11: __patches__/graceful-fs@4.2.11.patch mdast-util-to-string@2.0.0: __patches__/mdast-util-to-string@2.0.0.patch @@ -407,7 +408,6 @@ updateConfig: - camelcase - camelcase-keys - chalk - - detect-indent - escape-string-regexp - filenamify - find-up diff --git a/pnpm/artifacts/exe/package.json b/pnpm/artifacts/exe/package.json index d61abb04b9..10d465bfd4 100644 --- a/pnpm/artifacts/exe/package.json +++ b/pnpm/artifacts/exe/package.json @@ -13,6 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, + "type": "module", "scripts": { "preinstall": "node setup.js", "prepare": "node prepare.js", diff --git a/pnpm/artifacts/exe/prepare.js b/pnpm/artifacts/exe/prepare.js index 194da1a2a9..6e5ef5b431 100644 --- a/pnpm/artifacts/exe/prepare.js +++ b/pnpm/artifacts/exe/prepare.js @@ -1,6 +1,6 @@ -const fs = require('fs') -const path = require('path') +import fs from 'fs' +import path from 'path' -const pnpmCli = path.join(__dirname, 'pnpm') +const pnpmCli = path.join(import.meta.dirname, 'pnpm') fs.unlinkSync(pnpmCli) fs.writeFileSync(pnpmCli, 'This file intentionally left blank', 'utf8') diff --git a/pnpm/artifacts/exe/scripts/build-artifacts.ts b/pnpm/artifacts/exe/scripts/build-artifacts.ts index 2fc812cf8a..9febd234c1 100644 --- a/pnpm/artifacts/exe/scripts/build-artifacts.ts +++ b/pnpm/artifacts/exe/scripts/build-artifacts.ts @@ -2,7 +2,7 @@ import * as execa from 'execa' import fs from 'fs' import path from 'path' -const artifactsDir = path.join(__dirname, '../..') +const artifactsDir = path.join(import.meta.dirname, '../..') function build (target: string) { let artifactFile = path.join(artifactsDir, target, 'pnpm') @@ -12,8 +12,8 @@ function build (target: string) { try { fs.unlinkSync(artifactFile) } catch {} - execa.sync('pkg', ['../../dist/pnpm.cjs', `--config=../../package-${target}.json`], { - cwd: path.join(__dirname, '..'), + execa.sync('pkg', ['../../pnpm.mjs', `--config=../../package-${target}.json`, '--sea'], { + cwd: path.join(import.meta.dirname, '..'), stdio: 'inherit', }) // Verifying that the artifact was created. @@ -22,14 +22,12 @@ function build (target: string) { build('win-x64') build('linux-x64') -build('linuxstatic-x64') build('macos-x64') const isM1Mac = process.platform === 'darwin' && process.arch === 'arm64' if (process.platform === 'linux' || isM1Mac) { build('macos-arm64') build('linux-arm64') - build('linuxstatic-arm64') build('win-arm64') } diff --git a/pnpm/artifacts/exe/setup.js b/pnpm/artifacts/exe/setup.js index 1e238e8c71..6e0cc5eae1 100644 --- a/pnpm/artifacts/exe/setup.js +++ b/pnpm/artifacts/exe/setup.js @@ -1,5 +1,6 @@ -const path = require('path') -const fs = require('fs') +import { fileURLToPath } from 'url' +import path from 'path' +import fs from 'fs' const platform = process.platform === 'win32' ? 'win' @@ -9,7 +10,7 @@ const platform = process.platform === 'win32' const arch = platform === 'win' && process.arch === 'ia32' ? 'x86' : process.arch const pkgName = `@pnpm/${platform}-${arch}` -const pkgJson = require.resolve(`${pkgName}/package.json`) +const pkgJson = fileURLToPath(import.meta.resolve(`${pkgName}/package.json`)) const subpkg = JSON.parse(fs.readFileSync(pkgJson, 'utf8')) if (subpkg.bin != null) { diff --git a/pnpm/bin/pnpm.cjs b/pnpm/bin/pnpm.mjs similarity index 79% rename from pnpm/bin/pnpm.cjs rename to pnpm/bin/pnpm.mjs index 2111381bea..0d81f354c7 100755 --- a/pnpm/bin/pnpm.cjs +++ b/pnpm/bin/pnpm.mjs @@ -3,7 +3,7 @@ const [major, minor] = process.version.slice(1).split('.') const COMPATIBILITY_PAGE = `Visit https://r.pnpm.io/comp to see the list of past pnpm versions with respective Node.js version support.` // We don't use the semver library here because: -// 1. it is already bundled to dist/pnpm.cjs, so we would load it twice +// 1. it is already bundled to dist/pnpm.mjs, so we would load it twice // 2. we want this file to support potentially older Node.js versions than what semver supports if (major < 20 || major == 20 && minor < 19) { console.error(`ERROR: This version of pnpm requires at least Node.js v20.19 @@ -12,17 +12,18 @@ ${COMPATIBILITY_PAGE}`) process.exit(1) } +import * as module from 'module' + // We need to load v8-compile-cache.js separately in order to have effect try { - // Use node.js 22 new API for better performance. - if(!require('module')?.enableCompileCache?.()) - require('v8-compile-cache'); + module.enableCompileCache?.() } catch { // We don't have/need to care about v8-compile-cache failed } global['pnpm__startedAt'] = Date.now() -require('../dist/pnpm.cjs') + +import {} from '../dist/pnpm.mjs' // if you want to debug at your local env, you can use this // require('../lib/pnpm') diff --git a/pnpm/bin/pnpx.cjs b/pnpm/bin/pnpx.mjs similarity index 78% rename from pnpm/bin/pnpx.cjs rename to pnpm/bin/pnpx.mjs index 8deb37e359..c7a6235907 100755 --- a/pnpm/bin/pnpx.cjs +++ b/pnpm/bin/pnpx.mjs @@ -2,4 +2,4 @@ process.argv = [...process.argv.slice(0, 2), 'dlx', ...process.argv.slice(2)] -require('./pnpm.cjs') +await import('./pnpm.mjs') diff --git a/pnpm/bundle.ts b/pnpm/bundle.ts index ad8181f5aa..422216e72d 100644 --- a/pnpm/bundle.ts +++ b/pnpm/bundle.ts @@ -7,11 +7,14 @@ import { build } from 'esbuild' */ ;(async () => { try { + const banner = { js: `import { createRequire as _cr } from 'module';const require = _cr(import.meta.url); const __filename = import.meta.filename; const __dirname = import.meta.dirname` } await build({ entryPoints: ['lib/pnpm.js'], bundle: true, platform: 'node', - outfile: 'dist/pnpm.cjs', + outfile: 'dist/pnpm.mjs', + format: 'esm', + banner, external: [ 'node-gyp', './get-uid-gid.js', // traces back to: https://github.com/npm/uid-number/blob/6e9bdb302ae4799d05abf12e922ccdb4bd9ea023/uid-number.js#L31 @@ -33,7 +36,9 @@ import { build } from 'esbuild' entryPoints: ['../worker/lib/worker.js'], bundle: true, platform: 'node', + format: 'esm', outfile: 'dist/worker.js', + banner, loader: { '.node': 'copy', }, diff --git a/pnpm/dev/package.json b/pnpm/dev/package.json index 68b4e3e7bc..24b733f60b 100644 --- a/pnpm/dev/package.json +++ b/pnpm/dev/package.json @@ -3,6 +3,7 @@ "version": "1000.0.0", "bin": "pd.js", "private": true, + "type": "module", "scripts": { "test": "pnpm run _test", "_test": "node pd.js --version" diff --git a/pnpm/dev/pd.js b/pnpm/dev/pd.js index 66d6d601bf..d59e4e533c 100755 --- a/pnpm/dev/pd.js +++ b/pnpm/dev/pd.js @@ -1,17 +1,17 @@ #!/usr/bin/env node -const fs = require('fs') -const esbuild = require('esbuild') -const pathLib = require('path') -const childProcess = require('child_process') -const { createRequire } = require('module') -const { findWorkspacePackagesNoCheck } = require('@pnpm/workspace.find-packages') -const { findWorkspaceDir } = require('@pnpm/find-workspace-dir') -const { readWorkspaceManifest } = require('@pnpm/workspace.read-manifest') +import fs from 'fs' +import esbuild from 'esbuild' +import pathLib from 'path' +import childProcess from 'child_process' +import { createRequire } from 'module' +import { findWorkspacePackagesNoCheck } from '@pnpm/workspace.find-packages' +import { findWorkspaceDir } from '@pnpm/find-workspace-dir' +import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest' -const pnpmPackageJson = JSON.parse(fs.readFileSync(pathLib.join(__dirname, 'package.json'), 'utf8')) +const pnpmPackageJson = JSON.parse(fs.readFileSync(pathLib.join(import.meta.dirname, 'package.json'), 'utf8')) ;(async () => { - const workspaceDir = await findWorkspaceDir(__dirname) + const workspaceDir = await findWorkspaceDir(import.meta.dirname) const workspaceManifest = await readWorkspaceManifest(workspaceDir) const pkgs = await findWorkspacePackagesNoCheck(workspaceDir, { patterns: workspaceManifest.packages }) const localPackages = pkgs.map(pkg => pkg.manifest.name) @@ -42,7 +42,7 @@ const pnpmPackageJson = JSON.parse(fs.readFileSync(pathLib.join(__dirname, 'pack if (path === 'js-yaml' && resolveDir.includes('lockfile/fs')) { // Force esbuild to use the resolved js-yaml from within lockfile-file, // since it seems to pick the wrong one otherwise. - const lockfileFileProject = pathLib.resolve(__dirname, '../../lockfile/fs/index.js') + const lockfileFileProject = pathLib.resolve(import.meta.dirname, '../../lockfile/fs/index.js') const resolvedJsYaml = createRequire(lockfileFileProject).resolve('js-yaml') return { path: resolvedJsYaml @@ -52,11 +52,14 @@ const pnpmPackageJson = JSON.parse(fs.readFileSync(pathLib.join(__dirname, 'pack } } + const banner = { js: `import { createRequire as _cr } from 'module';const require = _cr(import.meta.url); const __filename = import.meta.filename; const __dirname = import.meta.dirname` } await esbuild.build({ - entryPoints: [pathLib.resolve(__dirname, '../../worker/src/worker.ts')], + entryPoints: [pathLib.resolve(import.meta.dirname, '../../worker/src/worker.ts')], bundle: true, + banner, platform: 'node', - outfile: pathLib.resolve(__dirname, 'dist/worker.js'), + format: 'esm', + outfile: pathLib.resolve(import.meta.dirname, 'dist/worker.js'), loader: { '.node': 'copy', }, @@ -65,9 +68,11 @@ const pnpmPackageJson = JSON.parse(fs.readFileSync(pathLib.join(__dirname, 'pack await esbuild.build({ bundle: true, platform: 'node', + format: 'esm', + banner, target: 'node14', - entryPoints: [pathLib.resolve(__dirname, '../src/pnpm.ts')], - outfile: pathLib.resolve(__dirname, 'dist/pnpm.cjs'), + entryPoints: [pathLib.resolve(import.meta.dirname, '../src/pnpm.ts')], + outfile: pathLib.resolve(import.meta.dirname, 'dist/pnpm.mjs'), external: [ 'node-gyp', './get-uid-gid.js', // traces back to: https://github.com/npm/uid-number/blob/6e9bdb302ae4799d05abf12e922ccdb4bd9ea023/uid-number.js#L31 @@ -89,7 +94,7 @@ const pnpmPackageJson = JSON.parse(fs.readFileSync(pathLib.join(__dirname, 'pack // Invoke the script just built by esbuild, with Node's sourcemaps enabled const { status } = childProcess.spawnSync(nodeBin, [ '--enable-source-maps', - pathLib.resolve(__dirname, 'dist/pnpm.cjs'), + pathLib.resolve(import.meta.dirname, 'dist/pnpm.mjs'), '--config.manage-package-manager-versions=false', ...process.argv.slice(2), ], { diff --git a/pnpm/package.json b/pnpm/package.json index 32d49b9f50..5931868f3b 100644 --- a/pnpm/package.json +++ b/pnpm/package.json @@ -40,8 +40,8 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", - "main": "bin/pnpm.cjs", + "type": "module", + "main": "bin/pnpm.mjs", "exports": { ".": "./package.json" }, @@ -50,19 +50,19 @@ "bin" ], "bin": { - "pnpm": "bin/pnpm.cjs", - "pnpx": "bin/pnpx.cjs" + "pnpm": "bin/pnpm.mjs", + "pnpx": "bin/pnpx.mjs" }, "directories": { "test": "test" }, - "unpkg": "dist/pnpm.cjs", + "unpkg": "dist/pnpm.mjs", "scripts": { - "bundle": "ts-node bundle.ts", + "bundle": "pnpm --config.useNodeVersion=24.6.0 exec ts-node bundle.ts", "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "pretest:e2e": "rimraf node_modules/.bin/pnpm", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm compile && publish-packed --prune --npm-client=pnpm --dest=dist", "postpublish": "publish-packed", @@ -192,7 +192,7 @@ "hosted-git-info@1": "npm:@pnpm/hosted-git-info@1.0.0", "http-proxy-middleware@<2.0.7": "^2.0.7", "istanbul-reports": "npm:@zkochan/istanbul-reports", - "js-yaml@^4.0.0": "npm:@zkochan/js-yaml@0.0.9", + "js-yaml@^4.0.0": "npm:@zkochan/js-yaml@0.0.10", "json5@<2.2.2": "^2.2.3", "jsonwebtoken@<=8.5.1": ">=9.0.0", "nopt@5": "npm:@pnpm/nopt@^0.2.1", diff --git a/pnpm/pnpm.cjs b/pnpm/pnpm.cjs new file mode 100644 index 0000000000..8902cb3b2b --- /dev/null +++ b/pnpm/pnpm.cjs @@ -0,0 +1,5 @@ +// CJS → ESM bridge for pkg/SEA +;(async () => { + // import the real ESM entry; side effects will run like a CLI + await import('./dist/pnpm.mjs') +})() diff --git a/pnpm/src/checkForUpdates.test.ts b/pnpm/src/checkForUpdates.test.ts index 12d49645b6..1ffb71030f 100644 --- a/pnpm/src/checkForUpdates.test.ts +++ b/pnpm/src/checkForUpdates.test.ts @@ -1,15 +1,18 @@ import { getConfig } from '@pnpm/config' -import { updateCheckLogger } from '@pnpm/core-loggers' import { prepareEmpty } from '@pnpm/prepare' import { jest } from '@jest/globals' import loadJsonFile from 'load-json-file' import writeJsonFile from 'write-json-file' -import { checkForUpdates } from './checkForUpdates.js' -jest.mock('@pnpm/core-loggers', () => ({ +const original = await import('@pnpm/core-loggers') +jest.unstable_mockModule('@pnpm/core-loggers', () => ({ + ...original, updateCheckLogger: { debug: jest.fn() }, })) +const { updateCheckLogger } = await import('@pnpm/core-loggers') +const { checkForUpdates } = await import('./checkForUpdates.js') + beforeEach(() => { jest.mocked(updateCheckLogger.debug).mockReset() }) diff --git a/pnpm/src/cmd/bin.ts b/pnpm/src/cmd/bin.ts index 78afaaadc6..4cf0713c80 100644 --- a/pnpm/src/cmd/bin.ts +++ b/pnpm/src/cmd/bin.ts @@ -1,6 +1,6 @@ import { docsUrl } from '@pnpm/cli-utils' import { types as allTypes } from '@pnpm/config' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' export const rcOptionsTypes = cliOptionsTypes diff --git a/pnpm/src/cmd/index.ts b/pnpm/src/cmd/index.ts index c00090f260..d7798c776b 100644 --- a/pnpm/src/cmd/index.ts +++ b/pnpm/src/cmd/index.ts @@ -28,7 +28,7 @@ import { setup } from '@pnpm/plugin-commands-setup' import { store } from '@pnpm/plugin-commands-store' import { catFile, catIndex, findHash } from '@pnpm/plugin-commands-store-inspecting' import { init } from '@pnpm/plugin-commands-init' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import { type PnpmOptions } from '../types.js' import { shorthands as universalShorthands } from '../shorthands.js' import { parseCliArgs } from '../parseCliArgs.js' diff --git a/pnpm/src/cmd/root.ts b/pnpm/src/cmd/root.ts index 468617012a..51208f9c5f 100644 --- a/pnpm/src/cmd/root.ts +++ b/pnpm/src/cmd/root.ts @@ -1,7 +1,7 @@ import path from 'path' import { types as allTypes } from '@pnpm/config' import { docsUrl } from '@pnpm/cli-utils' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' export const rcOptionsTypes = cliOptionsTypes diff --git a/pnpm/src/main.ts b/pnpm/src/main.ts index 1caf3968ee..6f010fc23f 100644 --- a/pnpm/src/main.ts +++ b/pnpm/src/main.ts @@ -20,7 +20,7 @@ import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' import { finishWorkers } from '@pnpm/worker' import chalk from 'chalk' import path from 'path' -import isEmpty from 'ramda/src/isEmpty' +import { isEmpty } from 'ramda' import { stripVTControlCharacters as stripAnsi } from 'util' import { checkForUpdates } from './checkForUpdates.js' import { pnpmCmds, rcOptionsTypes, skipPackageManagerCheckForCommand } from './cmd/index.js' diff --git a/pnpm/src/runNpm.ts b/pnpm/src/runNpm.ts index cd9b7c29c0..882b0a4c36 100644 --- a/pnpm/src/runNpm.ts +++ b/pnpm/src/runNpm.ts @@ -2,7 +2,7 @@ import { type SpawnSyncReturns } from 'child_process' import { packageManager } from '@pnpm/cli-meta' import { getConfig, types as allTypes } from '@pnpm/config' import { runNpm as _runNpm } from '@pnpm/run-npm' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' export async function runNpm (args: string[]): Promise> { const { config } = await getConfig({ diff --git a/pnpm/test/cli.ts b/pnpm/test/cli.ts index c0768211e3..653421c6aa 100644 --- a/pnpm/test/cli.ts +++ b/pnpm/test/cli.ts @@ -12,7 +12,7 @@ import { execPnpxSync, } from './utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const hasOutdatedDepsFixture = f.find('has-outdated-deps') test('some commands pass through to npm', () => { diff --git a/pnpm/test/errorHandler.test.ts b/pnpm/test/errorHandler.test.ts index 4235be43a8..d7cde4268e 100644 --- a/pnpm/test/errorHandler.test.ts +++ b/pnpm/test/errorHandler.test.ts @@ -4,7 +4,7 @@ import { execPnpmSync } from './utils/index.js' import { fixtures } from '@pnpm/test-fixtures' import { isPortInUse } from './utils/isPortInUse.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const multipleScriptsErrorExit = f.find('multiple-scripts-error-exit') test('should print json format error when publish --json failed', async () => { diff --git a/pnpm/test/install/lifecycleScripts.ts b/pnpm/test/install/lifecycleScripts.ts index 5270bc7353..c3bc0963cb 100644 --- a/pnpm/test/install/lifecycleScripts.ts +++ b/pnpm/test/install/lifecycleScripts.ts @@ -10,7 +10,7 @@ import { execPnpm, execPnpmSync, pnpmBinLocation } from '../utils/index.js' import { getIntegrity } from '@pnpm/registry-mock' import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest' -const pkgRoot = path.join(__dirname, '..', '..') +const pkgRoot = path.join(import.meta.dirname, '..', '..') const pnpmPkg = loadJsonFile.sync(path.join(pkgRoot, 'package.json')) test('installation fails if lifecycle script fails', () => { @@ -121,7 +121,7 @@ test('dependency should not be added to package.json and lockfile if it was not expect(project.readLockfile()).toBeFalsy() const { default: pkg } = await import(path.resolve('package.json')) - expect(pkg).toStrictEqual(initialPkg) + expect(pkg).toEqual(initialPkg) }) test('node-gyp is in the PATH', async () => { diff --git a/pnpm/test/install/misc.ts b/pnpm/test/install/misc.ts index 9131c75245..8305a830f2 100644 --- a/pnpm/test/install/misc.ts +++ b/pnpm/test/install/misc.ts @@ -22,7 +22,7 @@ import { } from '../utils/index.js' const skipOnWindows = isWindows() ? test.skip : test -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('bin files are found by lifecycle scripts', () => { prepare({ @@ -162,7 +162,7 @@ test("don't fail on case insensitive filesystems when package has 2 files with s expect(packageFiles).toStrictEqual(['Foo.js', 'foo.js', 'package.json']) const files = fs.readdirSync('node_modules/@pnpm.e2e/with-same-file-in-different-cases') const storeDir = project.getStorePath() - if (await dirIsCaseSensitive(storeDir)) { + if (await dirIsCaseSensitive.default(storeDir)) { expect([...files].sort()).toStrictEqual(['Foo.js', 'foo.js', 'package.json']) } else { expect([...files].map((f) => f.toLowerCase()).sort()).toStrictEqual(['foo.js', 'package.json']) @@ -216,7 +216,7 @@ test('create a package.json if there is none', async () => { await execPnpm(['install', '@pnpm.e2e/dep-of-pkg-with-1-dep@100.1.0']) - expect((await import(path.resolve('package.json'))).default).toStrictEqual({ + expect((await import(path.resolve('package.json'))).default).toEqual({ dependencies: { '@pnpm.e2e/dep-of-pkg-with-1-dep': '100.1.0', }, diff --git a/pnpm/test/install/only.ts b/pnpm/test/install/only.ts index 1883b286fa..3cabb66cc3 100644 --- a/pnpm/test/install/only.ts +++ b/pnpm/test/install/only.ts @@ -4,7 +4,7 @@ import { type PackageManifest } from '@pnpm/types' import loadJsonFile from 'load-json-file' import { execPnpm } from '../utils/index.js' -const basicPackageManifest = loadJsonFile.sync(path.join(__dirname, '../utils/simple-package.json')) +const basicPackageManifest = loadJsonFile.sync(path.join(import.meta.dirname, '../utils/simple-package.json')) test('production install (with --production flag)', async () => { const project = prepare(basicPackageManifest) diff --git a/pnpm/test/monorepo/index.ts b/pnpm/test/monorepo/index.ts index f24f4dd8c6..cf0b9add2d 100644 --- a/pnpm/test/monorepo/index.ts +++ b/pnpm/test/monorepo/index.ts @@ -111,9 +111,9 @@ test('linking a package inside a monorepo with --link-workspace-packages when in const { default: pkg } = await import(path.resolve('package.json')) - expect(pkg?.dependencies).toStrictEqual({ 'project-2': 'workspace:^' }) // spec of linked package added to dependencies - expect(pkg?.devDependencies).toStrictEqual({ 'project-3': 'workspace:^' }) // spec of linked package added to devDependencies - expect(pkg?.optionalDependencies).toStrictEqual({ 'project-4': '^4.0.0' }) // spec of linked package added to optionalDependencies + expect(pkg?.dependencies).toEqual({ 'project-2': 'workspace:^' }) // spec of linked package added to dependencies + expect(pkg?.devDependencies).toEqual({ 'project-3': 'workspace:^' }) // spec of linked package added to devDependencies + expect(pkg?.optionalDependencies).toEqual({ 'project-4': '^4.0.0' }) // spec of linked package added to optionalDependencies projects['project-1'].has('project-2') projects['project-1'].has('project-3') @@ -156,9 +156,9 @@ test('linking a package inside a monorepo with --link-workspace-packages when in const { default: pkg } = await import(path.resolve('package.json')) - expect(pkg?.dependencies).toStrictEqual({ 'project-2': 'workspace:^' }) // spec of linked package added to dependencies - expect(pkg?.devDependencies).toStrictEqual({ 'project-3': 'workspace:^' }) // spec of linked package added to devDependencies - expect(pkg?.optionalDependencies).toStrictEqual({ 'project-4': '^4.0.0' }) // spec of linked package added to optionalDependencies + expect(pkg?.dependencies).toEqual({ 'project-2': 'workspace:^' }) // spec of linked package added to dependencies + expect(pkg?.devDependencies).toEqual({ 'project-3': 'workspace:^' }) // spec of linked package added to devDependencies + expect(pkg?.optionalDependencies).toEqual({ 'project-4': '^4.0.0' }) // spec of linked package added to optionalDependencies projects['project-1'].has('project-2') projects['project-1'].has('project-3') diff --git a/pnpm/test/patch/allowUnusedPatches.ts b/pnpm/test/patch/allowUnusedPatches.ts index c4005e915b..8ec8c90282 100644 --- a/pnpm/test/patch/allowUnusedPatches.ts +++ b/pnpm/test/patch/allowUnusedPatches.ts @@ -3,7 +3,7 @@ import { fixtures } from '@pnpm/test-fixtures' import { sync as writeYamlFile } from 'write-yaml-file' import { execPnpmSync } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('allowUnusedPatches=false errors on unused patches', async () => { preparePackages([ diff --git a/pnpm/test/patch/ignorePatchFailures.ts b/pnpm/test/patch/ignorePatchFailures.ts index b14b5f17e5..c778c6830a 100644 --- a/pnpm/test/patch/ignorePatchFailures.ts +++ b/pnpm/test/patch/ignorePatchFailures.ts @@ -4,7 +4,7 @@ import { fixtures } from '@pnpm/test-fixtures' import { sync as writeYamlFile } from 'write-yaml-file' import { execPnpmSync } from '../utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) describe('ignorePatchFailures=undefined (necessary for backward-compatibility)', () => { test('errors on exact version patch failures', async () => { diff --git a/pnpm/test/syncInjectedDepsAfterScripts.ts b/pnpm/test/syncInjectedDepsAfterScripts.ts index 3e4862ead5..2b91219955 100644 --- a/pnpm/test/syncInjectedDepsAfterScripts.ts +++ b/pnpm/test/syncInjectedDepsAfterScripts.ts @@ -5,7 +5,7 @@ import { fixtures } from '@pnpm/test-fixtures' import { sync as writeYamlFile } from 'write-yaml-file' import { execPnpm } from './utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const PKG_FILES = [ ...fs.readdirSync(f.find('injected-dep-files')), diff --git a/pnpm/test/tsconfig.json b/pnpm/test/tsconfig.json index e1f71d2cac..10250a5e38 100644 --- a/pnpm/test/tsconfig.json +++ b/pnpm/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/pnpm/test/utils/execPnpm.ts b/pnpm/test/utils/execPnpm.ts index f0d0bfda9b..4182c66fd2 100644 --- a/pnpm/test/utils/execPnpm.ts +++ b/pnpm/test/utils/execPnpm.ts @@ -4,9 +4,9 @@ import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import isWindows from 'is-windows' import crossSpawn from 'cross-spawn' -export const binDir = path.join(__dirname, '../..', isWindows() ? 'dist' : 'bin') -export const pnpmBinLocation = path.join(binDir, 'pnpm.cjs') -export const pnpxBinLocation = path.join(__dirname, '../../bin/pnpx.cjs') +export const binDir = path.join(import.meta.dirname, '../..', isWindows() ? 'dist' : 'bin') +export const pnpmBinLocation = path.join(binDir, 'pnpm.mjs') +export const pnpxBinLocation = path.join(import.meta.dirname, '../../bin/pnpx.mjs') // The default timeout for tests is 4 minutes. Set a timeout for execPnpm calls // for 3 minutes to make it more clear what specific part of a test is timing diff --git a/pnpm/test/utils/localPkg.ts b/pnpm/test/utils/localPkg.ts index 54e52bdd2f..0ea29a2bf5 100644 --- a/pnpm/test/utils/localPkg.ts +++ b/pnpm/test/utils/localPkg.ts @@ -1,7 +1,7 @@ import path from 'path' export function pathToLocalPkg (pkgName: string): string { - return path.join(__dirname, '../../../../fixtures', pkgName) + return path.join(import.meta.dirname, '../../../../fixtures', pkgName) } export function local (pkgName: string): string { diff --git a/releasing/plugin-commands-deploy/package.json b/releasing/plugin-commands-deploy/package.json index 1e07ed9a55..c94a254840 100644 --- a/releasing/plugin-commands-deploy/package.json +++ b/releasing/plugin-commands-deploy/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ "scripts": { "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/releasing/plugin-commands-deploy/src/createDeployFiles.ts b/releasing/plugin-commands-deploy/src/createDeployFiles.ts index f9a0ea8030..81fff6e321 100644 --- a/releasing/plugin-commands-deploy/src/createDeployFiles.ts +++ b/releasing/plugin-commands-deploy/src/createDeployFiles.ts @@ -1,7 +1,7 @@ import path from 'path' import url from 'url' import normalizePath from 'normalize-path' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import { USEFUL_NON_ROOT_PNPM_FIELDS } from '@pnpm/constants' import * as dp from '@pnpm/dependency-path' import { diff --git a/releasing/plugin-commands-deploy/src/deploy.ts b/releasing/plugin-commands-deploy/src/deploy.ts index a26edd0dc1..b361c06eb9 100644 --- a/releasing/plugin-commands-deploy/src/deploy.ts +++ b/releasing/plugin-commands-deploy/src/deploy.ts @@ -1,6 +1,6 @@ import fs from 'fs' import path from 'path' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import { docsUrl } from '@pnpm/cli-utils' import { type Config, types as configTypes } from '@pnpm/config' import { fetchFromDir } from '@pnpm/directory-fetcher' diff --git a/releasing/plugin-commands-deploy/test/deploy.test.ts b/releasing/plugin-commands-deploy/test/deploy.test.ts index ebbe274de8..63cf70701a 100644 --- a/releasing/plugin-commands-deploy/test/deploy.test.ts +++ b/releasing/plugin-commands-deploy/test/deploy.test.ts @@ -1,16 +1,29 @@ import fs from 'fs' import path from 'path' -import { deploy } from '@pnpm/plugin-commands-deploy' import { assertProject } from '@pnpm/assert-project' import { preparePackages } from '@pnpm/prepare' -import { logger, globalWarn } from '@pnpm/logger' import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir' import { jest } from '@jest/globals' import { DEFAULT_OPTS } from './utils/index.js' +const original = await import('@pnpm/logger') +const warn = jest.fn() +jest.unstable_mockModule('@pnpm/logger', () => { + const logger = { + ...original.logger, + warn, + } + return { + ...original, + globalWarn: jest.fn(), + logger: Object.assign(() => logger, logger), + } +}) +const { globalWarn } = await import('@pnpm/logger') +const { deploy } = await import('@pnpm/plugin-commands-deploy') + beforeEach(async () => { - const logger = await import('@pnpm/logger') - jest.spyOn(logger, 'globalWarn') + jest.mocked(globalWarn).mockClear() }) afterEach(() => { @@ -337,8 +350,6 @@ test('deploy fails when the destination directory exists and is not empty', asyn }) test('forced deploy succeeds with a warning when destination directory exists and is not empty', async () => { - const warnMock = jest.spyOn(logger, 'warn') - preparePackages([ { name: 'project', @@ -374,7 +385,7 @@ test('forced deploy succeeds with a warning when destination directory exists an workspaceDir: process.cwd(), }, [deployPath]) - expect(warnMock).toHaveBeenCalledWith({ + expect(warn).toHaveBeenCalledWith({ message: expect.stringMatching(/^using --force, deleting deploy pat/), prefix: deployFullPath, }) @@ -386,7 +397,7 @@ test('forced deploy succeeds with a warning when destination directory exists an expect(fs.existsSync('deploy/index.js')).toBeTruthy() expect(fs.existsSync('pnpm-lock.yaml')).toBeFalsy() // no changes to the lockfile are written - warnMock.mockRestore() + warn.mockRestore() }) test('deploy with dedupePeerDependents=true ignores the value of dedupePeerDependents', async () => { diff --git a/releasing/plugin-commands-deploy/test/shared-lockfile.test.ts b/releasing/plugin-commands-deploy/test/shared-lockfile.test.ts index c8480c6bf2..760cc6dcfc 100644 --- a/releasing/plugin-commands-deploy/test/shared-lockfile.test.ts +++ b/releasing/plugin-commands-deploy/test/shared-lockfile.test.ts @@ -1,12 +1,10 @@ import fs from 'fs' import path from 'path' import url from 'url' -import { deploy } from '@pnpm/plugin-commands-deploy' import { install } from '@pnpm/plugin-commands-installation' import { assertProject } from '@pnpm/assert-project' import { preparePackages } from '@pnpm/prepare' import { type PatchFile, type LockfileFile, type LockfilePackageSnapshot } from '@pnpm/lockfile.types' -import { globalWarn } from '@pnpm/logger' import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir' import { fixtures } from '@pnpm/test-fixtures' import { type ProjectManifest } from '@pnpm/types' @@ -14,13 +12,28 @@ import { jest } from '@jest/globals' import writeYamlFile from 'write-yaml-file' import { DEFAULT_OPTS } from './utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const resolvePathAsUrl = (...paths: string[]): string => url.pathToFileURL(path.resolve(...paths)).toString() +const original = await import('@pnpm/logger') +const warn = jest.fn() +jest.unstable_mockModule('@pnpm/logger', () => { + const logger = { + ...original.logger, + warn, + } + return { + ...original, + globalWarn: jest.fn(), + logger: Object.assign(() => logger, logger), + } +}) +const { globalWarn } = await import('@pnpm/logger') +const { deploy } = await import('@pnpm/plugin-commands-deploy') + beforeEach(async () => { - const logger = await import('@pnpm/logger') - jest.spyOn(logger, 'globalWarn') + jest.mocked(globalWarn).mockClear() }) afterEach(() => { diff --git a/releasing/plugin-commands-deploy/test/tsconfig.json b/releasing/plugin-commands-deploy/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/releasing/plugin-commands-deploy/test/tsconfig.json +++ b/releasing/plugin-commands-deploy/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/releasing/plugin-commands-publishing/package.json b/releasing/plugin-commands-publishing/package.json index ff679d51ac..6e3264f8bc 100644 --- a/releasing/plugin-commands-publishing/package.json +++ b/releasing/plugin-commands-publishing/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "scripts": { "start": "tsc --watch", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/releasing/plugin-commands-publishing/src/pack.ts b/releasing/plugin-commands-publishing/src/pack.ts index eeb9687e50..5c988b52d3 100644 --- a/releasing/plugin-commands-publishing/src/pack.ts +++ b/releasing/plugin-commands-publishing/src/pack.ts @@ -10,7 +10,7 @@ import { packlist } from '@pnpm/fs.packlist' import { getBinsFromPackageManifest } from '@pnpm/package-bins' import { type ProjectManifest, type Project, type ProjectRootDir, type ProjectsGraph, type DependencyManifest } from '@pnpm/types' import { glob } from 'tinyglobby' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import realpathMissing from 'realpath-missing' import renderHelp from 'render-help' import tar from 'tar-stream' diff --git a/releasing/plugin-commands-publishing/src/publish.ts b/releasing/plugin-commands-publishing/src/publish.ts index 52833ea545..a1a5df7cab 100644 --- a/releasing/plugin-commands-publishing/src/publish.ts +++ b/releasing/plugin-commands-publishing/src/publish.ts @@ -10,9 +10,9 @@ import { type ProjectManifest } from '@pnpm/types' import { getCurrentBranch, isGitRepo, isRemoteHistoryClean, isWorkingTreeClean } from '@pnpm/git-utils' import { loadToken } from '@pnpm/network.auth-header' import { prepareExecutionEnv } from '@pnpm/plugin-commands-env' -import { prompt } from 'enquirer' +import enquirer from 'enquirer' import rimraf from '@zkochan/rimraf' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import realpathMissing from 'realpath-missing' import renderHelp from 'render-help' import tempy from 'tempy' @@ -162,7 +162,7 @@ export async function publish ( ) } if (!branches.includes(currentBranch)) { - const { confirm } = await prompt({ + const { confirm } = await enquirer.prompt({ message: `You're on branch "${currentBranch}" but your "publish-branch" is set to "${branches.join('|')}". \ Do you want to continue?`, name: 'confirm', diff --git a/releasing/plugin-commands-publishing/src/recursivePublish.ts b/releasing/plugin-commands-publishing/src/recursivePublish.ts index ad03720b89..b674150667 100644 --- a/releasing/plugin-commands-publishing/src/recursivePublish.ts +++ b/releasing/plugin-commands-publishing/src/recursivePublish.ts @@ -7,7 +7,7 @@ import { type ResolveFunction } from '@pnpm/resolver-base' import { sortPackages } from '@pnpm/sort-packages' import { type Registries, type ProjectRootDir } from '@pnpm/types' import pFilter from 'p-filter' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import writeJsonFile from 'write-json-file' import { publish } from './publish.js' diff --git a/releasing/plugin-commands-publishing/test/gitChecks.ts b/releasing/plugin-commands-publishing/test/gitChecks.ts index e6210d45dd..f4e3fd920b 100644 --- a/releasing/plugin-commands-publishing/test/gitChecks.ts +++ b/releasing/plugin-commands-publishing/test/gitChecks.ts @@ -5,16 +5,14 @@ import { PnpmError } from '@pnpm/error' import execa from 'execa' import tempy from 'tempy' -import * as enquirer from 'enquirer' - -import { publish } from '@pnpm/plugin-commands-publishing' import { jest } from '@jest/globals' import { DEFAULT_OPTS } from './utils/index.js' -jest.mock('enquirer', () => ({ prompt: jest.fn() })) +jest.unstable_mockModule('enquirer', () => ({ default: { prompt: jest.fn() } })) +const { default: enquirer } = await import('enquirer') +const { publish } = await import('@pnpm/plugin-commands-publishing') -// eslint-disable-next-line -const prompt = enquirer.prompt as any +const prompt = jest.mocked(enquirer.prompt) const CREDENTIALS = [ `--registry=http://localhost:${REGISTRY_MOCK_PORT}/`, diff --git a/releasing/plugin-commands-publishing/test/pack.ts b/releasing/plugin-commands-publishing/test/pack.ts index 8f17ead678..1ab8b9f047 100644 --- a/releasing/plugin-commands-publishing/test/pack.ts +++ b/releasing/plugin-commands-publishing/test/pack.ts @@ -238,7 +238,7 @@ const modeIsExecutable = (mode: number) => (mode & 0o111) === 0o111 await pack.handler({ ...DEFAULT_OPTS, argv: { original: [] }, - dir: path.join(__dirname, '../fixtures/has-bin'), + dir: path.join(import.meta.dirname, '../fixtures/has-bin'), extraBinPaths: [], packDestination: process.cwd(), }) @@ -265,7 +265,7 @@ test('pack: should embed readme', async () => { await pack.handler({ ...DEFAULT_OPTS, argv: { original: [] }, - dir: path.join(__dirname, '../fixtures/readme'), + dir: path.join(import.meta.dirname, '../fixtures/readme'), extraBinPaths: [], packDestination: process.cwd(), embedReadme: true, @@ -273,7 +273,7 @@ test('pack: should embed readme', async () => { await tar.x({ file: 'readme-0.0.0.tgz' }) - const pkg = await import(path.resolve('package/package.json')) + const { default: pkg } = await import(path.resolve('package/package.json')) expect(pkg.readme).toBeTruthy() }) @@ -284,7 +284,7 @@ test('pack: should not embed readme', async () => { await pack.handler({ ...DEFAULT_OPTS, argv: { original: [] }, - dir: path.join(__dirname, '../fixtures/readme'), + dir: path.join(import.meta.dirname, '../fixtures/readme'), extraBinPaths: [], packDestination: process.cwd(), embedReadme: false, @@ -292,7 +292,7 @@ test('pack: should not embed readme', async () => { await tar.x({ file: 'readme-0.0.0.tgz' }) - const pkg = await import(path.resolve('package/package.json')) + const { default: pkg } = await import(path.resolve('package/package.json')) expect(pkg.readme).toBeFalsy() }) @@ -319,7 +319,7 @@ test('pack: remove publishConfig', async () => { await tar.x({ file: 'remove-publish-config-0.0.0.tgz' }) - expect((await import(path.resolve('package/package.json'))).default).toStrictEqual({ + expect((await import(path.resolve('package/package.json'))).default).toEqual({ name: 'remove-publish-config', version: '0.0.0', main: 'index.js', @@ -354,7 +354,7 @@ test('pack should read from the correct node_modules when publishing from a cust await tar.x({ file: 'custom-publish-dir-0.0.0.tgz' }) - expect((await import(path.resolve('package/package.json'))).default).toStrictEqual({ + expect((await import(path.resolve('package/package.json'))).default).toEqual({ name: 'custom-publish-dir', version: '0.0.0', dependencies: { diff --git a/releasing/plugin-commands-publishing/test/publish.ts b/releasing/plugin-commands-publishing/test/publish.ts index 648a633448..fa62423c4c 100644 --- a/releasing/plugin-commands-publishing/test/publish.ts +++ b/releasing/plugin-commands-publishing/test/publish.ts @@ -20,7 +20,7 @@ const CREDENTIALS = [ `--//localhost:${REGISTRY_MOCK_PORT}/:_password=${Buffer.from('password').toString('base64')}`, `--//localhost:${REGISTRY_MOCK_PORT}/:email=foo@bar.net`, ] -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') test('publish: package with package.json', async () => { prepare({ @@ -230,7 +230,7 @@ test('publish: package with all possible fields in publishConfig', async () => { }, []) const { default: originalManifests } = await import(path.resolve('package.json')) - expect(originalManifests).toStrictEqual({ + expect(originalManifests).toEqual({ name: 'test-publish-config', version: '1.0.0', @@ -259,7 +259,7 @@ test('publish: package with all possible fields in publishConfig', async () => { crossSpawn.sync(pnpmBin, ['add', 'test-publish-config', `--registry=http://localhost:${REGISTRY_MOCK_PORT}`]) const { default: publishedManifest } = await import(path.resolve('node_modules/test-publish-config/package.json')) - expect(publishedManifest).toStrictEqual({ + expect(publishedManifest).toEqual({ name: 'test-publish-config', version: '1.0.0', @@ -325,7 +325,7 @@ test('publish: package with publishConfig.directory', async () => { crossSpawn.sync(pnpmBin, ['add', 'publish_config_directory_dist_package', '--no-link-workspace-packages', `--registry=http://localhost:${REGISTRY_MOCK_PORT}`]) expect(JSON.parse(fs.readFileSync('node_modules/publish_config_directory_dist_package/package.json', { encoding: 'utf-8' }))) - .toStrictEqual({ + .toEqual({ name: 'publish_config_directory_dist_package', version: '1.0.0', }) @@ -504,7 +504,7 @@ test.skip('convert specs with workspace protocols to regular version ranges', as crossSpawn.sync(pnpmBin, ['add', '--store-dir=store', 'workspace-protocol-package', '--no-link-workspace-packages', `--registry=http://localhost:${REGISTRY_MOCK_PORT}`]) const { default: publishedManifest } = await import(path.resolve('node_modules/workspace-protocol-package/package.json')) - expect(publishedManifest.dependencies).toStrictEqual({ + expect(publishedManifest.dependencies).toEqual({ 'file-type': '12.0.1', 'is-negative': '1.0.0', 'is-positive': '1.0.0', @@ -514,15 +514,15 @@ test.skip('convert specs with workspace protocols to regular version ranges', as rd: 'npm:ramda@^0.1.0', 'word-wrap': '~0.1.0', }) - expect(publishedManifest.devDependencies).toStrictEqual({ + expect(publishedManifest.devDependencies).toEqual({ 'random-package': '^1.2.3', through: '^0.0.1', }) - expect(publishedManifest.optionalDependencies).toStrictEqual({ + expect(publishedManifest.optionalDependencies).toEqual({ 'lodash.deburr': '^4.1.0', ww: 'npm:wordwrap@~0.0.1', }) - expect(publishedManifest.peerDependencies).toStrictEqual({ + expect(publishedManifest.peerDependencies).toEqual({ 'random-package': '1.2.3', }) }) @@ -597,19 +597,19 @@ test.skip('convert specs with relative workspace protocols to regular version ra ]) const { default: publishedManifest } = await import(path.resolve('node_modules/relative-workspace-protocol-package/package.json')) - expect(publishedManifest.dependencies).toStrictEqual({ + expect(publishedManifest.dependencies).toEqual({ 'file-type': '12.0.1', 'is-neg': 'npm:is-negative@1.0.0', 'is-positive': '1.0.0', 'lodash.delay': '~4.1.0', }) - expect(publishedManifest.devDependencies).toStrictEqual({ + expect(publishedManifest.devDependencies).toEqual({ 'random-package': '1.2.3', }) - expect(publishedManifest.optionalDependencies).toStrictEqual({ + expect(publishedManifest.optionalDependencies).toEqual({ 'lodash.deburr': '4.1.0', }) - expect(publishedManifest.peerDependencies).toStrictEqual({ + expect(publishedManifest.peerDependencies).toEqual({ 'random-package': '1.2.3', }) }) @@ -666,10 +666,10 @@ describe('catalog protocol converted when publishing', () => { ]) const { default: publishedManifest } = await import(path.resolve(`node_modules/${testPackageName}/package.json`)) - expect(publishedManifest.dependencies).toStrictEqual({ 'is-positive': '1.0.0' }) - expect(publishedManifest.devDependencies).toStrictEqual({ 'is-positive': '1.0.0' }) - expect(publishedManifest.optionalDependencies).toStrictEqual({ 'is-positive': '1.0.0' }) - expect(publishedManifest.peerDependencies).toStrictEqual({ 'is-positive': '1.0.0' }) + expect(publishedManifest.dependencies).toEqual({ 'is-positive': '1.0.0' }) + expect(publishedManifest.devDependencies).toEqual({ 'is-positive': '1.0.0' }) + expect(publishedManifest.optionalDependencies).toEqual({ 'is-positive': '1.0.0' }) + expect(publishedManifest.peerDependencies).toEqual({ 'is-positive': '1.0.0' }) }) test('named catalog', async () => { @@ -728,10 +728,10 @@ describe('catalog protocol converted when publishing', () => { ]) const { default: publishedManifest } = await import(path.resolve(`node_modules/${testPackageName}/package.json`)) - expect(publishedManifest.dependencies).toStrictEqual({ 'is-positive': '1.0.0' }) - expect(publishedManifest.devDependencies).toStrictEqual({ 'is-positive': '1.0.0' }) - expect(publishedManifest.optionalDependencies).toStrictEqual({ 'is-positive': '1.0.0' }) - expect(publishedManifest.peerDependencies).toStrictEqual({ 'is-positive': '1.0.0' }) + expect(publishedManifest.dependencies).toEqual({ 'is-positive': '1.0.0' }) + expect(publishedManifest.devDependencies).toEqual({ 'is-positive': '1.0.0' }) + expect(publishedManifest.optionalDependencies).toEqual({ 'is-positive': '1.0.0' }) + expect(publishedManifest.peerDependencies).toEqual({ 'is-positive': '1.0.0' }) }) }) @@ -867,7 +867,7 @@ test('publish: use basic token helper for authentication', async () => { ? 'tokenHelperBasic.bat' : 'tokenHelperBasic.js' - const tokenHelper = path.join(__dirname, 'utils', file) + const tokenHelper = path.join(import.meta.dirname, 'utils', file) fs.chmodSync(tokenHelper, 0o755) @@ -895,7 +895,7 @@ test('publish: use bearer token helper for authentication', async () => { const file = os === 'win32' ? 'tokenHelperBearer.bat' : 'tokenHelperBearer.js' - const tokenHelper = path.join(__dirname, 'utils', file) + const tokenHelper = path.join(import.meta.dirname, 'utils', file) fs.chmodSync(tokenHelper, 0o755) diff --git a/releasing/plugin-commands-publishing/test/tsconfig.json b/releasing/plugin-commands-publishing/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/releasing/plugin-commands-publishing/test/tsconfig.json +++ b/releasing/plugin-commands-publishing/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/resolving/bun-resolver/package.json b/resolving/bun-resolver/package.json index 965f5507f4..0702dba8fd 100644 --- a/resolving/bun-resolver/package.json +++ b/resolving/bun-resolver/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/resolving/default-resolver/package.json b/resolving/default-resolver/package.json index d1098d8dfa..9bf6ea94aa 100644 --- a/resolving/default-resolver/package.json +++ b/resolving/default-resolver/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/resolving/default-resolver/test/tsconfig.json b/resolving/default-resolver/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/resolving/default-resolver/test/tsconfig.json +++ b/resolving/default-resolver/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/resolving/deno-resolver/package.json b/resolving/deno-resolver/package.json index 9181c48136..ac8c0d1859 100644 --- a/resolving/deno-resolver/package.json +++ b/resolving/deno-resolver/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/resolving/git-resolver/package.json b/resolving/git-resolver/package.json index cabf5a35df..198ccd4d5c 100644 --- a/resolving/git-resolver/package.json +++ b/resolving/git-resolver/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "fix": "tslint -c tslint.json src/**/*.ts test/**/*.ts --fix", diff --git a/resolving/git-resolver/test/index.ts b/resolving/git-resolver/test/index.ts index ac7d8029b3..627d083f63 100644 --- a/resolving/git-resolver/test/index.ts +++ b/resolving/git-resolver/test/index.ts @@ -1,17 +1,29 @@ /// import path from 'path' -import { createGitResolver } from '@pnpm/git-resolver' -import git from 'graceful-git' import isWindows from 'is-windows' -import { fetchWithAgent } from '@pnpm/fetch' -import { type jest } from '@jest/globals' +import { jest } from '@jest/globals' + +const { fetchWithAgent: fetchWithAgentOriginal } = await import('@pnpm/fetch') +jest.unstable_mockModule('@pnpm/fetch', () => ({ + fetchWithAgent: jest.fn(), +})) +const { default: gitOriginal } = await import('graceful-git') +jest.unstable_mockModule('graceful-git', () => ({ + default: jest.fn(), +})) +const { fetchWithAgent } = await import('@pnpm/fetch') +const { default: git } = await import('graceful-git') +const { createGitResolver } = await import('@pnpm/git-resolver') const resolveFromGit = createGitResolver({}) +beforeEach(() => { + jest.mocked(git).mockImplementation(gitOriginal) + jest.mocked(fetchWithAgent).mockImplementation(fetchWithAgentOriginal) +}) + function mockFetchAsPrivate (): void { - type FetchWithAgent = typeof fetchWithAgent - type MockedFetchWithAgent = jest.MockedFunction - (fetchWithAgent as MockedFetchWithAgent).mockImplementation(async (_url, _opts) => { + jest.mocked(fetchWithAgent).mockImplementation(async (_url, _opts) => { return { ok: false } as any // eslint-disable-line @typescript-eslint/no-explicit-any }) } @@ -437,7 +449,7 @@ test('resolveFromGit() private repo with commit hash', async () => { }) test('resolve a private repository using the HTTPS protocol without auth token', async () => { - git.mockImplementation(async (args: string[]) => { + jest.mocked(git).mockImplementation(async (args: string[]) => { expect(args).toContain('git+ssh://git@github.com/foo/bar.git') if (args.includes('--refs')) { return { @@ -463,7 +475,7 @@ test('resolve a private repository using the HTTPS protocol without auth token', }) test('resolve a private repository using the HTTPS protocol with a commit hash', async () => { - git.mockImplementation(async (args: string[]) => { + jest.mocked(git).mockImplementation(async (args: string[]) => { expect(args).toContain('ls-remote') expect(args).toContain('https://github.com/foo/bar.git') return { diff --git a/resolving/git-resolver/test/tsconfig.json b/resolving/git-resolver/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/resolving/git-resolver/test/tsconfig.json +++ b/resolving/git-resolver/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/resolving/jsr-specifier-parser/package.json b/resolving/jsr-specifier-parser/package.json index c3ffeb34e7..b4d63975c7 100644 --- a/resolving/jsr-specifier-parser/package.json +++ b/resolving/jsr-specifier-parser/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/resolving/jsr-specifier-parser/test/tsconfig.json b/resolving/jsr-specifier-parser/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/resolving/jsr-specifier-parser/test/tsconfig.json +++ b/resolving/jsr-specifier-parser/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/resolving/local-resolver/package.json b/resolving/local-resolver/package.json index f644ea339b..66272a4913 100644 --- a/resolving/local-resolver/package.json +++ b/resolving/local-resolver/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "fix": "tslint -c tslint.json src/**/*.ts test/**/*.ts --fix", diff --git a/resolving/local-resolver/test/index.ts b/resolving/local-resolver/test/index.ts index aae7bcd1e9..bb82436aa5 100644 --- a/resolving/local-resolver/test/index.ts +++ b/resolving/local-resolver/test/index.ts @@ -1,4 +1,5 @@ /// +import { createRequire } from 'module' import path from 'path' import { resolveFromLocal } from '@pnpm/local-resolver' import { type DirectoryResolution } from '@pnpm/resolver-base' @@ -6,21 +7,22 @@ import normalize from 'normalize-path' import { logger } from '@pnpm/logger' import { jest } from '@jest/globals' +const require = createRequire(import.meta.dirname) const TEST_DIR = path.dirname(require.resolve('@pnpm/tgz-fixtures/tgz/pnpm-local-resolver-0.1.1.tgz')) test('resolve directory', async () => { - const resolveResult = await resolveFromLocal({}, { bareSpecifier: '..' }, { projectDir: __dirname }) + const resolveResult = await resolveFromLocal({}, { bareSpecifier: '..' }, { projectDir: import.meta.dirname }) expect(resolveResult!.id).toBe('link:..') expect(resolveResult!.normalizedBareSpecifier).toBe('link:..') expect(resolveResult!['manifest']!.name).toBe('@pnpm/local-resolver') - expect((resolveResult!.resolution as DirectoryResolution).directory).toEqual(normalize(path.join(__dirname, '..'))) + expect((resolveResult!.resolution as DirectoryResolution).directory).toEqual(normalize(path.join(import.meta.dirname, '..'))) expect((resolveResult!.resolution as DirectoryResolution).type).toBe('directory') }) test('resolve directory specified using absolute path', async () => { - const linkedDir = path.join(__dirname, '..') + const linkedDir = path.join(import.meta.dirname, '..') const normalizedLinkedDir = normalize(linkedDir) - const resolveResult = await resolveFromLocal({}, { bareSpecifier: `link:${linkedDir}` }, { projectDir: __dirname }) + const resolveResult = await resolveFromLocal({}, { bareSpecifier: `link:${linkedDir}` }, { projectDir: import.meta.dirname }) expect(resolveResult!.id).toBe('link:..') expect(resolveResult!.normalizedBareSpecifier).toBe(`link:${normalizedLinkedDir}`) expect(resolveResult!['manifest']!.name).toBe('@pnpm/local-resolver') @@ -29,9 +31,9 @@ test('resolve directory specified using absolute path', async () => { }) test('resolve directory specified using absolute path with preserveAbsolutePaths', async () => { - const linkedDir = path.join(__dirname, '..') + const linkedDir = path.join(import.meta.dirname, '..') const normalizedLinkedDir = normalize(linkedDir) - const resolveResult = await resolveFromLocal({ preserveAbsolutePaths: true }, { bareSpecifier: `link:${linkedDir}` }, { projectDir: __dirname }) + const resolveResult = await resolveFromLocal({ preserveAbsolutePaths: true }, { bareSpecifier: `link:${linkedDir}` }, { projectDir: import.meta.dirname }) expect(resolveResult!.id).toBe(`link:${normalizedLinkedDir}`) expect(resolveResult!.normalizedBareSpecifier).toBe(`link:${normalizedLinkedDir}`) expect(resolveResult!['manifest']!.name).toBe('@pnpm/local-resolver') @@ -40,12 +42,12 @@ test('resolve directory specified using absolute path with preserveAbsolutePaths }) test('resolve directory specified using absolute path with preserveAbsolutePaths and file: scheme', async () => { - const linkedDir = path.join(__dirname, '..') + const linkedDir = path.join(import.meta.dirname, '..') const normalizedLinkedDir = normalize(linkedDir) const resolveResult = await resolveFromLocal( { preserveAbsolutePaths: true }, { bareSpecifier: `file:${linkedDir}` }, - { projectDir: __dirname } + { projectDir: import.meta.dirname } ) expect(resolveResult!.id).toBe(`file:${normalizedLinkedDir}`) expect(resolveResult!.normalizedBareSpecifier).toBe(`file:${normalizedLinkedDir}`) @@ -55,7 +57,7 @@ test('resolve directory specified using absolute path with preserveAbsolutePaths }) test('resolve injected directory', async () => { - const resolveResult = await resolveFromLocal({}, { injected: true, bareSpecifier: '..' }, { projectDir: __dirname }) + const resolveResult = await resolveFromLocal({}, { injected: true, bareSpecifier: '..' }, { projectDir: import.meta.dirname }) expect(resolveResult!.id).toBe('file:..') expect(resolveResult!.normalizedBareSpecifier).toBe('file:..') expect(resolveResult!['manifest']!.name).toBe('@pnpm/local-resolver') @@ -64,16 +66,16 @@ test('resolve injected directory', async () => { }) test('resolve workspace directory', async () => { - const resolveResult = await resolveFromLocal({}, { bareSpecifier: 'workspace:..' }, { projectDir: __dirname }) + const resolveResult = await resolveFromLocal({}, { bareSpecifier: 'workspace:..' }, { projectDir: import.meta.dirname }) expect(resolveResult!.id).toBe('link:..') expect(resolveResult!.normalizedBareSpecifier).toBe('link:..') expect(resolveResult!['manifest']!.name).toBe('@pnpm/local-resolver') - expect((resolveResult!.resolution as DirectoryResolution).directory).toEqual(normalize(path.join(__dirname, '..'))) + expect((resolveResult!.resolution as DirectoryResolution).directory).toEqual(normalize(path.join(import.meta.dirname, '..'))) expect((resolveResult!.resolution as DirectoryResolution).type).toBe('directory') }) test('resolve directory specified using the file: protocol', async () => { - const resolveResult = await resolveFromLocal({}, { bareSpecifier: 'file:..' }, { projectDir: __dirname }) + const resolveResult = await resolveFromLocal({}, { bareSpecifier: 'file:..' }, { projectDir: import.meta.dirname }) expect(resolveResult!.id).toBe('file:..') expect(resolveResult!.normalizedBareSpecifier).toBe('file:..') expect(resolveResult!['manifest']!.name).toBe('@pnpm/local-resolver') @@ -82,11 +84,11 @@ test('resolve directory specified using the file: protocol', async () => { }) test('resolve directory specified using the link: protocol', async () => { - const resolveResult = await resolveFromLocal({}, { bareSpecifier: 'link:..' }, { projectDir: __dirname }) + const resolveResult = await resolveFromLocal({}, { bareSpecifier: 'link:..' }, { projectDir: import.meta.dirname }) expect(resolveResult!.id).toBe('link:..') expect(resolveResult!.normalizedBareSpecifier).toBe('link:..') expect(resolveResult!['manifest']!.name).toBe('@pnpm/local-resolver') - expect((resolveResult!.resolution as DirectoryResolution).directory).toEqual(normalize(path.join(__dirname, '..'))) + expect((resolveResult!.resolution as DirectoryResolution).directory).toEqual(normalize(path.join(import.meta.dirname, '..'))) expect((resolveResult!.resolution as DirectoryResolution).type).toBe('directory') }) @@ -151,7 +153,7 @@ test('fail when resolving tarball specified with the link: protocol', async () = test('fail when resolving from not existing directory an injected dependency', async () => { const wantedDependency = { bareSpecifier: 'file:./dir-does-not-exist' } - const projectDir = __dirname + const projectDir = import.meta.dirname await expect( resolveFromLocal({}, wantedDependency, { projectDir }) ).rejects.toThrow(`Could not install from "${path.join(projectDir, 'dir-does-not-exist')}" as it does not exist.`) @@ -160,21 +162,21 @@ test('fail when resolving from not existing directory an injected dependency', a test('do not fail when resolving from not existing directory', async () => { jest.spyOn(logger, 'warn') const wantedDependency = { bareSpecifier: 'link:./dir-does-not-exist' } - const resolveResult = await resolveFromLocal({}, wantedDependency, { projectDir: __dirname }) + const resolveResult = await resolveFromLocal({}, wantedDependency, { projectDir: import.meta.dirname }) expect(resolveResult?.manifest).toStrictEqual({ name: 'dir-does-not-exist', version: '0.0.0', }) expect(logger.warn).toHaveBeenCalledWith({ - message: `Installing a dependency from a non-existent directory: ${path.join(__dirname, './dir-does-not-exist')}`, - prefix: __dirname, + message: `Installing a dependency from a non-existent directory: ${path.join(import.meta.dirname, './dir-does-not-exist')}`, + prefix: import.meta.dirname, }) jest.mocked(logger.warn).mockRestore() }) test('throw error when the path: protocol is used', async () => { try { - await resolveFromLocal({}, { bareSpecifier: 'path:..' }, { projectDir: __dirname }) + await resolveFromLocal({}, { bareSpecifier: 'path:..' }, { projectDir: import.meta.dirname }) fail() } catch (err: any) { // eslint-disable-line expect(err).toBeDefined() diff --git a/resolving/local-resolver/test/tsconfig.json b/resolving/local-resolver/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/resolving/local-resolver/test/tsconfig.json +++ b/resolving/local-resolver/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/resolving/npm-resolver/package.json b/resolving/npm-resolver/package.json index adf4795f1a..7938eb9d5b 100644 --- a/resolving/npm-resolver/package.json +++ b/resolving/npm-resolver/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -27,7 +27,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/resolving/npm-resolver/src/index.ts b/resolving/npm-resolver/src/index.ts index 9b236d916d..772275d970 100644 --- a/resolving/npm-resolver/src/index.ts +++ b/resolving/npm-resolver/src/index.ts @@ -23,7 +23,7 @@ import { type DependencyManifest, type Registries, type PinnedVersion } from '@p import { LRUCache } from 'lru-cache' import normalize from 'normalize-path' import pMemoize from 'p-memoize' -import clone from 'ramda/src/clone' +import { clone } from 'ramda' import semver from 'semver' import ssri from 'ssri' import versionSelectorType from 'version-selector-type' diff --git a/resolving/npm-resolver/src/parseBareSpecifier.ts b/resolving/npm-resolver/src/parseBareSpecifier.ts index c5d4d6fd7a..4c246679a2 100644 --- a/resolving/npm-resolver/src/parseBareSpecifier.ts +++ b/resolving/npm-resolver/src/parseBareSpecifier.ts @@ -38,7 +38,7 @@ export function parseBareSpecifier ( } } if (bareSpecifier.startsWith(registry)) { - const pkg = parseNpmTarballUrl(bareSpecifier) + const pkg = parseNpmTarballUrl.default(bareSpecifier) if (pkg != null) { return { fetchSpec: pkg.version, diff --git a/resolving/npm-resolver/src/pickPackage.ts b/resolving/npm-resolver/src/pickPackage.ts index d5874e0a91..188e617173 100644 --- a/resolving/npm-resolver/src/pickPackage.ts +++ b/resolving/npm-resolver/src/pickPackage.ts @@ -10,7 +10,7 @@ import getRegistryName from 'encode-registry' import loadJsonFile from 'load-json-file' import pLimit from 'p-limit' import { fastPathTemp as pathTemp } from 'path-temp' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import semver from 'semver' import renameOverwrite from 'rename-overwrite' import { toRaw } from './toRaw.js' diff --git a/resolving/npm-resolver/test/index.ts b/resolving/npm-resolver/test/index.ts index 8cb7237091..71210ddc5c 100644 --- a/resolving/npm-resolver/test/index.ts +++ b/resolving/npm-resolver/test/index.ts @@ -14,11 +14,11 @@ import { fixtures } from '@pnpm/test-fixtures' import { type Registries, type ProjectRootDir } from '@pnpm/types' import loadJsonFile from 'load-json-file' import nock from 'nock' -import omit from 'ramda/src/omit' +import { omit } from 'ramda' import tempy from 'tempy' import { delay, retryLoadJsonFile } from './utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) /* eslint-disable @typescript-eslint/no-explicit-any */ const isPositiveMeta = loadJsonFile.sync(f.find('is-positive.json')) const isPositiveMetaWithDeprecated = loadJsonFile.sync(f.find('is-positive-with-deprecated.json')) diff --git a/resolving/npm-resolver/test/publishedBy.test.ts b/resolving/npm-resolver/test/publishedBy.test.ts index f8c76cc484..c106699d21 100644 --- a/resolving/npm-resolver/test/publishedBy.test.ts +++ b/resolving/npm-resolver/test/publishedBy.test.ts @@ -9,7 +9,7 @@ import loadJsonFile from 'load-json-file' import nock from 'nock' import tempy from 'tempy' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const registries: Registries = { default: 'https://registry.npmjs.org/', diff --git a/resolving/npm-resolver/test/resolveJsr.test.ts b/resolving/npm-resolver/test/resolveJsr.test.ts index cae7c2d591..2ccf7cac1a 100644 --- a/resolving/npm-resolver/test/resolveJsr.test.ts +++ b/resolving/npm-resolver/test/resolveJsr.test.ts @@ -9,7 +9,7 @@ import nock from 'nock' import tempy from 'tempy' import { retryLoadJsonFile } from './utils/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) /* eslint-disable @typescript-eslint/no-explicit-any */ const jsrRusGreetMeta = loadJsonFile.sync(f.find('jsr-rus-greet.json')) const jsrLucaCasesMeta = loadJsonFile.sync(f.find('jsr-luca-cases.json')) diff --git a/resolving/npm-resolver/test/tsconfig.json b/resolving/npm-resolver/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/resolving/npm-resolver/test/tsconfig.json +++ b/resolving/npm-resolver/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/resolving/resolver-base/package.json b/resolving/resolver-base/package.json index d02a2c1522..8a68195177 100644 --- a/resolving/resolver-base/package.json +++ b/resolving/resolver-base/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/resolving/tarball-resolver/package.json b/resolving/tarball-resolver/package.json index ce15b34bff..d5d8eb2138 100644 --- a/resolving/tarball-resolver/package.json +++ b/resolving/tarball-resolver/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "fix": "tslint -c tslint.json src/**/*.ts test/**/*.ts --fix", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/resolving/tarball-resolver/test/tsconfig.json b/resolving/tarball-resolver/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/resolving/tarball-resolver/test/tsconfig.json +++ b/resolving/tarball-resolver/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/reviewing/dependencies-hierarchy/example/index.js b/reviewing/dependencies-hierarchy/example/index.js index 9dccb1fb78..ddf43c0718 100644 --- a/reviewing/dependencies-hierarchy/example/index.js +++ b/reviewing/dependencies-hierarchy/example/index.js @@ -1,7 +1,7 @@ 'use strict' const hierarchyForPackages = require('dependencies-hierarchy').forPackages -hierarchyForPackages(['graceful-fs', {name: 'pify', range: '2'}], __dirname, {depth: 2}) +hierarchyForPackages(['graceful-fs', {name: 'pify', range: '2'}], import.meta.dirname, {depth: 2}) .then(tree => { console.log(JSON.stringify(tree, null, 2)) }) diff --git a/reviewing/dependencies-hierarchy/package.json b/reviewing/dependencies-hierarchy/package.json index 66dcf240a3..20a72b8116 100644 --- a/reviewing/dependencies-hierarchy/package.json +++ b/reviewing/dependencies-hierarchy/package.json @@ -16,7 +16,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/reviewing/dependencies-hierarchy/test/index.ts b/reviewing/dependencies-hierarchy/test/index.ts index 04954a10c4..c7bdadb22d 100644 --- a/reviewing/dependencies-hierarchy/test/index.ts +++ b/reviewing/dependencies-hierarchy/test/index.ts @@ -1,4 +1,5 @@ /// +import fs from 'fs' import path from 'path' import { WANTED_LOCKFILE } from '@pnpm/constants' import { fixtures } from '@pnpm/test-fixtures' @@ -6,7 +7,7 @@ import { buildDependenciesHierarchy, type PackageNode } from '@pnpm/reviewing.de import { depPathToFilename } from '@pnpm/dependency-path' const virtualStoreDirMaxLength = process.platform === 'win32' ? 60 : 120 -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const generalFixture = f.find('general') const withPeerFixture = f.find('with-peer') const circularFixture = f.find('circular') @@ -14,7 +15,7 @@ const withFileDepFixture = f.find('with-file-dep') const withNonPackageDepFixture = f.find('with-non-package-dep') const withLinksOnlyFixture = f.find('fixtureWithLinks/with-links-only') const withUnsavedDepsFixture = f.find('with-unsaved-deps') -const fixtureMonorepo = path.join(__dirname, '..', 'fixtureMonorepo') +const fixtureMonorepo = path.join(import.meta.dirname, '..', 'fixtureMonorepo') const withAliasedDepFixture = f.find('with-aliased-dep') const workspaceWithNestedWorkspaceDeps = f.find('workspace-with-nested-workspace-deps') const customModulesDirFixture = f.find('custom-modules-dir') @@ -311,7 +312,7 @@ test('circular dependency', async () => { expect(tree).toStrictEqual({ [circularFixture]: { - dependencies: require('./circularTree.json') // eslint-disable-line + dependencies: JSON.parse(fs.readFileSync(path.join(import.meta.dirname, 'circularTree.json'), 'utf8')) .dependencies .map((dep: PackageNode) => resolvePaths(modulesDir, dep)), devDependencies: [], diff --git a/reviewing/dependencies-hierarchy/test/tsconfig.json b/reviewing/dependencies-hierarchy/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/reviewing/dependencies-hierarchy/test/tsconfig.json +++ b/reviewing/dependencies-hierarchy/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/reviewing/license-scanner/package.json b/reviewing/license-scanner/package.json index 396c99be6c..9e9d803dc6 100644 --- a/reviewing/license-scanner/package.json +++ b/reviewing/license-scanner/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "compile": "tsc --build && pnpm run lint --fix" }, "dependencies": { diff --git a/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts b/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts index 9f69a6af55..1503f3975e 100644 --- a/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts +++ b/reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts @@ -7,8 +7,8 @@ import { } from '@pnpm/lockfile.walker' import { type DepTypes, DepType, detectDepTypes } from '@pnpm/lockfile.detect-dep-types' import { type SupportedArchitectures, type DependenciesField, type ProjectId, type Registries } from '@pnpm/types' +import { map as mapValues } from 'ramda' import { getPkgInfo } from './getPkgInfo.js' -import mapValues from 'ramda/src/map' export interface LicenseNode { name?: string diff --git a/reviewing/license-scanner/test/licenses.spec.ts b/reviewing/license-scanner/test/licenses.spec.ts index 024ab01241..dd20cb76b3 100644 --- a/reviewing/license-scanner/test/licenses.spec.ts +++ b/reviewing/license-scanner/test/licenses.spec.ts @@ -1,4 +1,3 @@ -import { findDependencyLicenses } from '@pnpm/license-scanner' import { LOCKFILE_VERSION } from '@pnpm/constants' import { type DepPath, type ProjectManifest, type Registries, type ProjectId } from '@pnpm/types' import { type LockfileObject } from '@pnpm/lockfile.fs' @@ -6,8 +5,8 @@ import { jest } from '@jest/globals' import { type LicensePackage } from '../lib/licenses.js' import { type GetPackageInfoOptions, type PackageInfo } from '../lib/getPkgInfo.js' -jest.mock('../lib/getPkgInfo', () => { - const actualModule = jest.requireActual('../lib/getPkgInfo') +const actualModule = await import('../lib/getPkgInfo.js') +jest.unstable_mockModule('../lib/getPkgInfo.js', () => { return { ...actualModule, getPkgInfo: async (pkg: PackageInfo, _opts: GetPackageInfoOptions): Promise< @@ -34,6 +33,8 @@ jest.mock('../lib/getPkgInfo', () => { } }) +const { findDependencyLicenses } = await import('@pnpm/license-scanner') + describe('licences', () => { test('findDependencyLicenses()', async () => { const lockfile: LockfileObject = { diff --git a/reviewing/license-scanner/test/tsconfig.json b/reviewing/license-scanner/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/reviewing/license-scanner/test/tsconfig.json +++ b/reviewing/license-scanner/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/reviewing/list/example/index.js b/reviewing/list/example/index.js index 5ac1abb4aa..a5c994cebe 100644 --- a/reviewing/list/example/index.js +++ b/reviewing/list/example/index.js @@ -1,7 +1,7 @@ 'use strict' const pnpmList = require('../lib').default -pnpmList(__dirname, {depth: 2}) +pnpmList(import.meta.dirname, {depth: 2}) .then(output => { console.log(output) }) diff --git a/reviewing/list/package.json b/reviewing/list/package.json index c02cc089d1..5cba02904e 100644 --- a/reviewing/list/package.json +++ b/reviewing/list/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -31,7 +31,7 @@ "prepareFixtures": "cd test && node ../../pnpm recursive install --no-link-workspace-packages --no-shared-workspace-lockfile -f && cd ..", "prepublishOnly": "pnpm run compile", "pretest": "pnpm run --filter dependencies-hierarchy pretest", - "_test": "pnpm pretest && jest", + "_test": "pnpm pretest && cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "compile": "tsc --build && pnpm run lint --fix" }, diff --git a/reviewing/list/src/renderJson.ts b/reviewing/list/src/renderJson.ts index 06bc56d9ba..7a6f0998af 100644 --- a/reviewing/list/src/renderJson.ts +++ b/reviewing/list/src/renderJson.ts @@ -1,8 +1,6 @@ import { DEPENDENCIES_FIELDS } from '@pnpm/types' import { type PackageNode } from '@pnpm/reviewing.dependencies-hierarchy' -import sortBy from 'ramda/src/sortBy' -import path from 'ramda/src/path' -import { type Ord } from 'ramda' +import { sortBy, path, type Ord } from 'ramda' import { getPkgInfo, type PkgInfo } from './getPkgInfo.js' import { type PackageDependencyHierarchy } from './types.js' diff --git a/reviewing/list/src/renderParseable.ts b/reviewing/list/src/renderParseable.ts index 8234d7652c..e5bda21653 100644 --- a/reviewing/list/src/renderParseable.ts +++ b/reviewing/list/src/renderParseable.ts @@ -1,6 +1,5 @@ import { type PackageNode } from '@pnpm/reviewing.dependencies-hierarchy' -import sortBy from 'ramda/src/sortBy' -import prop from 'ramda/src/prop' +import { sortBy, prop } from 'ramda' import { type PackageDependencyHierarchy } from './types.js' const sortPackages = sortBy(prop('name')) diff --git a/reviewing/list/src/renderTree.ts b/reviewing/list/src/renderTree.ts index ccec55c245..b55b0aa74f 100644 --- a/reviewing/list/src/renderTree.ts +++ b/reviewing/list/src/renderTree.ts @@ -4,8 +4,7 @@ import { DEPENDENCIES_FIELDS, type DependenciesField } from '@pnpm/types' import archy from 'archy' import chalk from 'chalk' import cliColumns from 'cli-columns' -import sortBy from 'ramda/src/sortBy' -import ramdaPath from 'ramda/src/path' +import { sortBy, path as ramdaPath } from 'ramda' import { type Ord } from 'ramda' import { getPkgInfo } from './getPkgInfo.js' import { type PackageDependencyHierarchy } from './types.js' diff --git a/reviewing/list/test/index.ts b/reviewing/list/test/index.ts index ee89aa8f7f..9e171ea4d6 100644 --- a/reviewing/list/test/index.ts +++ b/reviewing/list/test/index.ts @@ -21,7 +21,7 @@ const UNSAVED_DEPENDENCIES = chalk.cyanBright('not saved (you should add these d const highlighted = chalk.bold const boldHighlighted = highlighted.underline -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const fixture = f.find('fixture') const fixtureWithNoPkgNameAndNoVersion = f.find('fixture-with-no-pkg-name-and-no-version') const fixtureWithNoPkgVersion = f.find('fixture-with-no-pkg-version') diff --git a/reviewing/list/test/tsconfig.json b/reviewing/list/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/reviewing/list/test/tsconfig.json +++ b/reviewing/list/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/reviewing/outdated/package.json b/reviewing/outdated/package.json index 9ab189ab52..33a2be4e70 100644 --- a/reviewing/outdated/package.json +++ b/reviewing/outdated/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "compile": "tsc --build && pnpm run lint --fix" }, "dependencies": { diff --git a/reviewing/outdated/src/outdatedDepsOfProjects.ts b/reviewing/outdated/src/outdatedDepsOfProjects.ts index e84f6df132..731a2e242b 100644 --- a/reviewing/outdated/src/outdatedDepsOfProjects.ts +++ b/reviewing/outdated/src/outdatedDepsOfProjects.ts @@ -10,7 +10,7 @@ import { type ProjectManifest, type ProjectRootDir, } from '@pnpm/types' -import unnest from 'ramda/src/unnest' +import { unnest } from 'ramda' import { createManifestGetter, type ManifestGetterOptions } from './createManifestGetter.js' import { outdated, type OutdatedPackage } from './outdated.js' diff --git a/reviewing/outdated/test/tsconfig.json b/reviewing/outdated/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/reviewing/outdated/test/tsconfig.json +++ b/reviewing/outdated/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/reviewing/plugin-commands-licenses/package.json b/reviewing/plugin-commands-licenses/package.json index 4212a3c7a0..f6c75919d8 100644 --- a/reviewing/plugin-commands-licenses/package.json +++ b/reviewing/plugin-commands-licenses/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/reviewing/plugin-commands-licenses/src/licenses.ts b/reviewing/plugin-commands-licenses/src/licenses.ts index 200e74df9d..4c7544dda1 100644 --- a/reviewing/plugin-commands-licenses/src/licenses.ts +++ b/reviewing/plugin-commands-licenses/src/licenses.ts @@ -6,7 +6,7 @@ import { type CompletionFunc } from '@pnpm/command' import { FILTERING } from '@pnpm/common-cli-options-help' import { types as allTypes } from '@pnpm/config' import { PnpmError } from '@pnpm/error' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { type LicensesCommandResult } from './LicensesCommandResult.js' import { licensesList, type LicensesCommandOptions } from './licensesList.js' diff --git a/reviewing/plugin-commands-licenses/test/index.ts b/reviewing/plugin-commands-licenses/test/index.ts index bad95352f0..f9532517bf 100644 --- a/reviewing/plugin-commands-licenses/test/index.ts +++ b/reviewing/plugin-commands-licenses/test/index.ts @@ -10,7 +10,7 @@ import { stripVTControlCharacters as stripAnsi } from 'util' import { DEFAULT_OPTS } from './utils/index.js' import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) test('pnpm licenses', async () => { const workspaceDir = tempDir() diff --git a/reviewing/plugin-commands-licenses/test/tsconfig.json b/reviewing/plugin-commands-licenses/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/reviewing/plugin-commands-licenses/test/tsconfig.json +++ b/reviewing/plugin-commands-licenses/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/reviewing/plugin-commands-listing/package.json b/reviewing/plugin-commands-listing/package.json index b4efcbfad7..734da0ccdc 100644 --- a/reviewing/plugin-commands-listing/package.json +++ b/reviewing/plugin-commands-listing/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/reviewing/plugin-commands-listing/src/list.ts b/reviewing/plugin-commands-listing/src/list.ts index 0453a11b59..ef4b900240 100644 --- a/reviewing/plugin-commands-listing/src/list.ts +++ b/reviewing/plugin-commands-listing/src/list.ts @@ -3,7 +3,7 @@ import { FILTERING, OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options- import { type Config, types as allTypes } from '@pnpm/config' import { list, listForPackages } from '@pnpm/list' import { type IncludedDependencies } from '@pnpm/types' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { listRecursive } from './recursive.js' diff --git a/reviewing/plugin-commands-listing/src/ll.ts b/reviewing/plugin-commands-listing/src/ll.ts index 1a6da05b4f..d0a6d1f91e 100644 --- a/reviewing/plugin-commands-listing/src/ll.ts +++ b/reviewing/plugin-commands-listing/src/ll.ts @@ -1,4 +1,4 @@ -import omit from 'ramda/src/omit' +import { omit } from 'ramda' import * as list from './list.js' export const commandNames = ['ll', 'la'] diff --git a/reviewing/plugin-commands-listing/src/why.ts b/reviewing/plugin-commands-listing/src/why.ts index 8cdd377493..e6db08f86a 100644 --- a/reviewing/plugin-commands-listing/src/why.ts +++ b/reviewing/plugin-commands-listing/src/why.ts @@ -2,7 +2,7 @@ import { docsUrl } from '@pnpm/cli-utils' import { FILTERING, OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help' import { types as allTypes } from '@pnpm/config' import { PnpmError } from '@pnpm/error' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { handler as list, type ListCommandOptions, EXCLUDE_PEERS_HELP } from './list.js' diff --git a/reviewing/plugin-commands-listing/test/index.ts b/reviewing/plugin-commands-listing/test/index.ts index d528ab0c31..fabf9d7ea9 100644 --- a/reviewing/plugin-commands-listing/test/index.ts +++ b/reviewing/plugin-commands-listing/test/index.ts @@ -9,7 +9,7 @@ import execa from 'execa' import { stripVTControlCharacters as stripAnsi } from 'util' import { sync as writeYamlFile } from 'write-yaml-file' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') test('listing packages', async () => { prepare({ diff --git a/reviewing/plugin-commands-listing/test/tsconfig.json b/reviewing/plugin-commands-listing/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/reviewing/plugin-commands-listing/test/tsconfig.json +++ b/reviewing/plugin-commands-listing/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/reviewing/plugin-commands-listing/test/why.ts b/reviewing/plugin-commands-listing/test/why.ts index 03b9a9f497..2f12931ae0 100644 --- a/reviewing/plugin-commands-listing/test/why.ts +++ b/reviewing/plugin-commands-listing/test/why.ts @@ -6,7 +6,7 @@ import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import execa from 'execa' import { stripVTControlCharacters as stripAnsi } from 'util' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') test('`pnpm why` should fail if no package name was provided', async () => { prepare() diff --git a/reviewing/plugin-commands-outdated/package.json b/reviewing/plugin-commands-outdated/package.json index 1e56f967ed..1100c2531d 100644 --- a/reviewing/plugin-commands-outdated/package.json +++ b/reviewing/plugin-commands-outdated/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/reviewing/plugin-commands-outdated/src/outdated.ts b/reviewing/plugin-commands-outdated/src/outdated.ts index ada821e354..30f93a31ca 100644 --- a/reviewing/plugin-commands-outdated/src/outdated.ts +++ b/reviewing/plugin-commands-outdated/src/outdated.ts @@ -17,8 +17,7 @@ import semverDiff from '@pnpm/semver-diff' import { type DependenciesField, type PackageManifest, type ProjectRootDir } from '@pnpm/types' import { table } from '@zkochan/table' import chalk from 'chalk' -import pick from 'ramda/src/pick' -import sortWith from 'ramda/src/sortWith' +import { pick, sortWith } from 'ramda' import renderHelp from 'render-help' import { stripVTControlCharacters as stripAnsi } from 'util' import { @@ -348,7 +347,7 @@ export function toOutdatedWithVersionDiff (outdated if (outdated.latestManifest != null) { return { ...outdated, - ...semverDiff(outdated.wanted, outdated.latestManifest.version), + ...semverDiff.default(outdated.wanted, outdated.latestManifest.version), } } return { @@ -380,7 +379,7 @@ export function renderLatest (outdatedPkg: OutdatedWithVersionDiff): string { : latestManifest.version } - return colorizeSemverDiff({ change, diff }) + return colorizeSemverDiff.default({ change, diff }) } export function renderDetails ({ latestManifest }: OutdatedPackage): string { diff --git a/reviewing/plugin-commands-outdated/src/recursive.ts b/reviewing/plugin-commands-outdated/src/recursive.ts index 9731cade19..11b627b47d 100644 --- a/reviewing/plugin-commands-outdated/src/recursive.ts +++ b/reviewing/plugin-commands-outdated/src/recursive.ts @@ -12,8 +12,7 @@ import { } from '@pnpm/types' import { table } from '@zkochan/table' import chalk from 'chalk' -import isEmpty from 'ramda/src/isEmpty' -import sortWith from 'ramda/src/sortWith' +import { isEmpty, sortWith } from 'ramda' import { getCellWidth, type OutdatedCommandOptions, diff --git a/reviewing/plugin-commands-outdated/test/index.ts b/reviewing/plugin-commands-outdated/test/index.ts index d6b930e3b1..bd63b7ce6a 100644 --- a/reviewing/plugin-commands-outdated/test/index.ts +++ b/reviewing/plugin-commands-outdated/test/index.ts @@ -9,7 +9,7 @@ import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import { fixtures } from '@pnpm/test-fixtures' import { stripVTControlCharacters as stripAnsi } from 'util' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) const hasOutdatedDepsFixture = f.find('has-outdated-deps') const has2OutdatedDepsFixture = f.find('has-2-outdated-deps') const hasOutdatedDepsFixtureAndExternalLockfile = path.join(f.find('has-outdated-deps-and-external-shrinkwrap'), 'pkg') diff --git a/reviewing/plugin-commands-outdated/test/tsconfig.json b/reviewing/plugin-commands-outdated/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/reviewing/plugin-commands-outdated/test/tsconfig.json +++ b/reviewing/plugin-commands-outdated/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/semver/peer-range/package.json b/semver/peer-range/package.json index 593eac8eef..d0c22bab98 100644 --- a/semver/peer-range/package.json +++ b/semver/peer-range/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/store/cafs-types/package.json b/store/cafs-types/package.json index febcff2951..2e992dd978 100644 --- a/store/cafs-types/package.json +++ b/store/cafs-types/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/store/cafs/package.json b/store/cafs/package.json index 65e572b43d..f756f71594 100644 --- a/store/cafs/package.json +++ b/store/cafs/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "compile": "tsc --build && pnpm run lint --fix", "prepublishOnly": "pnpm run compile" diff --git a/store/cafs/test/index.ts b/store/cafs/test/index.ts index e3b4755b14..15cfc608b6 100644 --- a/store/cafs/test/index.ts +++ b/store/cafs/test/index.ts @@ -9,7 +9,7 @@ import { getFilePathByModeInCafs, } from '../src/index.js' -const f = fixtures(__dirname) +const f = fixtures(import.meta.dirname) describe('cafs', () => { it('unpack', () => { @@ -28,7 +28,7 @@ describe('cafs', () => { it('replaces an already existing file, if the integrity of it was broken', () => { const storeDir = tempy.directory() - const srcDir = path.join(__dirname, 'fixtures/one-file') + const srcDir = path.join(import.meta.dirname, 'fixtures/one-file') const addFiles = () => createCafs(storeDir).addFilesFromDir(srcDir) let addFilesResult = addFiles() @@ -44,7 +44,7 @@ describe('cafs', () => { it('ignores broken symlinks when traversing subdirectories', () => { const storeDir = tempy.directory() - const srcDir = path.join(__dirname, 'fixtures/broken-symlink') + const srcDir = path.join(import.meta.dirname, 'fixtures/broken-symlink') const addFiles = () => createCafs(storeDir).addFilesFromDir(srcDir) const { filesIndex } = addFiles() diff --git a/store/cafs/test/tsconfig.json b/store/cafs/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/store/cafs/test/tsconfig.json +++ b/store/cafs/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/store/create-cafs-store/package.json b/store/create-cafs-store/package.json index 30797a0dc9..512d52298f 100644 --- a/store/create-cafs-store/package.json +++ b/store/create-cafs-store/package.json @@ -20,7 +20,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/store/create-cafs-store/src/index.ts b/store/create-cafs-store/src/index.ts index c1356333bc..520b3fe4eb 100644 --- a/store/create-cafs-store/src/index.ts +++ b/store/create-cafs-store/src/index.ts @@ -15,7 +15,7 @@ import { } from '@pnpm/store-controller-types' import memoize from 'mem' import pathTemp from 'path-temp' -import mapValues from 'ramda/src/map' +import { map as mapValues } from 'ramda' export { type CafsLocker } diff --git a/store/package-store/package.json b/store/package-store/package.json index 8b11436648..cd5d4f42bf 100644 --- a/store/package-store/package.json +++ b/store/package-store/package.json @@ -20,7 +20,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -38,7 +38,7 @@ "fix": "tslint -c tslint.json src/**/*.ts test/**/*.ts --fix", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "pretest": "rimraf .tmp", - "_test": "pnpm pretest && jest", + "_test": "pnpm pretest && cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/store/package-store/test/tsconfig.json b/store/package-store/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/store/package-store/test/tsconfig.json +++ b/store/package-store/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/store/plugin-commands-server/package.json b/store/plugin-commands-server/package.json index 55471bdecf..db47a2a0ad 100644 --- a/store/plugin-commands-server/package.json +++ b/store/plugin-commands-server/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/store/plugin-commands-server/src/server.ts b/store/plugin-commands-server/src/server.ts index 73b2499c34..dd48557a64 100644 --- a/store/plugin-commands-server/src/server.ts +++ b/store/plugin-commands-server/src/server.ts @@ -3,7 +3,7 @@ import { OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help' import { types as allTypes } from '@pnpm/config' import { PnpmError } from '@pnpm/error' import { type CreateStoreControllerOptions } from '@pnpm/store-connection-manager' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { start } from './start.js' import { status } from './status.js' diff --git a/store/plugin-commands-store-inspecting/package.json b/store/plugin-commands-store-inspecting/package.json index 6aec79d802..6af21b5d1c 100644 --- a/store/plugin-commands-store-inspecting/package.json +++ b/store/plugin-commands-store-inspecting/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/store/plugin-commands-store-inspecting/test/catFile.ts b/store/plugin-commands-store-inspecting/test/catFile.ts index 5a2922449b..29f26d1da6 100644 --- a/store/plugin-commands-store-inspecting/test/catFile.ts +++ b/store/plugin-commands-store-inspecting/test/catFile.ts @@ -8,7 +8,7 @@ import { type PnpmError } from '@pnpm/error' import execa from 'execa' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') // cat-file test('print hash file content', async () => { diff --git a/store/plugin-commands-store-inspecting/test/catIndex.ts b/store/plugin-commands-store-inspecting/test/catIndex.ts index 2378150802..2375f8288b 100644 --- a/store/plugin-commands-store-inspecting/test/catIndex.ts +++ b/store/plugin-commands-store-inspecting/test/catIndex.ts @@ -8,7 +8,7 @@ import { type PnpmError } from '@pnpm/error' import execa from 'execa' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') // cat-index test('print cat index file content', async () => { @@ -52,4 +52,4 @@ test('prints index file error', async () => { expect(err.code).toBe('ERR_PNPM_INVALID_PACKAGE') expect(err.message).toBe('No corresponding index file found. You can use pnpm list to see if the package is installed.') -}) \ No newline at end of file +}) diff --git a/store/plugin-commands-store-inspecting/test/findHash.ts b/store/plugin-commands-store-inspecting/test/findHash.ts index 54361b1097..17a7b58d1a 100644 --- a/store/plugin-commands-store-inspecting/test/findHash.ts +++ b/store/plugin-commands-store-inspecting/test/findHash.ts @@ -9,7 +9,7 @@ import { type PnpmError } from '@pnpm/error' import execa from 'execa' import tempy from 'tempy' -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') test('print index file path with hash', async () => { const { PACKAGE_INFO_CLR, INDEX_PATH_CLR } = findHash diff --git a/store/plugin-commands-store-inspecting/test/tsconfig.json b/store/plugin-commands-store-inspecting/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/store/plugin-commands-store-inspecting/test/tsconfig.json +++ b/store/plugin-commands-store-inspecting/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/store/plugin-commands-store/package.json b/store/plugin-commands-store/package.json index 2934a49a08..ca27b0bbff 100644 --- a/store/plugin-commands-store/package.json +++ b/store/plugin-commands-store/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/store/plugin-commands-store/src/cleanExpiredDlxCache.test.ts b/store/plugin-commands-store/src/cleanExpiredDlxCache.test.ts index 5acf90dae4..221f28d5b8 100644 --- a/store/plugin-commands-store/src/cleanExpiredDlxCache.test.ts +++ b/store/plugin-commands-store/src/cleanExpiredDlxCache.test.ts @@ -1,9 +1,28 @@ -import fs from 'fs' import path from 'path' -import { dlx } from '@pnpm/plugin-commands-script-runners' import { prepareEmpty } from '@pnpm/prepare' import { jest } from '@jest/globals' -import { cleanExpiredDlxCache, cleanOrphans } from './cleanExpiredDlxCache.js' + +const fsOriginal = await import('fs') +jest.unstable_mockModule('fs', () => ({ + ...fsOriginal, + readdirSync: jest.fn(fsOriginal.readdirSync), + promises: { + ...fsOriginal.promises, + readdir: jest.fn(fsOriginal.promises.readdir), + lstat: jest.fn(fsOriginal.promises.lstat), + rm: jest.fn(fsOriginal.promises.rm), + }, +})) +const fs = await import('fs') +const { cleanExpiredDlxCache, cleanOrphans } = await import('./cleanExpiredDlxCache.js') +const { dlx } = await import('@pnpm/plugin-commands-script-runners') + +beforeEach(() => { + jest.mocked(fs.readdirSync).mockClear() + jest.mocked(fs.promises.readdir).mockClear() + jest.mocked(fs.promises.lstat).mockClear() + jest.mocked(fs.promises.rm).mockClear() +}) const createCacheKey = (...packages: string[]): string => dlx.createCacheKey({ packages, @@ -11,11 +30,11 @@ const createCacheKey = (...packages: string[]): string => dlx.createCacheKey({ }) function createSampleDlxCacheLinkTarget (dirPath: string): void { - fs.mkdirSync(path.join(dirPath, 'node_modules', '.pnpm'), { recursive: true }) - fs.mkdirSync(path.join(dirPath, 'node_modules', '.bin'), { recursive: true }) - fs.writeFileSync(path.join(dirPath, 'node_modules', '.modules.yaml'), '') - fs.writeFileSync(path.join(dirPath, 'package.json'), '') - fs.writeFileSync(path.join(dirPath, 'pnpm-lock.yaml'), '') + fsOriginal.mkdirSync(path.join(dirPath, 'node_modules', '.pnpm'), { recursive: true }) + fsOriginal.mkdirSync(path.join(dirPath, 'node_modules', '.bin'), { recursive: true }) + fsOriginal.writeFileSync(path.join(dirPath, 'node_modules', '.modules.yaml'), '') + fsOriginal.writeFileSync(path.join(dirPath, 'package.json'), '') + fsOriginal.writeFileSync(path.join(dirPath, 'pnpm-lock.yaml'), '') } function createSampleDlxCacheItem (cacheDir: string, cmd: string, now: Date, age: number): void { @@ -27,8 +46,8 @@ function createSampleDlxCacheItem (cacheDir: string, cmd: string, now: Date, age const linkTarget = path.join(cacheDir, 'dlx', hash, targetName) const linkPath = path.join(cacheDir, 'dlx', hash, 'pkg') createSampleDlxCacheLinkTarget(linkTarget) - fs.symlinkSync(linkTarget, linkPath, 'junction') - fs.lutimesSync(linkPath, newDate, newDate) + fsOriginal.symlinkSync(linkTarget, linkPath, 'junction') + fsOriginal.lutimesSync(linkPath, newDate, newDate) } function createSampleDlxCacheFsTree (cacheDir: string, now: Date, ageTable: Record): void { @@ -37,10 +56,6 @@ function createSampleDlxCacheFsTree (cacheDir: string, now: Date, ageTable: Reco } } -afterEach(() => { - jest.restoreAllMocks() -}) - test('cleanExpiredCache removes items that outlive dlxCacheMaxAge', async () => { prepareEmpty() @@ -54,40 +69,32 @@ test('cleanExpiredCache removes items that outlive dlxCacheMaxAge', async () => baz: 20, }) - const readdirSyncSpy = jest.spyOn(fs, 'readdirSync') - const lstatSpy = jest.spyOn(fs.promises, 'lstat') - const rmSpy = jest.spyOn(fs.promises, 'rm') - await cleanExpiredDlxCache({ cacheDir, dlxCacheMaxAge, now, }) - expect(fs.readdirSync(path.join(cacheDir, 'dlx', createCacheKey('foo')))).toHaveLength(2) - expect(fs.readdirSync(path.join(cacheDir, 'dlx', createCacheKey('bar')))).toHaveLength(2) - expect(fs.existsSync(path.join(cacheDir, 'dlx', createCacheKey('baz')))).toBeFalsy() + expect(fsOriginal.readdirSync(path.join(cacheDir, 'dlx', createCacheKey('foo')))).toHaveLength(2) + expect(fsOriginal.readdirSync(path.join(cacheDir, 'dlx', createCacheKey('bar')))).toHaveLength(2) + expect(fsOriginal.existsSync(path.join(cacheDir, 'dlx', createCacheKey('baz')))).toBeFalsy() - expect(readdirSyncSpy).toHaveBeenCalledWith(path.join(cacheDir, 'dlx'), expect.anything()) + expect(fs.readdirSync).toHaveBeenCalledWith(path.join(cacheDir, 'dlx'), expect.anything()) for (const key of ['foo', 'bar', 'baz']) { - expect(lstatSpy).toHaveBeenCalledWith(path.join(cacheDir, 'dlx', createCacheKey(key), 'pkg')) + expect(fs.promises.lstat).toHaveBeenCalledWith(path.join(cacheDir, 'dlx', createCacheKey(key), 'pkg')) } - expect(rmSpy).not.toHaveBeenCalledWith( + expect(fs.promises.rm).not.toHaveBeenCalledWith( expect.stringContaining(path.join(cacheDir, 'dlx', createCacheKey('foo'))), expect.anything() ) - expect(rmSpy).not.toHaveBeenCalledWith( + expect(fs.promises.rm).not.toHaveBeenCalledWith( expect.stringContaining(path.join(cacheDir, 'dlx', createCacheKey('bar'))), expect.anything() ) - expect(rmSpy).toHaveBeenCalledWith( + expect(fs.promises.rm).toHaveBeenCalledWith( expect.stringContaining(path.join(cacheDir, 'dlx', createCacheKey('baz'))), { recursive: true, force: true } ) - - readdirSyncSpy.mockRestore() - lstatSpy.mockRestore() - rmSpy.mockRestore() }) test('cleanExpiredCache removes all directories without checking stat if dlxCacheMaxAge is 0', async () => { @@ -103,10 +110,6 @@ test('cleanExpiredCache removes all directories without checking stat if dlxCach baz: 20, }) - const readdirSyncSpy = jest.spyOn(fs, 'readdirSync') - const lstatSpy = jest.spyOn(fs.promises, 'lstat') - const rmSpy = jest.spyOn(fs.promises, 'rm') - await cleanExpiredDlxCache({ cacheDir, dlxCacheMaxAge, @@ -118,15 +121,11 @@ test('cleanExpiredCache removes all directories without checking stat if dlxCach .sort() ).toStrictEqual([]) - expect(readdirSyncSpy).toHaveBeenCalledWith(path.join(cacheDir, 'dlx'), expect.anything()) - expect(lstatSpy).not.toHaveBeenCalled() + expect(fs.readdirSync).toHaveBeenCalledWith(path.join(cacheDir, 'dlx'), expect.anything()) + expect(fs.promises.lstat).not.toHaveBeenCalled() for (const key of ['foo', 'bar', 'baz']) { - expect(rmSpy).toHaveBeenCalledWith(path.join(cacheDir, 'dlx', createCacheKey(key)), { recursive: true, force: true }) + expect(fs.promises.rm).toHaveBeenCalledWith(path.join(cacheDir, 'dlx', createCacheKey(key)), { recursive: true, force: true }) } - - readdirSyncSpy.mockRestore() - lstatSpy.mockRestore() - rmSpy.mockRestore() }) test('cleanExpiredCache does nothing if dlxCacheMaxAge is Infinity', async () => { @@ -142,10 +141,6 @@ test('cleanExpiredCache does nothing if dlxCacheMaxAge is Infinity', async () => baz: 20, }) - const readdirSpy = jest.spyOn(fs.promises, 'readdir') - const lstatSpy = jest.spyOn(fs.promises, 'lstat') - const rmSpy = jest.spyOn(fs.promises, 'rm') - await cleanExpiredDlxCache({ cacheDir, dlxCacheMaxAge, @@ -165,13 +160,9 @@ test('cleanExpiredCache does nothing if dlxCacheMaxAge is Infinity', async () => expect(fs.readdirSync(path.join(dlxCacheDir, entry))).toHaveLength(2) } - expect(readdirSpy).not.toHaveBeenCalled() - expect(lstatSpy).not.toHaveBeenCalled() - expect(rmSpy).not.toHaveBeenCalled() - - readdirSpy.mockRestore() - lstatSpy.mockRestore() - rmSpy.mockRestore() + expect(fs.promises.readdir).not.toHaveBeenCalled() + expect(fs.promises.lstat).not.toHaveBeenCalled() + expect(fs.promises.rm).not.toHaveBeenCalled() }) test("cleanOrphans deletes dirs that don't contain `link` and subdirs that aren't pointed to by `link` from the same parent", async () => { @@ -185,7 +176,7 @@ test("cleanOrphans deletes dirs that don't contain `link` and subdirs that aren' createSampleDlxCacheLinkTarget(path.join(cacheDir, 'dlx', createCacheKey('foo'), `${now.getTime().toString(16)}-${(7000).toString(16)}`)) createSampleDlxCacheLinkTarget(path.join(cacheDir, 'dlx', createCacheKey('foo'), `${now.getTime().toString(16)}-${(7005).toString(16)}`)) createSampleDlxCacheLinkTarget(path.join(cacheDir, 'dlx', createCacheKey('foo'), `${now.getTime().toString(16)}-${(7102).toString(16)}`)) - expect(fs.readdirSync(path.join(cacheDir, 'dlx', createCacheKey('foo')))).toHaveLength(5) + expect(fsOriginal.readdirSync(path.join(cacheDir, 'dlx', createCacheKey('foo')))).toHaveLength(5) // has no link, only orphans createSampleDlxCacheLinkTarget(path.join(cacheDir, 'dlx', createCacheKey('bar'), `${now.getTime().toString(16)}-${(7000).toString(16)}`)) diff --git a/store/plugin-commands-store/src/cleanExpiredDlxCache.ts b/store/plugin-commands-store/src/cleanExpiredDlxCache.ts index ec01f1040a..11cf0270df 100644 --- a/store/plugin-commands-store/src/cleanExpiredDlxCache.ts +++ b/store/plugin-commands-store/src/cleanExpiredDlxCache.ts @@ -1,5 +1,4 @@ -import { readdirSync, type Stats } from 'fs' -import fs from 'fs/promises' +import { readdirSync, type Stats, promises as fs } from 'fs' import path from 'path' import util from 'util' diff --git a/store/plugin-commands-store/src/store.ts b/store/plugin-commands-store/src/store.ts index 76ca0ecac8..45d47298fa 100644 --- a/store/plugin-commands-store/src/store.ts +++ b/store/plugin-commands-store/src/store.ts @@ -4,7 +4,7 @@ import { PnpmError } from '@pnpm/error' import { logger, type LogBase } from '@pnpm/logger' import { createOrConnectStoreController, type CreateStoreControllerOptions } from '@pnpm/store-connection-manager' import { getStorePath } from '@pnpm/store-path' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { storeAdd } from './storeAdd.js' import { storePrune } from './storePrune.js' diff --git a/store/plugin-commands-store/test/storePrune.ts b/store/plugin-commands-store/test/storePrune.ts index be26f85465..129a0143e5 100644 --- a/store/plugin-commands-store/test/storePrune.ts +++ b/store/plugin-commands-store/test/storePrune.ts @@ -11,7 +11,7 @@ import { jest } from '@jest/globals' import execa from 'execa' const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}/` -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') const createCacheKey = (...packages: string[]): string => dlx.createCacheKey({ packages, diff --git a/store/plugin-commands-store/test/storeStatus.ts b/store/plugin-commands-store/test/storeStatus.ts index 3d796538b6..4375fae9b6 100644 --- a/store/plugin-commands-store/test/storeStatus.ts +++ b/store/plugin-commands-store/test/storeStatus.ts @@ -8,7 +8,7 @@ import execa from 'execa' import tempy from 'tempy' const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}/` -const pnpmBin = path.join(__dirname, '../../../pnpm/bin/pnpm.cjs') +const pnpmBin = path.join(import.meta.dirname, '../../../pnpm/bin/pnpm.mjs') test('CLI fails when store status finds modified packages', async () => { const project = prepare() diff --git a/store/plugin-commands-store/test/tsconfig.json b/store/plugin-commands-store/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/store/plugin-commands-store/test/tsconfig.json +++ b/store/plugin-commands-store/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/store/server/package.json b/store/server/package.json index 9ae3bf0ded..bf7020e3f2 100644 --- a/store/server/package.json +++ b/store/server/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest --detectOpenHandles", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/store/server/test/index.ts b/store/server/test/index.ts index ff5cd18898..940bae0fba 100644 --- a/store/server/test/index.ts +++ b/store/server/test/index.ts @@ -178,7 +178,7 @@ test('server upload', async () => { files: {}, }), 'utf8') - await storeCtrl.upload(path.join(__dirname, '__fixtures__/side-effect-fake-dir'), { + await storeCtrl.upload(path.join(import.meta.dirname, '__fixtures__/side-effect-fake-dir'), { sideEffectsCacheKey: fakeEngine, filesIndexFile, }) @@ -211,7 +211,7 @@ test('disable server upload', async () => { let thrown = false try { - await storeCtrl.upload(path.join(__dirname, '__fixtures__/side-effect-fake-dir'), { + await storeCtrl.upload(path.join(import.meta.dirname, '__fixtures__/side-effect-fake-dir'), { sideEffectsCacheKey: fakeEngine, filesIndexFile, }) diff --git a/store/server/test/tsconfig.json b/store/server/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/store/server/test/tsconfig.json +++ b/store/server/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/store/store-connection-manager/package.json b/store/store-connection-manager/package.json index c9f06ce768..21ea8cede0 100644 --- a/store/store-connection-manager/package.json +++ b/store/store-connection-manager/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/store/store-connection-manager/src/runServerInBackground.ts b/store/store-connection-manager/src/runServerInBackground.ts index 8ded35adef..e14d3ac961 100644 --- a/store/store-connection-manager/src/runServerInBackground.ts +++ b/store/store-connection-manager/src/runServerInBackground.ts @@ -3,8 +3,9 @@ import { PnpmError } from '@pnpm/error' import diable from '@zkochan/diable' export function runServerInBackground (storePath: string): void { - if (require.main == null) { + const entry = process.argv[1] + if (!entry) { throw new PnpmError('CANNOT_START_SERVER', 'pnpm server cannot be started when pnpm is streamed to Node.js') } - return diable.daemonize(require.main.filename, ['server', 'start', '--store-dir', storePath], { stdio: 'inherit' }) + return diable.daemonize(entry, ['server', 'start', '--store-dir', storePath], { stdio: 'inherit' }) } diff --git a/store/store-controller-types/package.json b/store/store-controller-types/package.json index c8df559468..2f9d04cd77 100644 --- a/store/store-controller-types/package.json +++ b/store/store-controller-types/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/store/store-path/__mocks__/can-link.js b/store/store-path/__mocks__/can-link.js deleted file mode 100644 index 42f2836f36..0000000000 --- a/store/store-path/__mocks__/can-link.js +++ /dev/null @@ -1,8 +0,0 @@ -const CAN_LINK = new Set([ - '/can-link-to-homedir/tmp=>/home/user/tmp', - '/mnt/project/tmp=>/mnt/tmp/tmp', -]) - -module.exports = function (existingPath, newPath) { - return CAN_LINK.has(`${existingPath}=>${newPath}`) -} diff --git a/store/store-path/__mocks__/fs.js b/store/store-path/__mocks__/fs.js deleted file mode 100644 index 28c4c5edac..0000000000 --- a/store/store-path/__mocks__/fs.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports.promises = { - mkdir: () => {}, - unlink: () => {}, - rmdir: () => {}, -} diff --git a/store/store-path/__mocks__/os.js b/store/store-path/__mocks__/os.js deleted file mode 100644 index 16fdc5dbe8..0000000000 --- a/store/store-path/__mocks__/os.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - homedir: () => '/home/user' -} diff --git a/store/store-path/__mocks__/path-temp.js b/store/store-path/__mocks__/path-temp.js deleted file mode 100644 index 99f5e650e2..0000000000 --- a/store/store-path/__mocks__/path-temp.js +++ /dev/null @@ -1,5 +0,0 @@ -const path = require('path') - -module.exports = function (dir) { - return path.join(dir, 'tmp') -} diff --git a/store/store-path/__mocks__/root-link-target.js b/store/store-path/__mocks__/root-link-target.js deleted file mode 100644 index b976dc574d..0000000000 --- a/store/store-path/__mocks__/root-link-target.js +++ /dev/null @@ -1,8 +0,0 @@ -const MAPPINGS = { - '/src/workspace/project/tmp': '/', - '/mnt/project/tmp': '/mnt/project', -} - -module.exports = async function (file) { - return MAPPINGS[file] -} diff --git a/store/store-path/__mocks__/touch.js b/store/store-path/__mocks__/touch.js deleted file mode 100644 index 4306849e8e..0000000000 --- a/store/store-path/__mocks__/touch.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = async function () {} diff --git a/store/store-path/package.json b/store/store-path/package.json index 8d4f1f0ef0..c7e744a6b0 100644 --- a/store/store-path/package.json +++ b/store/store-path/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "exports": { ".": "./lib/index.js" @@ -26,7 +26,7 @@ "scripts": { "prepublishOnly": "pnpm run compile", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "compile": "tsc --build && pnpm run lint --fix" }, diff --git a/store/store-path/test/index.ts b/store/store-path/test/index.ts index 03842949e1..9985709c26 100644 --- a/store/store-path/test/index.ts +++ b/store/store-path/test/index.ts @@ -1,10 +1,58 @@ +import path from 'path' import { STORE_VERSION } from '@pnpm/constants' -import { getStorePath } from '@pnpm/store-path' import { jest } from '@jest/globals' import isWindows from 'is-windows' -jest.mock('os') -jest.mock('fs') +jest.unstable_mockModule('touch', () => { + return { + default: jest.fn(), + } +}) +jest.unstable_mockModule('root-link-target', () => { + const MAPPINGS: Record = { + '/src/workspace/project/tmp': '/', + '/mnt/project/tmp': '/mnt/project', + } + + return { + default: async function (file: string): Promise { + return MAPPINGS[file] + }, + } +}) +jest.unstable_mockModule('path-temp', () => { + return { + default: function (dir: string): string { + return path.join(dir, 'tmp') + }, + } +}) +jest.unstable_mockModule('os', () => ({ + default: { + homedir: () => '/home/user', + }, +})) +jest.unstable_mockModule('fs', () => ({ + promises: { + mkdir: () => {}, + unlink: () => {}, + rmdir: () => {}, + }, +})) +jest.unstable_mockModule('can-link', () => { + const CAN_LINK = new Set([ + '/can-link-to-homedir/tmp=>/home/user/tmp', + '/mnt/project/tmp=>/mnt/tmp/tmp', + ]) + + return { + default: function (existingPath: string, newPath: string): boolean { + return CAN_LINK.has(`${existingPath}=>${newPath}`) + }, + } +}) + +const { getStorePath } = await import('@pnpm/store-path') const skipOnWindows = isWindows() ? test.skip : test diff --git a/store/store-path/test/tsconfig.json b/store/store-path/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/store/store-path/test/tsconfig.json +++ b/store/store-path/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/testing/temp-store/package.json b/testing/temp-store/package.json index e7ef5b6b16..5603965c63 100644 --- a/testing/temp-store/package.json +++ b/testing/temp-store/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/text/comments-parser/package.json b/text/comments-parser/package.json index aa23c821aa..1b0b0cdd3b 100644 --- a/text/comments-parser/package.json +++ b/text/comments-parser/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "start": "tsc --watch", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", diff --git a/text/comments-parser/test/tsconfig.json b/text/comments-parser/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/text/comments-parser/test/tsconfig.json +++ b/text/comments-parser/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/tools/path/package.json b/tools/path/package.json index a203b8974e..cce46e2ae8 100644 --- a/tools/path/package.json +++ b/tools/path/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/tools/plugin-commands-self-updater/package.json b/tools/plugin-commands-self-updater/package.json index 05d356e6d4..627897b5be 100644 --- a/tools/plugin-commands-self-updater/package.json +++ b/tools/plugin-commands-self-updater/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "prepublishOnly": "pnpm run compile", "test": "pnpm run compile && pnpm run _test", "compile": "tsc --build && pnpm run lint --fix", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/cli-meta": "workspace:*", diff --git a/tools/plugin-commands-self-updater/src/selfUpdate.ts b/tools/plugin-commands-self-updater/src/selfUpdate.ts index 06e07966f7..e56ccdb408 100644 --- a/tools/plugin-commands-self-updater/src/selfUpdate.ts +++ b/tools/plugin-commands-self-updater/src/selfUpdate.ts @@ -7,7 +7,7 @@ import { PnpmError } from '@pnpm/error' import { globalWarn } from '@pnpm/logger' import { readProjectManifest } from '@pnpm/read-project-manifest' import { linkBins } from '@pnpm/link-bins' -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import renderHelp from 'render-help' import { installPnpmToTools } from './installPnpmToTools.js' diff --git a/tools/plugin-commands-self-updater/test/selfUpdate.test.ts b/tools/plugin-commands-self-updater/test/selfUpdate.test.ts index 9f5ab5c767..fc9701b4f3 100644 --- a/tools/plugin-commands-self-updater/test/selfUpdate.test.ts +++ b/tools/plugin-commands-self-updater/test/selfUpdate.test.ts @@ -1,17 +1,17 @@ import fs from 'fs' +import { createRequire } from 'module' import path from 'path' import { prependDirsToPath } from '@pnpm/env.path' import { tempDir, prepare as prepareWithPkg } from '@pnpm/prepare' -import { selfUpdate } from '@pnpm/tools.plugin-commands-self-updater' import { jest } from '@jest/globals' import spawn from 'cross-spawn' import nock from 'nock' +const require = createRequire(import.meta.dirname) const pnpmTarballPath = require.resolve('@pnpm/tgz-fixtures/tgz/pnpm-9.1.0.tgz') -jest.mock('@pnpm/cli-meta', () => { - const actualModule = jest.requireActual('@pnpm/cli-meta') - +const actualModule = await import('@pnpm/cli-meta') +jest.unstable_mockModule('@pnpm/cli-meta', () => { return { ...actualModule, packageManager: { @@ -20,6 +20,7 @@ jest.mock('@pnpm/cli-meta', () => { }, } }) +const { selfUpdate } = await import('@pnpm/tools.plugin-commands-self-updater') afterEach(() => { nock.cleanAll() diff --git a/tools/plugin-commands-self-updater/test/tsconfig.json b/tools/plugin-commands-self-updater/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/tools/plugin-commands-self-updater/test/tsconfig.json +++ b/tools/plugin-commands-self-updater/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/worker/package.json b/worker/package.json index 5c3bb0e81a..d9185a5ab4 100644 --- a/worker/package.json +++ b/worker/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/worker/src/index.ts b/worker/src/index.ts index 1b3255b339..7fac0eba21 100644 --- a/worker/src/index.ts +++ b/worker/src/index.ts @@ -1,7 +1,7 @@ // cspell:ignore checkin import path from 'path' import os from 'os' -import { WorkerPool } from '@rushstack/worker-pool/lib/WorkerPool' +import { WorkerPool } from '@rushstack/worker-pool/lib/WorkerPool.js' import { PnpmError } from '@pnpm/error' import { execSync } from 'child_process' import isWindows from 'is-windows' @@ -34,7 +34,7 @@ function createTarballWorkerPool (): WorkerPool { const workerPool = new WorkerPool({ id: 'pnpm', maxWorkers, - workerScriptPath: path.join(__dirname, 'worker.js'), + workerScriptPath: path.join(import.meta.dirname, 'worker.js'), }) // @ts-expect-error if (global.finishWorkers) { diff --git a/workspace/filter-packages-from-dir/package.json b/workspace/filter-packages-from-dir/package.json index e38d0ba849..46259cf49d 100644 --- a/workspace/filter-packages-from-dir/package.json +++ b/workspace/filter-packages-from-dir/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/workspace/filter-workspace-packages/package.json b/workspace/filter-workspace-packages/package.json index cc261861a4..a830a57cff 100644 --- a/workspace/filter-workspace-packages/package.json +++ b/workspace/filter-workspace-packages/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/workspace/filter-workspace-packages/src/getChangedPackages.ts b/workspace/filter-workspace-packages/src/getChangedPackages.ts index bbbb6f25e6..51d042f9d9 100644 --- a/workspace/filter-workspace-packages/src/getChangedPackages.ts +++ b/workspace/filter-workspace-packages/src/getChangedPackages.ts @@ -78,7 +78,7 @@ async function getChangedDirsSinceCommit (commit: string, workingDir: string, te (pattern) => pattern.length ) const changedFiles = (patterns.length > 0) - ? micromatch.not(allChangedFiles, patterns, { + ? micromatch.default.not(allChangedFiles, patterns, { dot: true, }) : allChangedFiles @@ -88,7 +88,7 @@ async function getChangedDirsSinceCommit (commit: string, workingDir: string, te if (changedDirs.get(dir) === 'source') continue - const changeType: ChangeType = testPattern.some(pattern => micromatch.isMatch(changedFile, pattern)) + const changeType: ChangeType = testPattern.some(pattern => micromatch.default.isMatch(changedFile, pattern)) ? 'test' : 'source' changedDirs.set(dir, changeType) diff --git a/workspace/filter-workspace-packages/src/index.ts b/workspace/filter-workspace-packages/src/index.ts index e634cd44cc..a91e8ee60c 100644 --- a/workspace/filter-workspace-packages/src/index.ts +++ b/workspace/filter-workspace-packages/src/index.ts @@ -3,9 +3,7 @@ import { type ProjectRootDir, type SupportedArchitectures } from '@pnpm/types' import { findWorkspacePackages, type Project } from '@pnpm/workspace.find-packages' import { createPkgGraph, type Package, type PackageNode } from '@pnpm/workspace.pkgs-graph' import isSubdir from 'is-subdir' -import difference from 'ramda/src/difference' -import partition from 'ramda/src/partition' -import pick from 'ramda/src/pick' +import { difference, partition, pick } from 'ramda' import * as micromatch from 'micromatch' import { getChangedPackages } from './getChangedPackages.js' import { parsePackageSelector, type PackageSelector } from './parsePackageSelector.js' @@ -322,7 +320,7 @@ function matchPackagesByGlob ( ): ProjectRootDir[] { const format = (str: string) => str.replace(/\/$/, '') const formattedFilter = pathStartsWith.replace(/\\/g, '/').replace(/\/$/, '') - return (Object.keys(graph) as ProjectRootDir[]).filter((parentDir) => micromatch.isMatch(parentDir, formattedFilter, { format })) + return (Object.keys(graph) as ProjectRootDir[]).filter((parentDir) => micromatch.default.isMatch(parentDir, formattedFilter, { format })) } function pickSubgraph ( diff --git a/workspace/filter-workspace-packages/test/index.ts b/workspace/filter-workspace-packages/test/index.ts index 3660fb3b90..d6dadbd47c 100644 --- a/workspace/filter-workspace-packages/test/index.ts +++ b/workspace/filter-workspace-packages/test/index.ts @@ -9,7 +9,7 @@ import execa from 'execa' import { isCI } from 'ci-info' import isWindows from 'is-windows' import path from 'path' -import omit from 'ramda/src/omit' +import { omit } from 'ramda' import tempy from 'tempy' import touchCB from 'touch' diff --git a/workspace/filter-workspace-packages/test/tsconfig.json b/workspace/filter-workspace-packages/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/workspace/filter-workspace-packages/test/tsconfig.json +++ b/workspace/filter-workspace-packages/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/workspace/find-packages/package.json b/workspace/find-packages/package.json index 261d2ebfd7..1f80be7827 100644 --- a/workspace/find-packages/package.json +++ b/workspace/find-packages/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/workspace/find-packages/test/index.ts b/workspace/find-packages/test/index.ts index 2b14940384..eb030dd7ca 100644 --- a/workspace/find-packages/test/index.ts +++ b/workspace/find-packages/test/index.ts @@ -16,7 +16,7 @@ afterEach(() => { }) test('findWorkspacePackagesNoCheck() skips engine checks', async () => { - const fixturePath = path.join(__dirname, '__fixtures__/bad-engine') + const fixturePath = path.join(import.meta.dirname, '__fixtures__/bad-engine') const workspaceManifest = await readWorkspaceManifest(fixturePath) if (workspaceManifest?.packages == null) { @@ -31,7 +31,7 @@ test('findWorkspacePackagesNoCheck() skips engine checks', async () => { }) test('findWorkspacePackages() output warnings for non-root workspace project', async () => { - const fixturePath = path.join(__dirname, '__fixtures__/warning-for-non-root-project') + const fixturePath = path.join(import.meta.dirname, '__fixtures__/warning-for-non-root-project') const workspaceManifest = await readWorkspaceManifest(fixturePath) if (workspaceManifest?.packages == null) { diff --git a/workspace/find-packages/test/tsconfig.json b/workspace/find-packages/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/workspace/find-packages/test/tsconfig.json +++ b/workspace/find-packages/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/workspace/find-workspace-dir/package.json b/workspace/find-workspace-dir/package.json index 52d5ccc4ea..338dc8f2dd 100644 --- a/workspace/find-workspace-dir/package.json +++ b/workspace/find-workspace-dir/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/workspace/find-workspace-dir/test/index.ts b/workspace/find-workspace-dir/test/index.ts index acd11a941b..e7d0d302aa 100644 --- a/workspace/find-workspace-dir/test/index.ts +++ b/workspace/find-workspace-dir/test/index.ts @@ -22,13 +22,13 @@ const testOnCaseInSensitiveSystems = isFileSystemCaseSensitive() ? test.skip : t test('finds actual workspace dir', async () => { const workspaceDir = await findWorkspaceDir(process.cwd()) - expect(workspaceDir).toBe(path.resolve(__dirname, '..', '..', '..')) + expect(workspaceDir).toBe(path.resolve(import.meta.dirname, '..', '..', '..')) }) testOnCaseInSensitiveSystems('finds workspace dir with wrong case from cwd', async () => { const workspaceDir = await findWorkspaceDir(process.cwd().toUpperCase()) - expect(workspaceDir).toBe(path.resolve(__dirname, '..', '..', '..')) + expect(workspaceDir).toBe(path.resolve(import.meta.dirname, '..', '..', '..')) }) test('finds overridden workspace dir', async () => { diff --git a/workspace/find-workspace-dir/test/tsconfig.json b/workspace/find-workspace-dir/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/workspace/find-workspace-dir/test/tsconfig.json +++ b/workspace/find-workspace-dir/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/workspace/injected-deps-syncer/package.json b/workspace/injected-deps-syncer/package.json index ec388c5ef3..6057787afa 100644 --- a/workspace/injected-deps-syncer/package.json +++ b/workspace/injected-deps-syncer/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/directory-fetcher": "workspace:*", diff --git a/workspace/injected-deps-syncer/test/tsconfig.json b/workspace/injected-deps-syncer/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/workspace/injected-deps-syncer/test/tsconfig.json +++ b/workspace/injected-deps-syncer/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/workspace/manifest-writer/package.json b/workspace/manifest-writer/package.json index 65f3dac3a3..2695263613 100644 --- a/workspace/manifest-writer/package.json +++ b/workspace/manifest-writer/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -28,7 +28,7 @@ "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix", - "_test": "jest" + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest" }, "dependencies": { "@pnpm/catalogs.types": "workspace:*", diff --git a/workspace/manifest-writer/src/index.ts b/workspace/manifest-writer/src/index.ts index e25cec7e82..18af224b87 100644 --- a/workspace/manifest-writer/src/index.ts +++ b/workspace/manifest-writer/src/index.ts @@ -5,7 +5,7 @@ import { type ResolvedCatalogEntry } from '@pnpm/lockfile.types' import { readWorkspaceManifest, type WorkspaceManifest } from '@pnpm/workspace.read-manifest' import { WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants' import writeYamlFile from 'write-yaml-file' -import equals from 'ramda/src/equals' +import { equals } from 'ramda' import { sortKeysByPriority } from '@pnpm/object.key-sorting' import { type Project, diff --git a/workspace/manifest-writer/test/tsconfig.json b/workspace/manifest-writer/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/workspace/manifest-writer/test/tsconfig.json +++ b/workspace/manifest-writer/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/workspace/pkgs-graph/package.json b/workspace/pkgs-graph/package.json index 06d6cfe6bf..d7c05121c8 100644 --- a/workspace/pkgs-graph/package.json +++ b/workspace/pkgs-graph/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/workspace/pkgs-graph/src/index.ts b/workspace/pkgs-graph/src/index.ts index 110943cb6b..22497c9cc9 100644 --- a/workspace/pkgs-graph/src/index.ts +++ b/workspace/pkgs-graph/src/index.ts @@ -3,7 +3,7 @@ import npa from '@pnpm/npm-package-arg' import { resolveWorkspaceRange } from '@pnpm/resolve-workspace-range' import { parseBareSpecifier, workspacePrefToNpm } from '@pnpm/npm-resolver' import { type ProjectRootDir, type BaseManifest } from '@pnpm/types' -import mapValues from 'ramda/src/map' +import { map as mapValues } from 'ramda' export interface Package { manifest: BaseManifest diff --git a/workspace/pkgs-graph/test/tsconfig.json b/workspace/pkgs-graph/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/workspace/pkgs-graph/test/tsconfig.json +++ b/workspace/pkgs-graph/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/workspace/read-manifest/package.json b/workspace/read-manifest/package.json index 40552cb355..a29bebc737 100644 --- a/workspace/read-manifest/package.json +++ b/workspace/read-manifest/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/workspace/read-manifest/src/index.ts b/workspace/read-manifest/src/index.ts index df0913fcf5..5ed7a8fcb5 100644 --- a/workspace/read-manifest/src/index.ts +++ b/workspace/read-manifest/src/index.ts @@ -36,7 +36,7 @@ export async function readWorkspaceManifest (dir: string): Promise { try { - return await readYamlFile(path.join(dir, WORKSPACE_MANIFEST_FILENAME)) + return await readYamlFile.default(path.join(dir, WORKSPACE_MANIFEST_FILENAME)) } catch (err: unknown) { // File not exists is the same as empty file (undefined) if (util.types.isNativeError(err) && 'code' in err && err.code === 'ENOENT') { diff --git a/workspace/read-manifest/test/index.ts b/workspace/read-manifest/test/index.ts index edc1c1cb74..6bd53cb6f7 100644 --- a/workspace/read-manifest/test/index.ts +++ b/workspace/read-manifest/test/index.ts @@ -2,7 +2,7 @@ import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest' import path from 'node:path' test('readWorkspaceManifest() works with a valid workspace file', async () => { - const manifest = await readWorkspaceManifest(path.join(__dirname, '__fixtures__/ok')) + const manifest = await readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/ok')) expect(manifest).toEqual({ packages: ['packages/**', 'types'], @@ -11,61 +11,61 @@ test('readWorkspaceManifest() works with a valid workspace file', async () => { test('readWorkspaceManifest() throws on string content', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/string')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/string')) ).rejects.toThrow('Expected object but found - string') }) test('readWorkspaceManifest() throws on array content', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/array')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/array')) ).rejects.toThrow('Expected object but found - array') }) test('readWorkspaceManifest() does not throw on empty packages field', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/packages-empty')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/packages-empty')) ).resolves.toBeTruthy() }) test('readWorkspaceManifest() throws on string packages field', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/packages-string')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/packages-string')) ).rejects.toThrow('packages field is not an array') }) test('readWorkspaceManifest() throws on empty package', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/packages-contains-empty')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/packages-contains-empty')) ).rejects.toThrow('Missing or empty package') }) test('readWorkspaceManifest() throws on numeric package', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/packages-contains-number')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/packages-contains-number')) ).rejects.toThrow('Invalid package type - number') }) test('readWorkspaceManifest() works when no workspace file is present', async () => { - const manifest = await readWorkspaceManifest(path.join(__dirname, '__fixtures__/no-workspace-file')) + const manifest = await readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/no-workspace-file')) expect(manifest).toBeUndefined() }) test('readWorkspaceManifest() works when workspace file is empty', async () => { - const manifest = await readWorkspaceManifest(path.join(__dirname, '__fixtures__/empty')) + const manifest = await readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/empty')) expect(manifest).toBeUndefined() }) test('readWorkspaceManifest() works when workspace file is null', async () => { - const manifest = await readWorkspaceManifest(path.join(__dirname, '__fixtures__/null')) + const manifest = await readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/null')) expect(manifest).toBeNull() }) describe('readWorkspaceManifest() catalog field', () => { test('works on simple catalog', async () => { - await expect(readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalog-ok'))).resolves.toEqual({ + await expect(readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalog-ok'))).resolves.toEqual({ packages: ['packages/**', 'types'], catalog: { foo: '^1.0.0', @@ -75,26 +75,26 @@ describe('readWorkspaceManifest() catalog field', () => { test('throws on invalid array', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalog-invalid-array')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalog-invalid-array')) ).rejects.toThrow('Expected catalog field to be an object, but found - array') }) test('throws on invalid object', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalog-invalid-object')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalog-invalid-object')) ).rejects.toThrow('Expected catalog field to be an object, but found - number') }) test('throws on invalid specifier', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalog-invalid-specifier')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalog-invalid-specifier')) ).rejects.toThrow('Invalid catalog entry for foo. Expected string, but found: object') }) }) describe('readWorkspaceManifest() catalogs field', () => { test('works with simple named catalogs', async () => { - await expect(readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalogs-ok'))).resolves.toEqual({ + await expect(readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalogs-ok'))).resolves.toEqual({ packages: ['packages/**', 'types'], catalog: { bar: '^1.0.0', @@ -109,38 +109,38 @@ describe('readWorkspaceManifest() catalogs field', () => { test('throws on invalid array', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalogs-invalid-array')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalogs-invalid-array')) ).rejects.toThrow('Expected catalogs field to be an object, but found - array') }) test('throws on invalid value', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalogs-invalid-object')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalogs-invalid-object')) ).rejects.toThrow('Expected catalogs field to be an object, but found - number') }) test('throws on invalid named catalog array', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalogs-invalid-named-catalog-array')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalogs-invalid-named-catalog-array')) ).rejects.toThrow('Expected named catalog foo to be an object, but found - array') }) test('throws on invalid named catalog object', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalogs-invalid-named-catalog-object')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalogs-invalid-named-catalog-object')) ).rejects.toThrow('Expected named catalog foo to be an object, but found - number') }) test('throws on invalid named catalog specifier', async () => { await expect( - readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalogs-invalid-named-catalog-specifier')) + readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalogs-invalid-named-catalog-specifier')) ).rejects.toThrow('Catalog \'foo\' has invalid entry \'bar\'. Expected string specifier, but found: object') }) }) describe('readWorkspaceManifest() reads default catalog defined alongside named catalogs', () => { test('works when implicit default catalog is configured alongside named catalogs', async () => { - await expect(readWorkspaceManifest(path.join(__dirname, '__fixtures__/catalogs-ok'))).resolves.toEqual({ + await expect(readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalogs-ok'))).resolves.toEqual({ packages: ['packages/**', 'types'], catalog: { bar: '^1.0.0', diff --git a/workspace/read-manifest/test/tsconfig.json b/workspace/read-manifest/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/workspace/read-manifest/test/tsconfig.json +++ b/workspace/read-manifest/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/workspace/resolve-workspace-range/package.json b/workspace/resolve-workspace-range/package.json index 9a1d7a9be1..97911bd5cc 100644 --- a/workspace/resolve-workspace-range/package.json +++ b/workspace/resolve-workspace-range/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { diff --git a/workspace/sort-packages/package.json b/workspace/sort-packages/package.json index e47964271b..03b695a14c 100644 --- a/workspace/sort-packages/package.json +++ b/workspace/sort-packages/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -42,4 +42,4 @@ "jest": { "preset": "@pnpm/jest-config" } -} \ No newline at end of file +} diff --git a/workspace/spec-parser/package.json b/workspace/spec-parser/package.json index 3658fe405b..18dc4a979b 100644 --- a/workspace/spec-parser/package.json +++ b/workspace/spec-parser/package.json @@ -13,7 +13,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -25,7 +25,7 @@ ], "scripts": { "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/workspace/spec-parser/test/tsconfig.json b/workspace/spec-parser/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/workspace/spec-parser/test/tsconfig.json +++ b/workspace/spec-parser/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts", diff --git a/workspace/state/package.json b/workspace/state/package.json index b6fa3541bc..19f90ce6d5 100644 --- a/workspace/state/package.json +++ b/workspace/state/package.json @@ -14,7 +14,7 @@ "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, - "type": "commonjs", + "type": "module", "main": "lib/index.js", "types": "lib/index.d.ts", "exports": { @@ -26,7 +26,7 @@ ], "scripts": { "test": "pnpm run compile && pnpm run _test", - "_test": "jest", + "_test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "pnpm run compile", "compile": "tsc --build && pnpm run lint --fix" diff --git a/workspace/state/src/createWorkspaceState.ts b/workspace/state/src/createWorkspaceState.ts index fdf73c6387..1d3d409f1c 100644 --- a/workspace/state/src/createWorkspaceState.ts +++ b/workspace/state/src/createWorkspaceState.ts @@ -1,4 +1,4 @@ -import pick from 'ramda/src/pick' +import { pick } from 'ramda' import { type WorkspaceState, type WorkspaceStateSettings, type ProjectsList } from './types.js' export interface CreateWorkspaceStateOptions { diff --git a/workspace/state/test/tsconfig.json b/workspace/state/test/tsconfig.json index 74036126c6..67ce5e1d0e 100644 --- a/workspace/state/test/tsconfig.json +++ b/workspace/state/test/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "noEmit": false, - "outDir": "../test.lib", - "rootDir": "." + "outDir": "../node_modules/.test.lib", + "rootDir": "..", + "isolatedModules": true }, "include": [ "**/*.ts",