Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: yarnpkg/berry
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7b88e9ef75bf73e97df47428c9146322c9c4315f
Choose a base ref
...
head repository: yarnpkg/berry
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b6026842dfec4b012571b5982bb74420c7682a73
Choose a head ref
  • 2 commits
  • 8 files changed
  • 2 contributors

Commits on Aug 23, 2023

  1. fix(pnp): esm - return undefined source for commonjs (#5677)

    **What's the problem this PR addresses?**
    
    The ESM loader always returns a source which after
    nodejs/node#47999 landed causes stuff to break.
    
    **How did you fix it?**
    
    Return undefined source for commonjs modules
    
    **Checklist**
    - [x] I have read the [Contributing
    Guide](https://yarnpkg.com/advanced/contributing).
    - [x] I have set the packages that need to be released for my changes to
    be effective.
    - [x] I will check that all automated PR checks pass before the PR gets
    reviewed.
    merceyz committed Aug 23, 2023
    1
    Copy the full SHA
    70cbec6 View commit details
  2. Releasing 3 new packages

    | Package name | Version |
    | --- | --- |
    | `@yarnpkg/cli` | `3.6.3` |
    | `@yarnpkg/plugin-pnp` | `3.2.13` |
    | `@yarnpkg/pnp` | `3.3.5` |
    yarnbot committed Aug 23, 2023
    1
    Copy the full SHA
    b602684 View commit details
28 changes: 28 additions & 0 deletions packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts
Original file line number Diff line number Diff line change
@@ -1028,4 +1028,32 @@ describe(`Plug'n'Play - ESM`, () => {
),
);
});

it(
`should use the commonjs resolver in commonjs files imported from ESM`,
makeTemporaryEnv(
{
type: `module`,
},
async ({path, run, source}) => {
await xfs.writeFilePromise(ppath.join(path, `foo.js` as Filename), `import './bar.cjs';`);
await xfs.writeFilePromise(
ppath.join(path, `bar.cjs` as Filename),
`
require('module')._extensions['.custom'] = require('module')._extensions['.js'];
require('./baz');
`,
);
await xfs.writeFilePromise(ppath.join(path, `baz.custom` as Filename), `console.log(42);`);

await expect(run(`install`)).resolves.toMatchObject({code: 0});

await expect(run(`node`, `./foo.js`)).resolves.toMatchObject({
code: 0,
stdout: `42\n`,
stderr: ``,
});
},
),
);
});
4 changes: 2 additions & 2 deletions packages/berry-cli/bin/berry.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/plugin-pnp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yarnpkg/plugin-pnp",
"version": "3.2.12",
"version": "3.2.13",
"license": "BSD-2-Clause",
"main": "./sources/index.ts",
"dependencies": {
4 changes: 2 additions & 2 deletions packages/yarnpkg-cli/bin/yarn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/yarnpkg-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yarnpkg/cli",
"version": "3.6.2",
"version": "3.6.3",
"license": "BSD-2-Clause",
"main": "./sources/index.ts",
"dependencies": {
2 changes: 1 addition & 1 deletion packages/yarnpkg-pnp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yarnpkg/pnp",
"version": "3.3.4",
"version": "3.3.5",
"license": "BSD-2-Clause",
"main": "./sources/index.ts",
"dependencies": {
2 changes: 1 addition & 1 deletion packages/yarnpkg-pnp/sources/esm-loader/built-loader.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/yarnpkg-pnp/sources/esm-loader/hooks/load.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ export async function load(
};
},
nextLoad: typeof load,
): Promise<{ format: string, source: string, shortCircuit: boolean }> {
): Promise<{ format: string, source?: string, shortCircuit: boolean }> {
const url = loaderUtils.tryParseURL(urlString);
if (url?.protocol !== `file:`)
return nextLoad(urlString, context, nextLoad);
@@ -49,7 +49,7 @@ export async function load(

return {
format,
source: await fs.promises.readFile(filePath, `utf8`),
source: format === `commonjs` ? undefined : await fs.promises.readFile(filePath, `utf8`),
shortCircuit: true,
};
}