deno.land / x / deno2node@v1.6.0 / src / _transformations / specifiers.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import XR from "https://cdn.skypack.dev/xregexp@5.1.0?dts";
const path = /^\/[\w/.-]+$/;const scopedPackage = /^(?:@[\w.-]+\/)?[\w.-]+$/;const version = /^[^/?]+$/;
const services = [ XR.tag("x")`^npm: (${scopedPackage})(?:@${version})?(${path})?$`, XR.tag( "x", )`^https://cdn\.skypack\.dev/ (${scopedPackage})(?:@${version})?(${path})?\?`, XR.tag("x")`^https://esm\.sh/ (${scopedPackage})(?:@${version})?(${path})?$`, XR.tag("x")`^https://deno\.land/ std(?:@${version})?/node/([\w/]+)\.ts$`, XR.tag("x")`^https://nest\.land/ std/node/${version}/([\w/]+)\.ts$`,];
const transpileHttpsImport = (specifier: string) => { for (const service of services) { const match = service.exec(specifier); if (match === null) continue; const [, pkg, path = ""] = match; return pkg + path; } return specifier;};
const transpileRelativeImport = (specifier: string) => specifier .replace(/\.[jt]sx?$/i, ".js") .replace(/\.deno\.js$/i, ".node.js");
const isRelative = (specifier: string) => /^\.\.?\//.test(specifier);
export const transpileSpecifier = (specifier: string) => { if (isRelative(specifier)) return transpileRelativeImport(specifier); return transpileHttpsImport(specifier);};
deno2node

Version Info

Tagged at
a year ago