Skip to content

Commit

Permalink
Merge branch 'master' into reece/fix-mts
Browse files Browse the repository at this point in the history
  • Loading branch information
RDIL authored Jan 20, 2025
2 parents 4519c60 + 93a5664 commit 56298ba
Show file tree
Hide file tree
Showing 34 changed files with 1,802 additions and 637 deletions.
26 changes: 14 additions & 12 deletions .pnp.cjs

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

Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,16 @@ describe(`Commands`, () => {
expect(xfs.existsSync(`${path}/.yarn/cache`)).toEqual(false);
expect(xfs.existsSync(`${path}/.yarn/global/cache`)).toEqual(false);
}));

test(`it should follow the enableCacheClean configuration`, makeTemporaryEnv({
dependencies: {
[`no-deps`]: `1.0.0`,
},
}, {
enableCacheClean: false,
}, async ({path, run, source}) => {
await run(`install`);
await expect(run(`cache`, `clean`)).rejects.toThrowError();
}));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,33 @@ describe(`Commands`, () => {
}),
);

tests.testIf(
() => process.platform !== `win32`,
`it should install from zips that are symlinks`,
makeTemporaryEnv({
dependencies: {
[`no-deps`]: `1.0.0`,
},
}, async ({path, run, source}) => {
await run(`install`);

const allFiles = await xfs.readdirPromise(ppath.join(path, `.yarn/cache`));
const zipFiles = allFiles.filter(file => file.endsWith(`.zip`));

await xfs.mkdirPromise(ppath.join(path, `store`));
for (const filename of zipFiles) {
const zipFile = ppath.join(path, `.yarn/cache`, filename);
const storePath = ppath.join(path, `store`, filename);
await xfs.movePromise(zipFile, storePath);
await xfs.symlinkPromise(storePath, zipFile);
}

await xfs.removePromise(ppath.join(path, Filename.pnpCjs));

await run(`install`, `--immutable`);
}),
);

test(
`it should refuse to create a lockfile when using --immutable`,
makeTemporaryEnv({
Expand Down
62 changes: 60 additions & 2 deletions packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ describe(`Plug'n'Play - ESM`, () => {
),
);

test(
// @ts-expect-error - Missing types
(process.features.require_module ? it.skip : it)(
`it should throw ERR_REQUIRE_ESM when requiring a file with type=module`,
makeTemporaryEnv(
{
Expand Down Expand Up @@ -643,7 +644,36 @@ describe(`Plug'n'Play - ESM`, () => {
),
);

test(
// @ts-expect-error - Missing types
(process.features.require_module ? it : it.skip)(
`it should not throw ERR_REQUIRE_ESM when requiring a file with type=module`,
makeTemporaryEnv(
{
dependencies: {
'no-deps-esm': `1.0.0`,
},
},
{
pnpEnableEsmLoader: true,
},
async ({path, run, source}) => {
await run(`install`);

await xfs.writeFilePromise(ppath.join(path, `index.js`), `
require('no-deps-esm')
console.log('ESM required')
`);

await expect(run(`node`, `index.js`)).resolves.toMatchObject({
code: 0,
stdout: `ESM required\n`,
});
},
),
);

// @ts-expect-error - Missing types
(process.features.require_module ? it.skip : it)(
`it should throw ERR_REQUIRE_ESM when requiring a .mjs file`,
makeTemporaryEnv(
{
Expand Down Expand Up @@ -673,6 +703,34 @@ describe(`Plug'n'Play - ESM`, () => {
),
);

// @ts-expect-error - Missing types
(process.features.require_module ? it : it.skip)(
`it should not throw ERR_REQUIRE_ESM when requiring a .mjs file`,
makeTemporaryEnv(
{
dependencies: {
'no-deps-mjs': `1.0.0`,
},
},
{
pnpEnableEsmLoader: true,
},
async ({path, run, source}) => {
await run(`install`);

await xfs.writeFilePromise(ppath.join(path, `index.js`), `
require('no-deps-mjs/index.mjs')
console.log('ESM required')
`);

await expect(run(`node`, `index.js`)).resolves.toMatchObject({
code: 0,
stdout: `ESM required\n`,
});
},
),
);

test(
`it should throw ERR_MODULE_NOT_FOUND when statically importing a nonexistent file`,
makeTemporaryEnv(
Expand Down
27 changes: 27 additions & 0 deletions packages/acceptance-tests/pkg-tests-specs/sources/pnp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2253,4 +2253,31 @@ describe(`Plug'n'Play`, () => {
});
}),
);

testIf(
() => process.platform !== `win32`,
`it can resolve files from zips that are symlinks`,
makeTemporaryEnv({
dependencies: {
[`no-deps`]: `1.0.0`,
},
}, async ({path, run, source}) => {
await run(`install`);

const allFiles = await xfs.readdirPromise(ppath.join(path, `.yarn/cache`));
const zipFiles = allFiles.filter(file => file.endsWith(`.zip`));

await xfs.mkdirPromise(ppath.join(path, `store`));
for (const filename of zipFiles) {
const zipFile = ppath.join(path, `.yarn/cache`, filename);
const storePath = ppath.join(path, `store`, filename);
await xfs.movePromise(zipFile, storePath);
await xfs.symlinkPromise(storePath, zipFile);
}

await expect(
source(`require('no-deps')`),
).resolves.toEqual({name: `no-deps`, version: `1.0.0`});
}),
);
});
556 changes: 278 additions & 278 deletions packages/berry-cli/bin/berry.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,14 @@ const SLICES = [
from: `18776a771f795ecc2535ee56705ea9fdb786a569`,
to: `519971751e31f38542a608abf21ba3d61c5c3f93`,
onto: `69fb689edbbce517a4615be9d356c6c812639849`,
range: `>=5.7.0-beta`,
range: `>=5.7.0-beta <5.7.1-rc`,
},
// https://github.com/yarnpkg/TypeScript/tree/merceyz/pnp-5.7-rc
{
from: `99f3e130bbe02473680bfa040d131c1f7f08fcc0`,
to: `99f3e130bbe02473680bfa040d131c1f7f08fcc0`,
onto: `c1216dea1a504da7b89b5221b925abcd1702d7e4`,
range: `>=5.7.1-rc`,
},
];

Expand Down
Loading

0 comments on commit 56298ba

Please sign in to comment.