Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5c752fc

Browse files
authored
fix(sdks): support Prettier v3 (#5411)
**What's the problem this PR addresses?** Prettier v3 changes the path to the entry point so we need to update the path used. **How did you fix it?** Updated the SDK to require `prettier` and let Node.js find the entry point. **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.
1 parent cf24f17 commit 5c752fc

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

‎.yarn/versions/5a966911.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
releases:
2+
"@yarnpkg/sdks": patch

‎packages/yarnpkg-sdks/sources/generateSdk.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export class Wrapper {
206206
this.target = target;
207207
}
208208

209-
async writeManifest() {
209+
async writeManifest(rawManifest: Record<string,any>={}) {
210210
const absWrapperPath = ppath.join(this.target, this.name, `package.json`);
211211

212212
const topLevelInformation = this.pnpApi.getPackageInformation(this.pnpApi.topLevel)!;
@@ -224,10 +224,11 @@ export class Wrapper {
224224
version: `${manifest.version}-sdk`,
225225
main: manifest.main,
226226
type: `commonjs`,
227+
...rawManifest,
227228
});
228229
}
229230

230-
async writeBinary(relPackagePath: PortablePath, options: TemplateOptions = {}) {
231+
async writeBinary(relPackagePath: PortablePath, options: TemplateOptions &{requirePath?: PortablePath}= {}) {
231232
await this.writeFile(relPackagePath, {...options, mode: 0o755});
232233
}
233234

‎packages/yarnpkg-sdks/sources/sdks/base.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,25 @@ export const generateEslintBaseWrapper: GenerateBaseWrapper = async (pnpApi: Pnp
1919
await wrapper.writeManifest();
2020

2121
await wrapper.writeBinary(`bin/eslint.js` as PortablePath);
22-
await wrapper.writeFile(`lib/api.js` as PortablePath, {requirePath: `` as PortablePath});
22+
await wrapper.writeFile(`lib/api.js` as PortablePath, {
23+
// Empty path to use the entrypoint and let Node.js resolve the correct path itself
24+
requirePath: `` as PortablePath,
25+
});
2326

2427
return wrapper;
2528
};
2629

2730
export const generatePrettierBaseWrapper: GenerateBaseWrapper = async (pnpApi: PnpApi, target: PortablePath) => {
2831
const wrapper = new Wrapper(`prettier` as PortablePath, {pnpApi, target});
2932

30-
await wrapper.writeManifest();
33+
await wrapper.writeManifest({
34+
main: `./index.js`,
35+
});
3136

32-
await wrapper.writeBinary(`index.js` as PortablePath);
37+
await wrapper.writeBinary(`index.js` as PortablePath, {
38+
// Empty path to use the entrypoint and let Node.js resolve the correct path itself
39+
requirePath: `` as PortablePath,
40+
});
3341

3442
return wrapper;
3543
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /