Skip to content

Commit 86469fb

Browse files
committed
Fix snapshots for scoped packages
1 parent 4fe593a commit 86469fb

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

packages/core/scripts/createSnapshotFixture.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ if (import.meta.url === "file://" + process.argv[1]) {
1515
* @param {string} packageSpec
1616
*/
1717
async function fetchManifest(packageSpec) {
18-
const [packageName, version = "latest"] = packageSpec.split("@");
18+
const versionIndex = packageSpec.indexOf("@", 1);
19+
const packageName = packageSpec.substring(0, versionIndex < 0 ? undefined : versionIndex);
20+
const version = versionIndex < 0 ? "latest" : packageSpec.substring(versionIndex + 1);
1921
const manifestUrl = `https://registry.npmjs.org/${packageName}/${version}`;
2022
return fetch(manifestUrl).then((r) => r.json());
2123
}
@@ -24,7 +26,7 @@ async function fetchManifest(packageSpec) {
2426
* @param {any} manifest
2527
*/
2628
async function writePackage(manifest) {
27-
const localUrl = new URL(`../test/fixtures/${manifest.name}@${manifest.version}.tgz`, import.meta.url);
29+
const localUrl = new URL(`../test/fixtures/${manifest.name.replace("/", "__")}@${manifest.version}.tgz`, import.meta.url);
2830
const tarballUrl = manifest.dist.tarball;
2931
const packageBuffer = await fetch(tarballUrl).then((r) => r.arrayBuffer());
3032
await writeFile(localUrl, Buffer.from(packageBuffer));
8.37 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
3+
## Summary
4+
5+
```json
6+
[
7+
{
8+
"kind": "FalseCJS",
9+
"title": "Types are CJS, but implementation is ESM",
10+
"messages": [
11+
{
12+
"messageText": "Imports of the package under the `node16` module resolution setting when the importing module is ESM (its extension is `.mts` or `.mjs`, or it has a `.ts` or `.js` extension and is in scope of a `package.json` that contains `\"type\": \"module\"`) resolved to CJS types, but ESM implementations.",
13+
"messageHtml": "Imports of the package under the <code>node16</code> module resolution setting when the importing module is ESM (its extension is <code>.mts</code> or <code>.mjs</code>, or it has a <code>.ts</code> or <code>.js</code> extension and is in scope of a <code>package.json</code> that contains <code>\"type\"\"module\"</code>) resolved to CJS types, but ESM implementations."
14+
}
15+
]
16+
}
17+
]
18+
```
19+
20+
## Problems
21+
22+
```json
23+
[
24+
{
25+
"kind": "FalseCJS",
26+
"entrypoint": ".",
27+
"resolutionKind": "node16-esm"
28+
}
29+
]
30+
```

0 commit comments

Comments
 (0)