diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8176b37..53d2cd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [14.x, 16.x] + node: [18.x, 20.x, 21.x] deno: ['1'] steps: - uses: actions/checkout@v2 diff --git a/src/generator.ts b/src/generator.ts index 1a2e686..5d11221 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -537,22 +537,17 @@ export class Generator { * Link a module, installing all dependencies necessary into the map * to support its execution including static and dynamic module imports. * - * @param specifier Module to link + * @param specifier Module or list of modules to link * @param parentUrl Optional parent URL */ async link( - specifier?: string | string[], + specifier: string | string[], parentUrl?: string ): Promise<{ staticDeps: string[]; dynamicDeps: string[] }> { if (typeof specifier === "string") specifier = [specifier]; let error = false; if (this.installCnt++ === 0) this.traceMap.startInstall(); await this.traceMap.processInputMap; - if (!specifier || specifier.length === 0) { - const { map, staticDeps, dynamicDeps } = await this.traceMap.finishInstall(); - this.map = map; - return { staticDeps, dynamicDeps }; - } specifier = specifier.map((specifier) => specifier.replace(/\\/g, "/")); try { await Promise.all( @@ -1010,6 +1005,21 @@ export class Generator { } } + /** + * Locking install, retraces all top-level pins but does not change the + * versions of anything (similar to "npm ci"). + */ + async reinstall() { + if (this.installCnt++ === 0) this.traceMap.startInstall(); + await this.traceMap.processInputMap; + if (--this.installCnt === 0) { + const { map, staticDeps, dynamicDeps } = + await this.traceMap.finishInstall(); + this.map = map; + return { staticDeps, dynamicDeps }; + } + } + /** * Updates the versions of the given packages to the latest versions * compatible with their parent's package.json ranges. If no packages are diff --git a/test/api/providerswitch.test.js b/test/api/providerswitch.test.js index 2667294..e0e6003 100644 --- a/test/api/providerswitch.test.js +++ b/test/api/providerswitch.test.js @@ -13,7 +13,7 @@ const generator = new Generator({ // The generator should swap the provider from skypack to jspm.io. // TODO: once we land defaultProvider changes this test will break -await generator.install(); +await generator.reinstall(); const json = generator.getMap(); assert(json.imports.react.startsWith("https://ga.jspm.io/npm:")); diff --git a/test/api/reenv.test.js b/test/api/reenv.test.js index 852ebe7..1b4b9b4 100644 --- a/test/api/reenv.test.js +++ b/test/api/reenv.test.js @@ -19,7 +19,7 @@ import assert from "assert"; env: ["production", "browser"], }); - await generator.link(); + await generator.reinstall(); const json = generator.getMap(); assert.strictEqual( @@ -50,7 +50,7 @@ import assert from "assert"; }, }); - await generator.link(); + await generator.reinstall(); const json = generator.getMap(); diff --git a/test/providers/esmsh.test.js b/test/providers/esmsh.test.skip.js similarity index 100% rename from test/providers/esmsh.test.js rename to test/providers/esmsh.test.skip.js diff --git a/test/test.html b/test/test.html index f3bde45..f393db0 100644 --- a/test/test.html +++ b/test/test.html @@ -10,7 +10,7 @@ "scopes": { "../": { "#fetch": "../dist/fetch-native.js", - "@babel/core": "https://ga.jspm.io/npm:@babel/core@7.23.3/lib/index.js", + "@babel/core": "https://ga.jspm.io/npm:@babel/core@7.23.5/lib/index.js", "@babel/plugin-syntax-import-assertions": "https://ga.jspm.io/npm:@babel/plugin-syntax-import-assertions@7.23.3/lib/index.js", "@babel/preset-typescript": "https://ga.jspm.io/npm:@babel/preset-typescript@7.23.3/lib/index.js", "@jspm/import-map": "https://ga.jspm.io/npm:@jspm/import-map@1.0.7/dist/map.js", @@ -23,19 +23,19 @@ "url": "https://ga.jspm.io/npm:@jspm/core@2.0.1/nodelibs/browser/url.js" }, "https://ga.jspm.io/": { - "#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/core@7.23.3/lib/config/files/index-browser.js", - "#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/core@7.23.3/lib/config/resolve-targets-browser.js", - "#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/core@7.23.3/lib/transform-file-browser.js", - "#node.js": "https://ga.jspm.io/npm:browserslist@4.22.1/browser.js", + "#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/core@7.23.5/lib/config/files/index-browser.js", + "#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/core@7.23.5/lib/config/resolve-targets-browser.js", + "#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/core@7.23.5/lib/transform-file-browser.js", + "#node.js": "https://ga.jspm.io/npm:browserslist@4.22.2/browser.js", "@ampproject/remapping": "https://ga.jspm.io/npm:@ampproject/remapping@2.2.1/dist/remapping.umd.js", - "@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.22.13/lib/index.js", - "@babel/compat-data/native-modules": "https://ga.jspm.io/npm:@babel/compat-data@7.23.3/native-modules.js", - "@babel/compat-data/plugins": "https://ga.jspm.io/npm:@babel/compat-data@7.23.3/plugins.js", - "@babel/core": "https://ga.jspm.io/npm:@babel/core@7.23.3/lib/index.js", - "@babel/generator": "https://ga.jspm.io/npm:@babel/generator@7.23.3/lib/index.js", + "@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.23.5/lib/index.js", + "@babel/compat-data/native-modules": "https://ga.jspm.io/npm:@babel/compat-data@7.23.5/native-modules.js", + "@babel/compat-data/plugins": "https://ga.jspm.io/npm:@babel/compat-data@7.23.5/plugins.js", + "@babel/core": "https://ga.jspm.io/npm:@babel/core@7.23.5/lib/index.js", + "@babel/generator": "https://ga.jspm.io/npm:@babel/generator@7.23.5/lib/index.js", "@babel/helper-annotate-as-pure": "https://ga.jspm.io/npm:@babel/helper-annotate-as-pure@7.22.5/lib/index.js", "@babel/helper-compilation-targets": "https://ga.jspm.io/npm:@babel/helper-compilation-targets@7.22.15/lib/index.js", - "@babel/helper-create-class-features-plugin": "https://ga.jspm.io/npm:@babel/helper-create-class-features-plugin@7.22.15/lib/index.js", + "@babel/helper-create-class-features-plugin": "https://ga.jspm.io/npm:@babel/helper-create-class-features-plugin@7.23.5/lib/index.js", "@babel/helper-environment-visitor": "https://ga.jspm.io/npm:@babel/helper-environment-visitor@7.22.20/lib/index.js", "@babel/helper-function-name": "https://ga.jspm.io/npm:@babel/helper-function-name@7.23.0/lib/index.js", "@babel/helper-hoist-variables": "https://ga.jspm.io/npm:@babel/helper-hoist-variables@7.22.5/lib/index.js", @@ -48,34 +48,34 @@ "@babel/helper-simple-access": "https://ga.jspm.io/npm:@babel/helper-simple-access@7.22.5/lib/index.js", "@babel/helper-skip-transparent-expression-wrappers": "https://ga.jspm.io/npm:@babel/helper-skip-transparent-expression-wrappers@7.22.5/lib/index.js", "@babel/helper-split-export-declaration": "https://ga.jspm.io/npm:@babel/helper-split-export-declaration@7.22.6/lib/index.js", - "@babel/helper-string-parser": "https://ga.jspm.io/npm:@babel/helper-string-parser@7.22.5/lib/index.js", + "@babel/helper-string-parser": "https://ga.jspm.io/npm:@babel/helper-string-parser@7.23.4/lib/index.js", "@babel/helper-validator-identifier": "https://ga.jspm.io/npm:@babel/helper-validator-identifier@7.22.20/lib/index.js", - "@babel/helper-validator-option": "https://ga.jspm.io/npm:@babel/helper-validator-option@7.22.15/lib/index.js", - "@babel/helpers": "https://ga.jspm.io/npm:@babel/helpers@7.23.2/lib/index.js", - "@babel/highlight": "https://ga.jspm.io/npm:@babel/highlight@7.22.20/lib/index.js", - "@babel/parser": "https://ga.jspm.io/npm:@babel/parser@7.23.3/lib/index.js", + "@babel/helper-validator-option": "https://ga.jspm.io/npm:@babel/helper-validator-option@7.23.5/lib/index.js", + "@babel/helpers": "https://ga.jspm.io/npm:@babel/helpers@7.23.5/lib/index.js", + "@babel/highlight": "https://ga.jspm.io/npm:@babel/highlight@7.23.4/lib/index.js", + "@babel/parser": "https://ga.jspm.io/npm:@babel/parser@7.23.5/lib/index.js", "@babel/plugin-syntax-jsx": "https://ga.jspm.io/npm:@babel/plugin-syntax-jsx@7.23.3/lib/index.js", "@babel/plugin-syntax-typescript": "https://ga.jspm.io/npm:@babel/plugin-syntax-typescript@7.23.3/lib/index.js", "@babel/plugin-transform-modules-commonjs": "https://ga.jspm.io/npm:@babel/plugin-transform-modules-commonjs@7.23.3/lib/index.js", - "@babel/plugin-transform-typescript": "https://ga.jspm.io/npm:@babel/plugin-transform-typescript@7.23.3/lib/index.js", + "@babel/plugin-transform-typescript": "https://ga.jspm.io/npm:@babel/plugin-transform-typescript@7.23.5/lib/index.js", "@babel/template": "https://ga.jspm.io/npm:@babel/template@7.22.15/lib/index.js", - "@babel/traverse": "https://ga.jspm.io/npm:@babel/traverse@7.23.3/lib/index.js", - "@babel/types": "https://ga.jspm.io/npm:@babel/types@7.23.3/lib/index.js", + "@babel/traverse": "https://ga.jspm.io/npm:@babel/traverse@7.23.5/lib/index.js", + "@babel/types": "https://ga.jspm.io/npm:@babel/types@7.23.5/lib/index.js", "@jridgewell/gen-mapping": "https://ga.jspm.io/npm:@jridgewell/gen-mapping@0.3.3/dist/gen-mapping.umd.js", "@jridgewell/resolve-uri": "https://ga.jspm.io/npm:@jridgewell/resolve-uri@3.1.1/dist/resolve-uri.umd.js", "@jridgewell/set-array": "https://ga.jspm.io/npm:@jridgewell/set-array@1.1.2/dist/set-array.umd.js", "@jridgewell/sourcemap-codec": "https://ga.jspm.io/npm:@jridgewell/sourcemap-codec@1.4.15/dist/sourcemap-codec.umd.js", "@jridgewell/trace-mapping": "https://ga.jspm.io/npm:@jridgewell/trace-mapping@0.3.20/dist/trace-mapping.umd.js", "ansi-styles": "https://ga.jspm.io/npm:ansi-styles@3.2.1/index.js", - "browserslist": "https://ga.jspm.io/npm:browserslist@4.22.1/index.js", + "browserslist": "https://ga.jspm.io/npm:browserslist@4.22.2/index.js", "buffer": "https://ga.jspm.io/npm:@jspm/core@2.0.1/nodelibs/browser/buffer.js", - "caniuse-lite/dist/unpacker/agents": "https://ga.jspm.io/npm:caniuse-lite@1.0.30001563/dist/unpacker/agents.js", + "caniuse-lite/dist/unpacker/agents": "https://ga.jspm.io/npm:caniuse-lite@1.0.30001566/dist/unpacker/agents.js", "chalk": "https://ga.jspm.io/npm:chalk@2.4.2/index.js", "color-convert": "https://ga.jspm.io/npm:color-convert@1.9.3/index.js", "color-name": "https://ga.jspm.io/npm:color-name@1.1.3/index.js", "convert-source-map": "https://ga.jspm.io/npm:convert-source-map@2.0.0/index.js", "debug": "https://ga.jspm.io/npm:debug@4.3.4/src/browser.js", - "electron-to-chromium/versions": "https://ga.jspm.io/npm:electron-to-chromium@1.4.585/versions.js", + "electron-to-chromium/versions": "https://ga.jspm.io/npm:electron-to-chromium@1.4.609/versions.js", "escape-string-regexp": "https://ga.jspm.io/npm:escape-string-regexp@1.0.5/index.js", "fs": "https://ga.jspm.io/npm:@jspm/core@2.0.1/nodelibs/browser/fs.js", "gensync": "https://ga.jspm.io/npm:gensync@1.0.0-beta.2/index.js", @@ -84,8 +84,8 @@ "jsesc": "https://ga.jspm.io/npm:jsesc@2.5.2/jsesc.js", "lru-cache": "https://ga.jspm.io/npm:lru-cache@5.1.1/index.js", "ms": "https://ga.jspm.io/npm:ms@2.1.2/index.js", - "node-releases/data/processed/envs.json": "https://ga.jspm.io/npm:node-releases@2.0.13/data/processed/envs.json.js", - "node-releases/data/release-schedule/release-schedule.json": "https://ga.jspm.io/npm:node-releases@2.0.13/data/release-schedule/release-schedule.json.js", + "node-releases/data/processed/envs.json": "https://ga.jspm.io/npm:node-releases@2.0.14/data/processed/envs.json.js", + "node-releases/data/release-schedule/release-schedule.json": "https://ga.jspm.io/npm:node-releases@2.0.14/data/release-schedule/release-schedule.json.js", "path": "https://ga.jspm.io/npm:@jspm/core@2.0.1/nodelibs/browser/path.js", "process": "https://ga.jspm.io/npm:@jspm/core@2.0.1/nodelibs/browser/process-production.js", "semver": "https://ga.jspm.io/npm:semver@6.3.1/semver.js",