Skip to content

Commit 41e32e7

Browse files
authored
deprecate: undeprecate the reinstall feature (#337)
1 parent 2376b38 commit 41e32e7

File tree

6 files changed

+45
-35
lines changed

6 files changed

+45
-35
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
runs-on: ubuntu-latest
5959
strategy:
6060
matrix:
61-
node: [14.x, 16.x]
61+
node: [18.x, 20.x, 21.x]
6262
deno: ['1']
6363
steps:
6464
- uses: actions/checkout@v2

src/generator.ts

+17-7
Original file line numberDiff line numberDiff line change
@@ -537,22 +537,17 @@ export class Generator {
537537
* Link a module, installing all dependencies necessary into the map
538538
* to support its execution including static and dynamic module imports.
539539
*
540-
* @param specifier Module to link
540+
* @param specifier Module or list of modules to link
541541
* @param parentUrl Optional parent URL
542542
*/
543543
async link(
544-
specifier?: string | string[],
544+
specifier: string | string[],
545545
parentUrl?: string
546546
): Promise<{ staticDeps: string[]; dynamicDeps: string[] }> {
547547
if (typeof specifier === "string") specifier = [specifier];
548548
let error = false;
549549
if (this.installCnt++ === 0) this.traceMap.startInstall();
550550
await this.traceMap.processInputMap;
551-
if (!specifier || specifier.length === 0) {
552-
const { map, staticDeps, dynamicDeps } = await this.traceMap.finishInstall();
553-
this.map = map;
554-
return { staticDeps, dynamicDeps };
555-
}
556551
specifier = specifier.map((specifier) => specifier.replace(/\\/g, "/"));
557552
try {
558553
await Promise.all(
@@ -1010,6 +1005,21 @@ export class Generator {
10101005
}
10111006
}
10121007

1008+
/**
1009+
* Locking install, retraces all top-level pins but does not change the
1010+
* versions of anything (similar to "npm ci").
1011+
*/
1012+
async reinstall() {
1013+
if (this.installCnt++ === 0) this.traceMap.startInstall();
1014+
await this.traceMap.processInputMap;
1015+
if (--this.installCnt === 0) {
1016+
const { map, staticDeps, dynamicDeps } =
1017+
await this.traceMap.finishInstall();
1018+
this.map = map;
1019+
return { staticDeps, dynamicDeps };
1020+
}
1021+
}
1022+
10131023
/**
10141024
* Updates the versions of the given packages to the latest versions
10151025
* compatible with their parent's package.json ranges. If no packages are

test/api/providerswitch.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const generator = new Generator({
1313

1414
// The generator should swap the provider from skypack to jspm.io.
1515
// TODO: once we land defaultProvider changes this test will break
16-
await generator.install();
16+
await generator.reinstall();
1717

1818
const json = generator.getMap();
1919
assert(json.imports.react.startsWith("https://ga.jspm.io/npm:"));

test/api/reenv.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import assert from "assert";
1919
env: ["production", "browser"],
2020
});
2121

22-
await generator.link();
22+
await generator.reinstall();
2323
const json = generator.getMap();
2424

2525
assert.strictEqual(
@@ -50,7 +50,7 @@ import assert from "assert";
5050
},
5151
});
5252

53-
await generator.link();
53+
await generator.reinstall();
5454

5555
const json = generator.getMap();
5656

File renamed without changes.

test/test.html

+24-24
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"scopes": {
1111
"../": {
1212
"#fetch": "../dist/fetch-native.js",
13-
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
13+
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
1414
"@babel/plugin-syntax-import-assertions": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
1515
"@babel/preset-typescript": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
1616
"@jspm/import-map": "https://ga.jspm.io/npm:@jspm/[email protected]/dist/map.js",
@@ -23,19 +23,19 @@
2323
"url": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/url.js"
2424
},
2525
"https://ga.jspm.io/": {
26-
"#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/config/files/index-browser.js",
27-
"#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/config/resolve-targets-browser.js",
28-
"#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/transform-file-browser.js",
29-
"#node.js": "https://ga.jspm.io/npm:[email protected].1/browser.js",
26+
"#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/config/files/index-browser.js",
27+
"#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/config/resolve-targets-browser.js",
28+
"#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/transform-file-browser.js",
29+
"#node.js": "https://ga.jspm.io/npm:[email protected].2/browser.js",
3030
"@ampproject/remapping": "https://ga.jspm.io/npm:@ampproject/[email protected]/dist/remapping.umd.js",
31-
"@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.22.13/lib/index.js",
32-
"@babel/compat-data/native-modules": "https://ga.jspm.io/npm:@babel/[email protected].3/native-modules.js",
33-
"@babel/compat-data/plugins": "https://ga.jspm.io/npm:@babel/[email protected].3/plugins.js",
34-
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
35-
"@babel/generator": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
31+
"@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.23.5/lib/index.js",
32+
"@babel/compat-data/native-modules": "https://ga.jspm.io/npm:@babel/[email protected].5/native-modules.js",
33+
"@babel/compat-data/plugins": "https://ga.jspm.io/npm:@babel/[email protected].5/plugins.js",
34+
"@babel/core": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
35+
"@babel/generator": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
3636
"@babel/helper-annotate-as-pure": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
3737
"@babel/helper-compilation-targets": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
38-
"@babel/helper-create-class-features-plugin": "https://ga.jspm.io/npm:@babel/helper-create-class-features-plugin@7.22.15/lib/index.js",
38+
"@babel/helper-create-class-features-plugin": "https://ga.jspm.io/npm:@babel/helper-create-class-features-plugin@7.23.5/lib/index.js",
3939
"@babel/helper-environment-visitor": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
4040
"@babel/helper-function-name": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
4141
"@babel/helper-hoist-variables": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
@@ -48,34 +48,34 @@
4848
"@babel/helper-simple-access": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
4949
"@babel/helper-skip-transparent-expression-wrappers": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
5050
"@babel/helper-split-export-declaration": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
51-
"@babel/helper-string-parser": "https://ga.jspm.io/npm:@babel/helper-string-parser@7.22.5/lib/index.js",
51+
"@babel/helper-string-parser": "https://ga.jspm.io/npm:@babel/helper-string-parser@7.23.4/lib/index.js",
5252
"@babel/helper-validator-identifier": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
53-
"@babel/helper-validator-option": "https://ga.jspm.io/npm:@babel/helper-validator-option@7.22.15/lib/index.js",
54-
"@babel/helpers": "https://ga.jspm.io/npm:@babel/[email protected].2/lib/index.js",
55-
"@babel/highlight": "https://ga.jspm.io/npm:@babel/highlight@7.22.20/lib/index.js",
56-
"@babel/parser": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
53+
"@babel/helper-validator-option": "https://ga.jspm.io/npm:@babel/helper-validator-option@7.23.5/lib/index.js",
54+
"@babel/helpers": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
55+
"@babel/highlight": "https://ga.jspm.io/npm:@babel/highlight@7.23.4/lib/index.js",
56+
"@babel/parser": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
5757
"@babel/plugin-syntax-jsx": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
5858
"@babel/plugin-syntax-typescript": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
5959
"@babel/plugin-transform-modules-commonjs": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
60-
"@babel/plugin-transform-typescript": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
60+
"@babel/plugin-transform-typescript": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
6161
"@babel/template": "https://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
62-
"@babel/traverse": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
63-
"@babel/types": "https://ga.jspm.io/npm:@babel/[email protected].3/lib/index.js",
62+
"@babel/traverse": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
63+
"@babel/types": "https://ga.jspm.io/npm:@babel/[email protected].5/lib/index.js",
6464
"@jridgewell/gen-mapping": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/gen-mapping.umd.js",
6565
"@jridgewell/resolve-uri": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/resolve-uri.umd.js",
6666
"@jridgewell/set-array": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/set-array.umd.js",
6767
"@jridgewell/sourcemap-codec": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/sourcemap-codec.umd.js",
6868
"@jridgewell/trace-mapping": "https://ga.jspm.io/npm:@jridgewell/[email protected]/dist/trace-mapping.umd.js",
6969
"ansi-styles": "https://ga.jspm.io/npm:[email protected]/index.js",
70-
"browserslist": "https://ga.jspm.io/npm:[email protected].1/index.js",
70+
"browserslist": "https://ga.jspm.io/npm:[email protected].2/index.js",
7171
"buffer": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/buffer.js",
72-
"caniuse-lite/dist/unpacker/agents": "https://ga.jspm.io/npm:[email protected].30001563/dist/unpacker/agents.js",
72+
"caniuse-lite/dist/unpacker/agents": "https://ga.jspm.io/npm:[email protected].30001566/dist/unpacker/agents.js",
7373
"chalk": "https://ga.jspm.io/npm:[email protected]/index.js",
7474
"color-convert": "https://ga.jspm.io/npm:[email protected]/index.js",
7575
"color-name": "https://ga.jspm.io/npm:[email protected]/index.js",
7676
"convert-source-map": "https://ga.jspm.io/npm:[email protected]/index.js",
7777
"debug": "https://ga.jspm.io/npm:[email protected]/src/browser.js",
78-
"electron-to-chromium/versions": "https://ga.jspm.io/npm:[email protected].585/versions.js",
78+
"electron-to-chromium/versions": "https://ga.jspm.io/npm:[email protected].609/versions.js",
7979
"escape-string-regexp": "https://ga.jspm.io/npm:[email protected]/index.js",
8080
"fs": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/fs.js",
8181
"gensync": "https://ga.jspm.io/npm:[email protected]/index.js",
@@ -84,8 +84,8 @@
8484
"jsesc": "https://ga.jspm.io/npm:[email protected]/jsesc.js",
8585
"lru-cache": "https://ga.jspm.io/npm:[email protected]/index.js",
8686
"ms": "https://ga.jspm.io/npm:[email protected]/index.js",
87-
"node-releases/data/processed/envs.json": "https://ga.jspm.io/npm:[email protected].13/data/processed/envs.json.js",
88-
"node-releases/data/release-schedule/release-schedule.json": "https://ga.jspm.io/npm:[email protected].13/data/release-schedule/release-schedule.json.js",
87+
"node-releases/data/processed/envs.json": "https://ga.jspm.io/npm:[email protected].14/data/processed/envs.json.js",
88+
"node-releases/data/release-schedule/release-schedule.json": "https://ga.jspm.io/npm:[email protected].14/data/release-schedule/release-schedule.json.js",
8989
"path": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/path.js",
9090
"process": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/process-production.js",
9191
"semver": "https://ga.jspm.io/npm:[email protected]/semver.js",

0 commit comments

Comments
 (0)