Skip to content

Commit e70e6bf

Browse files
Resolve the deps with version number to support multiple versions of same package
1 parent 5cc4a2a commit e70e6bf

File tree

4 files changed

+100
-23
lines changed

4 files changed

+100
-23
lines changed

loader.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ const parseModule = async (specifier, modulePathToFetch) => {
4646
}
4747

4848
const moduleURL = new URL(modulePathToFetch);
49-
const [, packageName, , filePath] = moduleURL.pathname.match(
49+
const [, packageName, version , filePath] = moduleURL.pathname.match(
5050
extractPackageNameAndVersion
5151
);
52-
console.log(packageName);
53-
const cachePath = join(cache, packageName, filePath);
52+
console.log(`${packageName}@${version}`);
53+
const cachePath = join(cache, `${packageName}@${version}`, filePath);
5454
cacheMap.set(`file://${cachePath}`, modulePathToFetch);
5555

5656
if (existsSync(cachePath)) {

node.importmap

Lines changed: 91 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"imports": {
3+
"@teleporthq/teleport-project-generator-preact": "https://ga.jspm.io/npm:@teleporthq/teleport-project-generator-preact@0.20.0/dist/cjs/index.js",
34
"@teleporthq/teleport-project-generator-react": "https://ga.jspm.io/npm:@teleporthq/teleport-project-generator-react@0.25.4/dist/cjs/index.js",
45
"@teleporthq/teleport-types": "https://ga.jspm.io/npm:@teleporthq/teleport-types@0.25.2/dist/cjs/index.js",
56
"chalk": "https://ga.jspm.io/npm:chalk@5.2.0/source/index.js",
@@ -32,27 +33,30 @@
3233
"@jridgewell/trace-mapping": "https://ga.jspm.io/npm:@jridgewell/trace-mapping@0.3.17/dist/trace-mapping.umd.js",
3334
"@mojotech/json-type-validation": "https://ga.jspm.io/npm:@mojotech/json-type-validation@3.1.0/dist/index.umd.js",
3435
"@starptech/prettyhtml-hast-to-html": "https://ga.jspm.io/npm:@starptech/prettyhtml-hast-to-html@0.10.0/index.js",
35-
"@teleporthq/teleport-component-generator": "https://ga.jspm.io/npm:@teleporthq/teleport-component-generator@0.25.4/dist/cjs/index.js",
36+
"@teleporthq/teleport-component-generator": "https://ga.jspm.io/npm:@teleporthq/teleport-component-generator@0.20.3/dist/cjs/index.js",
37+
"@teleporthq/teleport-component-generator-preact": "https://ga.jspm.io/npm:@teleporthq/teleport-component-generator-preact@0.20.6/dist/cjs/index.js",
3638
"@teleporthq/teleport-component-generator-react": "https://ga.jspm.io/npm:@teleporthq/teleport-component-generator-react@0.25.4/dist/cjs/index.js",
3739
"@teleporthq/teleport-plugin-common": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.25.4/dist/cjs/index.js",
3840
"@teleporthq/teleport-plugin-css": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-css@0.25.4/dist/cjs/index.js",
39-
"@teleporthq/teleport-plugin-css-modules": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-css-modules@0.25.4/dist/cjs/index.js",
40-
"@teleporthq/teleport-plugin-import-statements": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-import-statements@0.25.4/dist/cjs/index.js",
41-
"@teleporthq/teleport-plugin-jsx-head-config": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-head-config@0.25.4/dist/cjs/index.js",
42-
"@teleporthq/teleport-plugin-jsx-inline-styles": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-inline-styles@0.25.4/dist/cjs/index.js",
43-
"@teleporthq/teleport-plugin-jsx-proptypes": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-proptypes@0.25.4/dist/cjs/index.js",
44-
"@teleporthq/teleport-plugin-react-app-routing": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-react-app-routing@0.25.4/dist/cjs/index.js",
41+
"@teleporthq/teleport-plugin-css-modules": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-css-modules@0.20.6/dist/cjs/index.js",
42+
"@teleporthq/teleport-plugin-import-statements": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-import-statements@0.20.6/dist/cjs/index.js",
43+
"@teleporthq/teleport-plugin-jsx-head-config": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-head-config@0.20.6/dist/cjs/index.js",
44+
"@teleporthq/teleport-plugin-jsx-inline-styles": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-inline-styles@0.20.6/dist/cjs/index.js",
45+
"@teleporthq/teleport-plugin-jsx-proptypes": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-proptypes@0.20.6/dist/cjs/index.js",
46+
"@teleporthq/teleport-plugin-preact-base-component": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-preact-base-component@0.20.6/dist/cjs/index.js",
47+
"@teleporthq/teleport-plugin-react-app-routing": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-react-app-routing@0.20.6/dist/cjs/index.js",
4548
"@teleporthq/teleport-plugin-react-base-component": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-react-base-component@0.25.4/dist/cjs/index.js",
4649
"@teleporthq/teleport-plugin-react-jss": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-react-jss@0.25.4/dist/cjs/index.js",
4750
"@teleporthq/teleport-plugin-react-styled-components": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-react-styled-components@0.25.4/dist/cjs/index.js",
4851
"@teleporthq/teleport-plugin-react-styled-jsx": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-react-styled-jsx@0.25.4/dist/cjs/index.js",
4952
"@teleporthq/teleport-postprocessor-prettier-html": "https://ga.jspm.io/npm:@teleporthq/teleport-postprocessor-prettier-html@0.25.4/dist/cjs/index.js",
50-
"@teleporthq/teleport-postprocessor-prettier-js": "https://ga.jspm.io/npm:@teleporthq/teleport-postprocessor-prettier-js@0.25.4/dist/cjs/index.js",
53+
"@teleporthq/teleport-postprocessor-prettier-js": "https://ga.jspm.io/npm:@teleporthq/teleport-postprocessor-prettier-js@0.20.3/dist/cjs/index.js",
5154
"@teleporthq/teleport-postprocessor-prettier-jsx": "https://ga.jspm.io/npm:@teleporthq/teleport-postprocessor-prettier-jsx@0.25.4/dist/cjs/index.js",
52-
"@teleporthq/teleport-project-generator": "https://ga.jspm.io/npm:@teleporthq/teleport-project-generator@0.25.4/dist/cjs/index.js",
55+
"@teleporthq/teleport-project-generator": "https://ga.jspm.io/npm:@teleporthq/teleport-project-generator@0.20.6/dist/cjs/index.js",
5356
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.25.4/dist/cjs/index.js",
57+
"@teleporthq/teleport-types": "https://ga.jspm.io/npm:@teleporthq/teleport-types@0.20.3/dist/cjs/index.js",
5458
"@teleporthq/teleport-uidl-builders": "https://ga.jspm.io/npm:@teleporthq/teleport-uidl-builders@0.25.2/dist/cjs/index.js",
55-
"@teleporthq/teleport-uidl-resolver": "https://ga.jspm.io/npm:@teleporthq/teleport-uidl-resolver@0.25.4/dist/cjs/index.js",
59+
"@teleporthq/teleport-uidl-resolver": "https://ga.jspm.io/npm:@teleporthq/teleport-uidl-resolver@0.20.3/dist/cjs/index.js",
5660
"@teleporthq/teleport-uidl-validator": "https://ga.jspm.io/npm:@teleporthq/teleport-uidl-validator@0.25.4/dist/cjs/index.js",
5761
"accepts": "https://ga.jspm.io/npm:accepts@1.3.8/index.js",
5862
"array-flatten": "https://ga.jspm.io/npm:array-flatten@1.1.1/array-flatten.js",
@@ -185,6 +189,83 @@
185189
"xtend": "https://ga.jspm.io/npm:xtend@4.0.2/immutable.js",
186190
"zlib": "node:zlib"
187191
},
192+
"https://ga.jspm.io/npm:@teleporthq/teleport-component-generator-preact@0.20.6/": {
193+
"@teleporthq/teleport-plugin-css": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-css@0.20.6/dist/cjs/index.js"
194+
},
195+
"https://ga.jspm.io/npm:@teleporthq/teleport-component-generator-react@0.25.4/": {
196+
"@teleporthq/teleport-component-generator": "https://ga.jspm.io/npm:@teleporthq/teleport-component-generator@0.25.4/dist/cjs/index.js",
197+
"@teleporthq/teleport-plugin-css-modules": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-css-modules@0.25.4/dist/cjs/index.js",
198+
"@teleporthq/teleport-plugin-import-statements": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-import-statements@0.25.4/dist/cjs/index.js",
199+
"@teleporthq/teleport-plugin-jsx-inline-styles": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-inline-styles@0.25.4/dist/cjs/index.js",
200+
"@teleporthq/teleport-plugin-jsx-proptypes": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-proptypes@0.25.4/dist/cjs/index.js"
201+
},
202+
"https://ga.jspm.io/npm:@teleporthq/teleport-component-generator@0.20.3/": {
203+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js",
204+
"@teleporthq/teleport-uidl-validator": "https://ga.jspm.io/npm:@teleporthq/teleport-uidl-validator@0.20.3/dist/cjs/index.js"
205+
},
206+
"https://ga.jspm.io/npm:@teleporthq/teleport-component-generator@0.25.4/": {
207+
"@teleporthq/teleport-uidl-resolver": "https://ga.jspm.io/npm:@teleporthq/teleport-uidl-resolver@0.25.4/dist/cjs/index.js"
208+
},
209+
"https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.20.6/": {
210+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js"
211+
},
212+
"https://ga.jspm.io/npm:@teleporthq/teleport-plugin-css-modules@0.20.6/": {
213+
"@teleporthq/teleport-plugin-common": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.20.6/dist/cjs/index.js",
214+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js"
215+
},
216+
"https://ga.jspm.io/npm:@teleporthq/teleport-plugin-css@0.20.6/": {
217+
"@teleporthq/teleport-plugin-common": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.20.6/dist/cjs/index.js",
218+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js"
219+
},
220+
"https://ga.jspm.io/npm:@teleporthq/teleport-plugin-import-statements@0.20.6/": {
221+
"@teleporthq/teleport-plugin-common": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.20.6/dist/cjs/index.js"
222+
},
223+
"https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-head-config@0.20.6/": {
224+
"@teleporthq/teleport-plugin-common": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.20.6/dist/cjs/index.js"
225+
},
226+
"https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-inline-styles@0.20.6/": {
227+
"@teleporthq/teleport-plugin-common": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.20.6/dist/cjs/index.js",
228+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js"
229+
},
230+
"https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-proptypes@0.20.6/": {
231+
"@teleporthq/teleport-plugin-common": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.20.6/dist/cjs/index.js",
232+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js"
233+
},
234+
"https://ga.jspm.io/npm:@teleporthq/teleport-plugin-preact-base-component@0.20.6/": {
235+
"@teleporthq/teleport-plugin-common": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.20.6/dist/cjs/index.js",
236+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js"
237+
},
238+
"https://ga.jspm.io/npm:@teleporthq/teleport-plugin-react-app-routing@0.20.6/": {
239+
"@teleporthq/teleport-plugin-common": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.20.6/dist/cjs/index.js",
240+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js"
241+
},
242+
"https://ga.jspm.io/npm:@teleporthq/teleport-postprocessor-prettier-js@0.20.3/": {
243+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js"
244+
},
245+
"https://ga.jspm.io/npm:@teleporthq/teleport-project-generator-react@0.25.4/": {
246+
"@teleporthq/teleport-component-generator": "https://ga.jspm.io/npm:@teleporthq/teleport-component-generator@0.25.4/dist/cjs/index.js",
247+
"@teleporthq/teleport-plugin-import-statements": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-import-statements@0.25.4/dist/cjs/index.js",
248+
"@teleporthq/teleport-plugin-jsx-head-config": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-jsx-head-config@0.25.4/dist/cjs/index.js",
249+
"@teleporthq/teleport-plugin-react-app-routing": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-react-app-routing@0.25.4/dist/cjs/index.js",
250+
"@teleporthq/teleport-postprocessor-prettier-js": "https://ga.jspm.io/npm:@teleporthq/teleport-postprocessor-prettier-js@0.25.4/dist/cjs/index.js",
251+
"@teleporthq/teleport-project-generator": "https://ga.jspm.io/npm:@teleporthq/teleport-project-generator@0.25.4/dist/cjs/index.js"
252+
},
253+
"https://ga.jspm.io/npm:@teleporthq/teleport-project-generator@0.20.6/": {
254+
"@teleporthq/teleport-plugin-common": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-common@0.20.6/dist/cjs/index.js",
255+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js",
256+
"@teleporthq/teleport-uidl-builders": "https://ga.jspm.io/npm:@teleporthq/teleport-uidl-builders@0.20.3/dist/cjs/index.js",
257+
"@teleporthq/teleport-uidl-validator": "https://ga.jspm.io/npm:@teleporthq/teleport-uidl-validator@0.20.3/dist/cjs/index.js"
258+
},
259+
"https://ga.jspm.io/npm:@teleporthq/teleport-project-generator@0.25.4/": {
260+
"@teleporthq/teleport-component-generator": "https://ga.jspm.io/npm:@teleporthq/teleport-component-generator@0.25.4/dist/cjs/index.js",
261+
"@teleporthq/teleport-plugin-import-statements": "https://ga.jspm.io/npm:@teleporthq/teleport-plugin-import-statements@0.25.4/dist/cjs/index.js"
262+
},
263+
"https://ga.jspm.io/npm:@teleporthq/teleport-uidl-resolver@0.20.3/": {
264+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js"
265+
},
266+
"https://ga.jspm.io/npm:@teleporthq/teleport-uidl-validator@0.20.3/": {
267+
"@teleporthq/teleport-shared": "https://ga.jspm.io/npm:@teleporthq/teleport-shared@0.20.3/dist/cjs/index.js"
268+
},
188269
"https://ga.jspm.io/npm:basic-auth@2.0.1/": {
189270
"safe-buffer": "https://ga.jspm.io/npm:safe-buffer@5.1.2/index.js"
190271
},

test-server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import express from "express";
22
import morgan from "morgan";
3+
import chalk from 'chalk'
34
import { readFileSync } from "node:fs";
45
import { fileURLToPath } from "node:url";
56
import { join } from "node:path";
@@ -21,5 +22,5 @@ app.get("/map", (request, response) => {
2122
});
2223

2324
app.listen(3000, () => {
24-
console.log("Listen on the port 3000...");
25+
console.log(chalk.green("Listen on the port 3000..."));
2526
});

test.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1+
import * as TeleportProjectGeneratorPreact from "@teleporthq/teleport-project-generator-preact";
12
import * as TeleportProjectGeneratorReact from "@teleporthq/teleport-project-generator-react";
23
import * as TeleportTypes from "@teleporthq/teleport-types";
34
import * as chalk from "chalk";
5+
import * as express from "express";
6+
import * as morgan from "morgan";
47
import * as react from "react";
58
import * as reactDom from "react-dom";
69
import * as reactRouter from "react-router";
710
import * as reactRouterDom from "react-router-dom";
811

912
// Write main module code here, or as a separate file with a "src" attribute on the module script.
10-
console.log(
11-
TeleportProjectGeneratorReact,
12-
TeleportTypes,
13-
chalk,
14-
react,
15-
reactDom,
16-
reactRouter,
17-
reactRouterDom
18-
);
13+
console.log(TeleportProjectGeneratorPreact, TeleportProjectGeneratorReact, TeleportTypes, chalk, express, morgan, react, reactDom, reactRouter, reactRouterDom);
1914
console.log(chalk.default.green("Hello......."));

0 commit comments

Comments
 (0)