smartbundle 0.10.0 → 0.10.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__compiled__/cjs/src/tasks/buildTypesTask/callTypescript.js +3 -2
- package/__compiled__/cjs/src/tasks/buildTypesTask/callTypescript.js.map +1 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/inlineExtensions.d.ts +2 -0
- package/__compiled__/cjs/src/tasks/buildTypesTask/inlineExtensions.js +28 -0
- package/__compiled__/cjs/src/tasks/buildTypesTask/inlineExtensions.js.map +1 -0
- package/__compiled__/esm/src/tasks/buildTypesTask/callTypescript.mjs +3 -2
- package/__compiled__/esm/src/tasks/buildTypesTask/callTypescript.mjs.map +1 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/inlineExtensions.d.mts +2 -0
- package/__compiled__/esm/src/tasks/buildTypesTask/inlineExtensions.mjs +28 -0
- package/__compiled__/esm/src/tasks/buildTypesTask/inlineExtensions.mjs.map +1 -0
- package/package.json +1 -1
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
3
|
const path = require("node:path");
|
4
4
|
const fs = require("node:fs");
|
5
|
+
const inlineExtensions = require("./inlineExtensions.js");
|
5
6
|
function _interopNamespaceDefault(e) {
|
6
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
7
8
|
if (e) {
|
@@ -62,10 +63,10 @@ async function callTypescript({
|
|
62
63
|
const esmFinalPath = finalEsmPath.replace(/\.d\.ts$/, ".d.mts");
|
63
64
|
sourceToDtsMap.set(esmFinalPath, sourceFileName);
|
64
65
|
fs__namespace.mkdirSync(path__namespace.dirname(esmFinalPath), { recursive: true });
|
65
|
-
fs__namespace.writeFileSync(esmFinalPath, data);
|
66
|
+
fs__namespace.writeFileSync(esmFinalPath, inlineExtensions.inlineExtensionsMjs(data));
|
66
67
|
const finalCjsPath = path__namespace.join(outDir, "__compiled__", "cjs", relativePath);
|
67
68
|
const cjsFinalPath = finalCjsPath.replace(/\.d\.ts$/, ".d.ts");
|
68
|
-
fs__namespace.writeFileSync(cjsFinalPath, data);
|
69
|
+
fs__namespace.writeFileSync(cjsFinalPath, inlineExtensions.inlineExtensionsCjs(data));
|
69
70
|
sourceToDtsMap.set(cjsFinalPath, sourceFileName);
|
70
71
|
});
|
71
72
|
return sourceToDtsMap;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"callTypescript.js","sources":["../../../../../../src/tasks/buildTypesTask/callTypescript.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs\";\n\ntype BuildTypesOptions = {\n ts: typeof import(\"typescript\");\n sourceDir: string;\n files: string[];\n outDir: string;\n};\n\nexport async function callTypescript({\n ts,\n sourceDir,\n files,\n outDir,\n}: BuildTypesOptions) {\n const configPath = path.join(sourceDir, \"tsconfig.json\");\n const configFile = ts.readConfigFile(configPath, (path) =>\n // https://github.com/XaveScor/bobrik/issues/22\n fs.readFileSync(path, \"utf-8\"),\n );\n\n const parsedCommandLine = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n sourceDir,\n {\n declaration: true,\n emitDeclarationOnly: true,\n strict: false,\n strictNullChecks: false,\n strictFunctionTypes: false,\n strictPropertyInitialization: false,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n // https://github.com/XaveScor/bobrik/issues/22#issuecomment-2308552352\n noEmit: false,\n },\n configPath,\n );\n\n const host = ts.createCompilerHost(parsedCommandLine.options);\n\n const sourceToDtsMap = new Map<string, string>();\n const program = ts.createProgram(files, parsedCommandLine.options, host);\n program.emit(undefined, (fileName, data) => {\n // .d.ts for cjs because \"type\": \"commonjs\" in package.json\n // .d.mts for esm\n const relativePath = path.relative(sourceDir, fileName);\n const sourceFileName = fileName.replace(/\\.d\\.ts$/, \".ts\"); // Assuming source files have .ts extension\n\n const finalEsmPath = path.join(outDir, \"__compiled__\", \"esm\", relativePath);\n const esmFinalPath = finalEsmPath.replace(/\\.d\\.ts$/, \".d.mts\");\n sourceToDtsMap.set(esmFinalPath, sourceFileName);\n fs.mkdirSync(path.dirname(esmFinalPath), { recursive: true });\n fs.writeFileSync(esmFinalPath, data);\n\n const finalCjsPath = path.join(outDir, \"__compiled__\", \"cjs\", relativePath);\n const cjsFinalPath = finalCjsPath.replace(/\\.d\\.ts$/, \".d.ts\");\n fs.writeFileSync(cjsFinalPath, data);\n sourceToDtsMap.set(cjsFinalPath, sourceFileName);\n });\n\n return sourceToDtsMap;\n}\n"],"names":["path","fs"],"mappings":"
|
1
|
+
{"version":3,"file":"callTypescript.js","sources":["../../../../../../src/tasks/buildTypesTask/callTypescript.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs\";\nimport { inlineExtensionsMjs, inlineExtensionsCjs } from \"./inlineExtensions.js\";\n\ntype BuildTypesOptions = {\n ts: typeof import(\"typescript\");\n sourceDir: string;\n files: string[];\n outDir: string;\n};\n\n// It needs for vscode. It cannot resolve the import/export if it has no extension\nconst reexportRegex = /export { (.+?) } from \"(.+)\"/g;\nfunction inlineExtensionMjs(content: string) {}\n\nexport async function callTypescript({\n ts,\n sourceDir,\n files,\n outDir,\n}: BuildTypesOptions) {\n const configPath = path.join(sourceDir, \"tsconfig.json\");\n const configFile = ts.readConfigFile(configPath, (path) =>\n // https://github.com/XaveScor/bobrik/issues/22\n fs.readFileSync(path, \"utf-8\"),\n );\n\n const parsedCommandLine = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n sourceDir,\n {\n declaration: true,\n emitDeclarationOnly: true,\n strict: false,\n strictNullChecks: false,\n strictFunctionTypes: false,\n strictPropertyInitialization: false,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n // https://github.com/XaveScor/bobrik/issues/22#issuecomment-2308552352\n noEmit: false,\n },\n configPath,\n );\n\n const host = ts.createCompilerHost(parsedCommandLine.options);\n\n const sourceToDtsMap = new Map<string, string>();\n const program = ts.createProgram(files, parsedCommandLine.options, host);\n program.emit(undefined, (fileName, data) => {\n // .d.ts for cjs because \"type\": \"commonjs\" in package.json\n // .d.mts for esm\n const relativePath = path.relative(sourceDir, fileName);\n const sourceFileName = fileName.replace(/\\.d\\.ts$/, \".ts\"); // Assuming source files have .ts extension\n\n const finalEsmPath = path.join(outDir, \"__compiled__\", \"esm\", relativePath);\n const esmFinalPath = finalEsmPath.replace(/\\.d\\.ts$/, \".d.mts\");\n sourceToDtsMap.set(esmFinalPath, sourceFileName);\n fs.mkdirSync(path.dirname(esmFinalPath), { recursive: true });\n fs.writeFileSync(esmFinalPath, inlineExtensionsMjs(data));\n\n const finalCjsPath = path.join(outDir, \"__compiled__\", \"cjs\", relativePath);\n const cjsFinalPath = finalCjsPath.replace(/\\.d\\.ts$/, \".d.ts\");\n fs.writeFileSync(cjsFinalPath, inlineExtensionsCjs(data));\n sourceToDtsMap.set(cjsFinalPath, sourceFileName);\n });\n\n return sourceToDtsMap;\n}\n"],"names":["path","fs","inlineExtensionsMjs","inlineExtensionsCjs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAeA,eAAsB,eAAe;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsB;AACpB,QAAM,aAAaA,gBAAK,KAAK,WAAW,eAAe;AACvD,QAAM,aAAa,GAAG;AAAA,IAAe;AAAA,IAAY,CAACA;AAAAA;AAAAA,MAEhDC,cAAG,aAAaD,OAAM,OAAO;AAAA;AAAA,EAAA;AAG/B,QAAM,oBAAoB,GAAG;AAAA,IAC3B,WAAW;AAAA,IACX,GAAG;AAAA,IACH;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,QAAQ;AAAA,MACR,kBAAkB;AAAA,MAClB,qBAAqB;AAAA,MACrB,8BAA8B;AAAA,MAC9B,cAAc;AAAA,MACd,qBAAqB;AAAA;AAAA,MAErB,QAAQ;AAAA,IACV;AAAA,IACA;AAAA,EAAA;AAGF,QAAM,OAAO,GAAG,mBAAmB,kBAAkB,OAAO;AAEtD,QAAA,qCAAqB;AAC3B,QAAM,UAAU,GAAG,cAAc,OAAO,kBAAkB,SAAS,IAAI;AACvE,UAAQ,KAAK,QAAW,CAAC,UAAU,SAAS;AAG1C,UAAM,eAAeA,gBAAK,SAAS,WAAW,QAAQ;AACtD,UAAM,iBAAiB,SAAS,QAAQ,YAAY,KAAK;AAEzD,UAAM,eAAeA,gBAAK,KAAK,QAAQ,gBAAgB,OAAO,YAAY;AAC1E,UAAM,eAAe,aAAa,QAAQ,YAAY,QAAQ;AAC/C,mBAAA,IAAI,cAAc,cAAc;AAC5CC,kBAAA,UAAUD,gBAAK,QAAQ,YAAY,GAAG,EAAE,WAAW,MAAM;AAC5DC,kBAAG,cAAc,cAAcC,iBAAAA,oBAAoB,IAAI,CAAC;AAExD,UAAM,eAAeF,gBAAK,KAAK,QAAQ,gBAAgB,OAAO,YAAY;AAC1E,UAAM,eAAe,aAAa,QAAQ,YAAY,OAAO;AAC7DC,kBAAG,cAAc,cAAcE,iBAAAA,oBAAoB,IAAI,CAAC;AACzC,mBAAA,IAAI,cAAc,cAAc;AAAA,EAAA,CAChD;AAEM,SAAA;AACT;;"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
const importExportRegex = /(?:import|export)\s*(?:type\s*)?(?:(?:{\s*.+?\s*}|\*|[^{}\s]+)\s*from\s*)?["'](.+)["']/g;
|
4
|
+
const dynamicImportRegex = /import\(["'](.+)["']\)/g;
|
5
|
+
function addExtension(content, regex, ext) {
|
6
|
+
return content.replace(regex, (match, p1) => {
|
7
|
+
if (!p1.startsWith(".")) {
|
8
|
+
return match;
|
9
|
+
}
|
10
|
+
if (!p1.endsWith(".cjs") && !p1.endsWith(".mjs") && !p1.endsWith(".js")) {
|
11
|
+
return match.replace(p1, `${p1}${ext}`);
|
12
|
+
}
|
13
|
+
return match;
|
14
|
+
});
|
15
|
+
}
|
16
|
+
function inlineExtensionsMjs(content) {
|
17
|
+
content = addExtension(content, importExportRegex, ".mjs");
|
18
|
+
content = addExtension(content, dynamicImportRegex, ".mjs");
|
19
|
+
return content;
|
20
|
+
}
|
21
|
+
function inlineExtensionsCjs(content) {
|
22
|
+
content = addExtension(content, importExportRegex, ".cjs");
|
23
|
+
content = addExtension(content, dynamicImportRegex, ".cjs");
|
24
|
+
return content;
|
25
|
+
}
|
26
|
+
exports.inlineExtensionsCjs = inlineExtensionsCjs;
|
27
|
+
exports.inlineExtensionsMjs = inlineExtensionsMjs;
|
28
|
+
//# sourceMappingURL=inlineExtensions.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"inlineExtensions.js","sources":["../../../../../../src/tasks/buildTypesTask/inlineExtensions.ts"],"sourcesContent":["// It needs for VSCode. It cannot resolve the import/export if it has no extension\n\nconst importExportRegex = /(?:import|export)\\s*(?:type\\s*)?(?:(?:{\\s*.+?\\s*}|\\*|[^{}\\s]+)\\s*from\\s*)?[\"'](.+)[\"']/g;\nconst dynamicImportRegex = /import\\([\"'](.+)[\"']\\)/g;\n\nfunction addExtension(content: string, regex: RegExp, ext: string) {\n return content.replace(regex, (match, p1) => {\n if (!p1.startsWith(\".\")) {\n return match;\n }\n if (!p1.endsWith(\".cjs\") && !p1.endsWith(\".mjs\") && !p1.endsWith(\".js\")) {\n return match.replace(p1, `${p1}${ext}`);\n }\n return match;\n });\n}\n\nexport function inlineExtensionsMjs(content: string) {\n content = addExtension(content, importExportRegex, \".mjs\");\n content = addExtension(content, dynamicImportRegex, \".mjs\");\n return content;\n}\n\nexport function inlineExtensionsCjs(content: string) {\n content = addExtension(content, importExportRegex, \".cjs\");\n content = addExtension(content, dynamicImportRegex, \".cjs\");\n return content;\n}\n"],"names":[],"mappings":";;AAEA,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAE3B,SAAS,aAAa,SAAiB,OAAe,KAAa;AACjE,SAAO,QAAQ,QAAQ,OAAO,CAAC,OAAO,OAAO;AAC3C,QAAI,CAAC,GAAG,WAAW,GAAG,GAAG;AAChB,aAAA;AAAA,IACT;AACA,QAAI,CAAC,GAAG,SAAS,MAAM,KAAK,CAAC,GAAG,SAAS,MAAM,KAAK,CAAC,GAAG,SAAS,KAAK,GAAG;AACvE,aAAO,MAAM,QAAQ,IAAI,GAAG,EAAE,GAAG,GAAG,EAAE;AAAA,IACxC;AACO,WAAA;AAAA,EAAA,CACR;AACH;AAEO,SAAS,oBAAoB,SAAiB;AACzC,YAAA,aAAa,SAAS,mBAAmB,MAAM;AAC/C,YAAA,aAAa,SAAS,oBAAoB,MAAM;AACnD,SAAA;AACT;AAEO,SAAS,oBAAoB,SAAiB;AACzC,YAAA,aAAa,SAAS,mBAAmB,MAAM;AAC/C,YAAA,aAAa,SAAS,oBAAoB,MAAM;AACnD,SAAA;AACT;;;"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as path from "node:path";
|
2
2
|
import * as fs from "node:fs";
|
3
|
+
import { inlineExtensionsMjs, inlineExtensionsCjs } from "./inlineExtensions.mjs";
|
3
4
|
async function callTypescript({
|
4
5
|
ts,
|
5
6
|
sourceDir,
|
@@ -42,10 +43,10 @@ async function callTypescript({
|
|
42
43
|
const esmFinalPath = finalEsmPath.replace(/\.d\.ts$/, ".d.mts");
|
43
44
|
sourceToDtsMap.set(esmFinalPath, sourceFileName);
|
44
45
|
fs.mkdirSync(path.dirname(esmFinalPath), { recursive: true });
|
45
|
-
fs.writeFileSync(esmFinalPath, data);
|
46
|
+
fs.writeFileSync(esmFinalPath, inlineExtensionsMjs(data));
|
46
47
|
const finalCjsPath = path.join(outDir, "__compiled__", "cjs", relativePath);
|
47
48
|
const cjsFinalPath = finalCjsPath.replace(/\.d\.ts$/, ".d.ts");
|
48
|
-
fs.writeFileSync(cjsFinalPath, data);
|
49
|
+
fs.writeFileSync(cjsFinalPath, inlineExtensionsCjs(data));
|
49
50
|
sourceToDtsMap.set(cjsFinalPath, sourceFileName);
|
50
51
|
});
|
51
52
|
return sourceToDtsMap;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"callTypescript.mjs","sources":["../../../../../../src/tasks/buildTypesTask/callTypescript.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs\";\n\ntype BuildTypesOptions = {\n ts: typeof import(\"typescript\");\n sourceDir: string;\n files: string[];\n outDir: string;\n};\n\nexport async function callTypescript({\n ts,\n sourceDir,\n files,\n outDir,\n}: BuildTypesOptions) {\n const configPath = path.join(sourceDir, \"tsconfig.json\");\n const configFile = ts.readConfigFile(configPath, (path) =>\n // https://github.com/XaveScor/bobrik/issues/22\n fs.readFileSync(path, \"utf-8\"),\n );\n\n const parsedCommandLine = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n sourceDir,\n {\n declaration: true,\n emitDeclarationOnly: true,\n strict: false,\n strictNullChecks: false,\n strictFunctionTypes: false,\n strictPropertyInitialization: false,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n // https://github.com/XaveScor/bobrik/issues/22#issuecomment-2308552352\n noEmit: false,\n },\n configPath,\n );\n\n const host = ts.createCompilerHost(parsedCommandLine.options);\n\n const sourceToDtsMap = new Map<string, string>();\n const program = ts.createProgram(files, parsedCommandLine.options, host);\n program.emit(undefined, (fileName, data) => {\n // .d.ts for cjs because \"type\": \"commonjs\" in package.json\n // .d.mts for esm\n const relativePath = path.relative(sourceDir, fileName);\n const sourceFileName = fileName.replace(/\\.d\\.ts$/, \".ts\"); // Assuming source files have .ts extension\n\n const finalEsmPath = path.join(outDir, \"__compiled__\", \"esm\", relativePath);\n const esmFinalPath = finalEsmPath.replace(/\\.d\\.ts$/, \".d.mts\");\n sourceToDtsMap.set(esmFinalPath, sourceFileName);\n fs.mkdirSync(path.dirname(esmFinalPath), { recursive: true });\n fs.writeFileSync(esmFinalPath, data);\n\n const finalCjsPath = path.join(outDir, \"__compiled__\", \"cjs\", relativePath);\n const cjsFinalPath = finalCjsPath.replace(/\\.d\\.ts$/, \".d.ts\");\n fs.writeFileSync(cjsFinalPath, data);\n sourceToDtsMap.set(cjsFinalPath, sourceFileName);\n });\n\n return sourceToDtsMap;\n}\n"],"names":["path"],"mappings":"
|
1
|
+
{"version":3,"file":"callTypescript.mjs","sources":["../../../../../../src/tasks/buildTypesTask/callTypescript.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs\";\nimport { inlineExtensionsMjs, inlineExtensionsCjs } from \"./inlineExtensions.js\";\n\ntype BuildTypesOptions = {\n ts: typeof import(\"typescript\");\n sourceDir: string;\n files: string[];\n outDir: string;\n};\n\n// It needs for vscode. It cannot resolve the import/export if it has no extension\nconst reexportRegex = /export { (.+?) } from \"(.+)\"/g;\nfunction inlineExtensionMjs(content: string) {}\n\nexport async function callTypescript({\n ts,\n sourceDir,\n files,\n outDir,\n}: BuildTypesOptions) {\n const configPath = path.join(sourceDir, \"tsconfig.json\");\n const configFile = ts.readConfigFile(configPath, (path) =>\n // https://github.com/XaveScor/bobrik/issues/22\n fs.readFileSync(path, \"utf-8\"),\n );\n\n const parsedCommandLine = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n sourceDir,\n {\n declaration: true,\n emitDeclarationOnly: true,\n strict: false,\n strictNullChecks: false,\n strictFunctionTypes: false,\n strictPropertyInitialization: false,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n // https://github.com/XaveScor/bobrik/issues/22#issuecomment-2308552352\n noEmit: false,\n },\n configPath,\n );\n\n const host = ts.createCompilerHost(parsedCommandLine.options);\n\n const sourceToDtsMap = new Map<string, string>();\n const program = ts.createProgram(files, parsedCommandLine.options, host);\n program.emit(undefined, (fileName, data) => {\n // .d.ts for cjs because \"type\": \"commonjs\" in package.json\n // .d.mts for esm\n const relativePath = path.relative(sourceDir, fileName);\n const sourceFileName = fileName.replace(/\\.d\\.ts$/, \".ts\"); // Assuming source files have .ts extension\n\n const finalEsmPath = path.join(outDir, \"__compiled__\", \"esm\", relativePath);\n const esmFinalPath = finalEsmPath.replace(/\\.d\\.ts$/, \".d.mts\");\n sourceToDtsMap.set(esmFinalPath, sourceFileName);\n fs.mkdirSync(path.dirname(esmFinalPath), { recursive: true });\n fs.writeFileSync(esmFinalPath, inlineExtensionsMjs(data));\n\n const finalCjsPath = path.join(outDir, \"__compiled__\", \"cjs\", relativePath);\n const cjsFinalPath = finalCjsPath.replace(/\\.d\\.ts$/, \".d.ts\");\n fs.writeFileSync(cjsFinalPath, inlineExtensionsCjs(data));\n sourceToDtsMap.set(cjsFinalPath, sourceFileName);\n });\n\n return sourceToDtsMap;\n}\n"],"names":["path"],"mappings":";;;AAeA,eAAsB,eAAe;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsB;AACpB,QAAM,aAAa,KAAK,KAAK,WAAW,eAAe;AACvD,QAAM,aAAa,GAAG;AAAA,IAAe;AAAA,IAAY,CAACA;AAAAA;AAAAA,MAEhD,GAAG,aAAaA,OAAM,OAAO;AAAA;AAAA,EAAA;AAG/B,QAAM,oBAAoB,GAAG;AAAA,IAC3B,WAAW;AAAA,IACX,GAAG;AAAA,IACH;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,QAAQ;AAAA,MACR,kBAAkB;AAAA,MAClB,qBAAqB;AAAA,MACrB,8BAA8B;AAAA,MAC9B,cAAc;AAAA,MACd,qBAAqB;AAAA;AAAA,MAErB,QAAQ;AAAA,IACV;AAAA,IACA;AAAA,EAAA;AAGF,QAAM,OAAO,GAAG,mBAAmB,kBAAkB,OAAO;AAEtD,QAAA,qCAAqB;AAC3B,QAAM,UAAU,GAAG,cAAc,OAAO,kBAAkB,SAAS,IAAI;AACvE,UAAQ,KAAK,QAAW,CAAC,UAAU,SAAS;AAG1C,UAAM,eAAe,KAAK,SAAS,WAAW,QAAQ;AACtD,UAAM,iBAAiB,SAAS,QAAQ,YAAY,KAAK;AAEzD,UAAM,eAAe,KAAK,KAAK,QAAQ,gBAAgB,OAAO,YAAY;AAC1E,UAAM,eAAe,aAAa,QAAQ,YAAY,QAAQ;AAC/C,mBAAA,IAAI,cAAc,cAAc;AAC5C,OAAA,UAAU,KAAK,QAAQ,YAAY,GAAG,EAAE,WAAW,MAAM;AAC5D,OAAG,cAAc,cAAc,oBAAoB,IAAI,CAAC;AAExD,UAAM,eAAe,KAAK,KAAK,QAAQ,gBAAgB,OAAO,YAAY;AAC1E,UAAM,eAAe,aAAa,QAAQ,YAAY,OAAO;AAC7D,OAAG,cAAc,cAAc,oBAAoB,IAAI,CAAC;AACzC,mBAAA,IAAI,cAAc,cAAc;AAAA,EAAA,CAChD;AAEM,SAAA;AACT;"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
const importExportRegex = /(?:import|export)\s*(?:type\s*)?(?:(?:{\s*.+?\s*}|\*|[^{}\s]+)\s*from\s*)?["'](.+)["']/g;
|
2
|
+
const dynamicImportRegex = /import\(["'](.+)["']\)/g;
|
3
|
+
function addExtension(content, regex, ext) {
|
4
|
+
return content.replace(regex, (match, p1) => {
|
5
|
+
if (!p1.startsWith(".")) {
|
6
|
+
return match;
|
7
|
+
}
|
8
|
+
if (!p1.endsWith(".cjs") && !p1.endsWith(".mjs") && !p1.endsWith(".js")) {
|
9
|
+
return match.replace(p1, `${p1}${ext}`);
|
10
|
+
}
|
11
|
+
return match;
|
12
|
+
});
|
13
|
+
}
|
14
|
+
function inlineExtensionsMjs(content) {
|
15
|
+
content = addExtension(content, importExportRegex, ".mjs");
|
16
|
+
content = addExtension(content, dynamicImportRegex, ".mjs");
|
17
|
+
return content;
|
18
|
+
}
|
19
|
+
function inlineExtensionsCjs(content) {
|
20
|
+
content = addExtension(content, importExportRegex, ".cjs");
|
21
|
+
content = addExtension(content, dynamicImportRegex, ".cjs");
|
22
|
+
return content;
|
23
|
+
}
|
24
|
+
export {
|
25
|
+
inlineExtensionsCjs,
|
26
|
+
inlineExtensionsMjs
|
27
|
+
};
|
28
|
+
//# sourceMappingURL=inlineExtensions.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"inlineExtensions.mjs","sources":["../../../../../../src/tasks/buildTypesTask/inlineExtensions.ts"],"sourcesContent":["// It needs for VSCode. It cannot resolve the import/export if it has no extension\n\nconst importExportRegex = /(?:import|export)\\s*(?:type\\s*)?(?:(?:{\\s*.+?\\s*}|\\*|[^{}\\s]+)\\s*from\\s*)?[\"'](.+)[\"']/g;\nconst dynamicImportRegex = /import\\([\"'](.+)[\"']\\)/g;\n\nfunction addExtension(content: string, regex: RegExp, ext: string) {\n return content.replace(regex, (match, p1) => {\n if (!p1.startsWith(\".\")) {\n return match;\n }\n if (!p1.endsWith(\".cjs\") && !p1.endsWith(\".mjs\") && !p1.endsWith(\".js\")) {\n return match.replace(p1, `${p1}${ext}`);\n }\n return match;\n });\n}\n\nexport function inlineExtensionsMjs(content: string) {\n content = addExtension(content, importExportRegex, \".mjs\");\n content = addExtension(content, dynamicImportRegex, \".mjs\");\n return content;\n}\n\nexport function inlineExtensionsCjs(content: string) {\n content = addExtension(content, importExportRegex, \".cjs\");\n content = addExtension(content, dynamicImportRegex, \".cjs\");\n return content;\n}\n"],"names":[],"mappings":"AAEA,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAE3B,SAAS,aAAa,SAAiB,OAAe,KAAa;AACjE,SAAO,QAAQ,QAAQ,OAAO,CAAC,OAAO,OAAO;AAC3C,QAAI,CAAC,GAAG,WAAW,GAAG,GAAG;AAChB,aAAA;AAAA,IACT;AACA,QAAI,CAAC,GAAG,SAAS,MAAM,KAAK,CAAC,GAAG,SAAS,MAAM,KAAK,CAAC,GAAG,SAAS,KAAK,GAAG;AACvE,aAAO,MAAM,QAAQ,IAAI,GAAG,EAAE,GAAG,GAAG,EAAE;AAAA,IACxC;AACO,WAAA;AAAA,EAAA,CACR;AACH;AAEO,SAAS,oBAAoB,SAAiB;AACzC,YAAA,aAAa,SAAS,mBAAmB,MAAM;AAC/C,YAAA,aAAa,SAAS,oBAAoB,MAAM;AACnD,SAAA;AACT;AAEO,SAAS,oBAAoB,SAAiB;AACzC,YAAA,aAAa,SAAS,mBAAmB,MAAM;AAC/C,YAAA,aAAa,SAAS,oBAAoB,MAAM;AACnD,SAAA;AACT;"}
|