@tamagui/babel-plugin-fully-specified 1.125.14 → 1.125.15
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/dist/esm/commonjs.native.js +6 -7
- package/dist/esm/commonjs.native.js.map +6 -1
- package/dist/esm/index.native.js +69 -96
- package/dist/esm/index.native.js.map +6 -1
- package/package.json +1 -1
- package/dist/esm/commonjs.mjs +0 -47
- package/dist/esm/commonjs.mjs.map +0 -1
- package/dist/esm/index.mjs +0 -118
- package/dist/esm/index.mjs.map +0 -1
|
@@ -15,12 +15,9 @@ function fullySpecifyCommonJS(api) {
|
|
|
15
15
|
if (moduleSpecifier.startsWith(".") || moduleSpecifier.startsWith("/")) {
|
|
16
16
|
var filePath = state.file.opts.filename;
|
|
17
17
|
if (!filePath) return;
|
|
18
|
-
var fileDir = dirname(filePath),
|
|
19
|
-
cjsExtension = ".cjs",
|
|
20
|
-
jsExtension = ".js";
|
|
18
|
+
var fileDir = dirname(filePath), cjsExtension = ".cjs", jsExtension = ".js";
|
|
21
19
|
if (!extname(moduleSpecifier)) {
|
|
22
|
-
var resolvedPath = resolve(fileDir, moduleSpecifier),
|
|
23
|
-
newModuleSpecifier = moduleSpecifier;
|
|
20
|
+
var resolvedPath = resolve(fileDir, moduleSpecifier), newModuleSpecifier = moduleSpecifier;
|
|
24
21
|
if (isLocalDirectory(resolvedPath)) {
|
|
25
22
|
var indexPath = resolve(resolvedPath, "index" + jsExtension);
|
|
26
23
|
if (existsSync(indexPath)) {
|
|
@@ -44,5 +41,7 @@ function fullySpecifyCommonJS(api) {
|
|
|
44
41
|
function isLocalDirectory(absolutePath) {
|
|
45
42
|
return existsSync(absolutePath) && lstatSync(absolutePath).isDirectory();
|
|
46
43
|
}
|
|
47
|
-
export {
|
|
48
|
-
|
|
44
|
+
export {
|
|
45
|
+
fullySpecifyCommonJS as default
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=commonjs.js.map
|
|
@@ -1 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QU;AACZ;gBACF;cACF;YACF;UACF;QACF;MACF;IACF;EACF;AACF;AAEA,SAASC,iBAAiBI,cAAY;AACpC,SAAOpC,WAAWoC,YAAAA,KAAiBnC,UAAUmC,YAAAA,EAAcC,YAAW;AACxE;",
|
|
5
|
+
"names": ["existsSync", "lstatSync", "dirname", "extname", "resolve", "api", "assertVersion", "name", "visitor", "CallExpression", "path", "state", "callee", "get", "isIdentifier", "node", "arguments", "length", "arg", "type", "moduleSpecifier", "value", "startsWith", "filePath", "file", "opts", "filename", "fileDir", "cjsExtension", "jsExtension", "resolvedPath", "newModuleSpecifier", "isLocalDirectory", "indexPath", "endsWith", "filePathWithJs", "absolutePath", "isDirectory"]
|
|
6
|
+
}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -3,67 +3,61 @@ import { dirname, extname, resolve } from "node:path";
|
|
|
3
3
|
var DEFAULT_OPTIONS = {
|
|
4
4
|
ensureFileExists: !0,
|
|
5
5
|
esExtensionDefault: ".mjs",
|
|
6
|
-
tryExtensions: [
|
|
7
|
-
|
|
6
|
+
tryExtensions: [
|
|
7
|
+
".js"
|
|
8
|
+
],
|
|
9
|
+
esExtensions: [
|
|
10
|
+
".mjs"
|
|
11
|
+
]
|
|
8
12
|
};
|
|
9
13
|
function FullySpecified(api, rawOptions) {
|
|
10
14
|
api.assertVersion(7);
|
|
11
15
|
var options = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
filePath,
|
|
25
|
-
options
|
|
26
|
-
});
|
|
27
|
-
fullySpecifiedModuleSpecifier && (node.source.value = fullySpecifiedModuleSpecifier);
|
|
28
|
-
}
|
|
16
|
+
...DEFAULT_OPTIONS,
|
|
17
|
+
...rawOptions
|
|
18
|
+
}, importDeclarationVisitor = function(path, state) {
|
|
19
|
+
var filePath = state.file.opts.filename;
|
|
20
|
+
if (filePath) {
|
|
21
|
+
var { node } = path;
|
|
22
|
+
if (node.importKind !== "type") {
|
|
23
|
+
var originalModuleSpecifier = node.source.value, fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
|
|
24
|
+
filePath,
|
|
25
|
+
options
|
|
26
|
+
});
|
|
27
|
+
fullySpecifiedModuleSpecifier && (node.source.value = fullySpecifiedModuleSpecifier);
|
|
29
28
|
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
var source =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
options
|
|
44
|
-
});
|
|
45
|
-
fullySpecifiedModuleSpecifier && (source.value = fullySpecifiedModuleSpecifier);
|
|
46
|
-
}
|
|
29
|
+
}
|
|
30
|
+
}, exportDeclarationVisitor = function(path, state) {
|
|
31
|
+
var filePath = state.file.opts.filename;
|
|
32
|
+
if (filePath) {
|
|
33
|
+
var { node } = path;
|
|
34
|
+
if (node.exportKind !== "type") {
|
|
35
|
+
var source = node.source;
|
|
36
|
+
if (source) {
|
|
37
|
+
var originalModuleSpecifier = source.value, fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
|
|
38
|
+
filePath,
|
|
39
|
+
options
|
|
40
|
+
});
|
|
41
|
+
fullySpecifiedModuleSpecifier && (source.value = fullySpecifiedModuleSpecifier);
|
|
47
42
|
}
|
|
48
43
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
fullySpecifiedModuleSpecifier && (firstArgOfImportCall.value = fullySpecifiedModuleSpecifier);
|
|
63
|
-
}
|
|
44
|
+
}
|
|
45
|
+
}, importVisitor = function(path, state) {
|
|
46
|
+
var filePath = state.file.opts.filename;
|
|
47
|
+
if (filePath) {
|
|
48
|
+
var parent = path.parent;
|
|
49
|
+
if (parent.type === "CallExpression") {
|
|
50
|
+
var firstArgOfImportCall = parent.arguments[0];
|
|
51
|
+
if (firstArgOfImportCall.type === "StringLiteral") {
|
|
52
|
+
var originalModuleSpecifier = firstArgOfImportCall.value, fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
|
|
53
|
+
filePath,
|
|
54
|
+
options
|
|
55
|
+
});
|
|
56
|
+
fullySpecifiedModuleSpecifier && (firstArgOfImportCall.value = fullySpecifiedModuleSpecifier);
|
|
64
57
|
}
|
|
65
58
|
}
|
|
66
|
-
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
67
61
|
return {
|
|
68
62
|
name: "babel-plugin-fully-specified",
|
|
69
63
|
visitor: {
|
|
@@ -75,58 +69,34 @@ function FullySpecified(api, rawOptions) {
|
|
|
75
69
|
};
|
|
76
70
|
}
|
|
77
71
|
function getFullySpecifiedModuleSpecifier(originalModuleSpecifier, param) {
|
|
78
|
-
var {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
fileExt = extname(filePath),
|
|
83
|
-
fileDir = dirname(filePath),
|
|
84
|
-
isDirectory = isLocalDirectory(resolve(fileDir, originalModuleSpecifier)),
|
|
85
|
-
currentModuleExtension = extname(originalModuleSpecifier),
|
|
86
|
-
{
|
|
87
|
-
tryExtensions,
|
|
88
|
-
esExtensions,
|
|
89
|
-
esExtensionDefault,
|
|
90
|
-
ensureFileExists
|
|
91
|
-
} = options,
|
|
92
|
-
targetModule = evaluateTargetModule({
|
|
93
|
-
moduleSpecifier: originalModuleSpecifier,
|
|
94
|
-
filenameDirectory: fileDir,
|
|
95
|
-
filenameExtension: fileExt,
|
|
96
|
-
currentModuleExtension,
|
|
97
|
-
isDirectory,
|
|
98
|
-
tryExtensions,
|
|
99
|
-
esExtensions,
|
|
100
|
-
esExtensionDefault,
|
|
101
|
-
ensureFileExists
|
|
102
|
-
});
|
|
103
|
-
return targetModule === !1 ? null : targetModule;
|
|
104
|
-
}
|
|
105
|
-
function isLocalDirectory(absoluteDirectory) {
|
|
106
|
-
return existsSync(absoluteDirectory) && lstatSync(absoluteDirectory).isDirectory();
|
|
107
|
-
}
|
|
108
|
-
function evaluateTargetModule(param) {
|
|
109
|
-
var {
|
|
110
|
-
moduleSpecifier,
|
|
72
|
+
var { filePath, options } = param, fileExt = extname(filePath), fileDir = dirname(filePath), isDirectory = isLocalDirectory(resolve(fileDir, originalModuleSpecifier)), currentModuleExtension = extname(originalModuleSpecifier), { tryExtensions, esExtensions, esExtensionDefault, ensureFileExists } = options, targetModule = evaluateTargetModule({
|
|
73
|
+
moduleSpecifier: originalModuleSpecifier,
|
|
74
|
+
filenameDirectory: fileDir,
|
|
75
|
+
filenameExtension: fileExt,
|
|
111
76
|
currentModuleExtension,
|
|
112
77
|
isDirectory,
|
|
113
|
-
filenameDirectory,
|
|
114
|
-
filenameExtension,
|
|
115
78
|
tryExtensions,
|
|
116
79
|
esExtensions,
|
|
117
80
|
esExtensionDefault,
|
|
118
81
|
ensureFileExists
|
|
119
|
-
}
|
|
120
|
-
|
|
82
|
+
});
|
|
83
|
+
return targetModule === !1 ? null : targetModule;
|
|
84
|
+
}
|
|
85
|
+
function isLocalDirectory(absoluteDirectory) {
|
|
86
|
+
return existsSync(absoluteDirectory) && lstatSync(absoluteDirectory).isDirectory();
|
|
87
|
+
}
|
|
88
|
+
function evaluateTargetModule(param) {
|
|
89
|
+
var { moduleSpecifier, currentModuleExtension, isDirectory, filenameDirectory, filenameExtension, tryExtensions, esExtensions, esExtensionDefault, ensureFileExists } = param;
|
|
90
|
+
if (currentModuleExtension && !esExtensions.includes(currentModuleExtension))
|
|
91
|
+
return !1;
|
|
121
92
|
var targetFile = resolve(filenameDirectory, moduleSpecifier);
|
|
122
93
|
if (ensureFileExists) {
|
|
123
|
-
var _iteratorNormalCompletion = !0,
|
|
124
|
-
_didIteratorError = !1,
|
|
125
|
-
_iteratorError = void 0;
|
|
94
|
+
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
126
95
|
try {
|
|
127
96
|
for (var _iterator = tryExtensions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
128
97
|
var extension = _step.value;
|
|
129
|
-
if (existsSync(targetFile + extension))
|
|
98
|
+
if (existsSync(targetFile + extension))
|
|
99
|
+
return moduleSpecifier + esExtensionDefault;
|
|
130
100
|
}
|
|
131
101
|
} catch (err) {
|
|
132
102
|
_didIteratorError = !0, _iteratorError = err;
|
|
@@ -134,12 +104,15 @@ function evaluateTargetModule(param) {
|
|
|
134
104
|
try {
|
|
135
105
|
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
136
106
|
} finally {
|
|
137
|
-
if (_didIteratorError)
|
|
107
|
+
if (_didIteratorError)
|
|
108
|
+
throw _iteratorError;
|
|
138
109
|
}
|
|
139
110
|
}
|
|
140
111
|
isDirectory && !existsSync(resolve(filenameDirectory, currentModuleExtension ? moduleSpecifier : moduleSpecifier + esExtensionDefault)) && (moduleSpecifier = `${moduleSpecifier}/index`);
|
|
141
112
|
} else return esExtensions.includes(filenameExtension), moduleSpecifier + esExtensionDefault;
|
|
142
113
|
return !1;
|
|
143
114
|
}
|
|
144
|
-
export {
|
|
145
|
-
|
|
115
|
+
export {
|
|
116
|
+
FullySpecified as default
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Users/n8/tamagui/code/packages/babel-plugin-fully-specified/src/index.ts"],
|
|
4
|
+
"mappings": "AAAA,SAASA,YAAYC,iBAAiB;AACtC,SAASC,SAASC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;gBAAA;;;AAOL,IACEoC,eACA,CAAC3C,WACCI,QACE6C,mBACAJ,yBAAyBG,kBAAkBA,kBAAkBzC,kBAAAA,CAAAA,MAIjEyC,kBAAkB,GAAGA,eAAAA;EAEzB,MAAO,QAAIvC,aAAa2C,SAASF,iBAAAA,GACxBF,kBAAkBzC;AAK3B,SAAO;AACT;",
|
|
5
|
+
"names": ["existsSync", "lstatSync", "dirname", "extname", "resolve", "DEFAULT_OPTIONS", "ensureFileExists", "esExtensionDefault", "tryExtensions", "esExtensions", "api", "rawOptions", "assertVersion", "options", "importDeclarationVisitor", "path", "state", "filePath", "file", "opts", "filename", "node", "importKind", "originalModuleSpecifier", "source", "value", "fullySpecifiedModuleSpecifier", "getFullySpecifiedModuleSpecifier", "exportDeclarationVisitor", "exportKind", "importVisitor", "parent", "type", "firstArgOfImportCall", "arguments", "name", "visitor", "ImportDeclaration", "ExportNamedDeclaration", "ExportAllDeclaration", "Import", "fileExt", "fileDir", "isDirectory", "isLocalDirectory", "currentModuleExtension", "targetModule", "evaluateTargetModule", "moduleSpecifier", "filenameDirectory", "filenameExtension", "absoluteDirectory", "includes", "targetFile", "extension"]
|
|
6
|
+
}
|
package/package.json
CHANGED
package/dist/esm/commonjs.mjs
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { existsSync, lstatSync } from "node:fs";
|
|
2
|
-
import { dirname, extname, resolve } from "node:path";
|
|
3
|
-
function fullySpecifyCommonJS(api) {
|
|
4
|
-
return api.assertVersion(7), {
|
|
5
|
-
name: "babel-plugin-fully-specified-cjs",
|
|
6
|
-
visitor: {
|
|
7
|
-
CallExpression(path, state) {
|
|
8
|
-
if (path.get("callee").isIdentifier({
|
|
9
|
-
name: "require"
|
|
10
|
-
}) && path.node.arguments.length === 1) {
|
|
11
|
-
const arg = path.node.arguments[0];
|
|
12
|
-
if (arg.type === "StringLiteral") {
|
|
13
|
-
let moduleSpecifier = arg.value;
|
|
14
|
-
if (moduleSpecifier.startsWith(".") || moduleSpecifier.startsWith("/")) {
|
|
15
|
-
const filePath = state.file.opts.filename;
|
|
16
|
-
if (!filePath) return;
|
|
17
|
-
const fileDir = dirname(filePath),
|
|
18
|
-
cjsExtension = ".cjs",
|
|
19
|
-
jsExtension = ".js";
|
|
20
|
-
if (!extname(moduleSpecifier)) {
|
|
21
|
-
const resolvedPath = resolve(fileDir, moduleSpecifier);
|
|
22
|
-
let newModuleSpecifier = moduleSpecifier;
|
|
23
|
-
if (isLocalDirectory(resolvedPath)) {
|
|
24
|
-
const indexPath = resolve(resolvedPath, "index" + jsExtension);
|
|
25
|
-
if (existsSync(indexPath)) {
|
|
26
|
-
newModuleSpecifier.endsWith("/") || (newModuleSpecifier += "/"), newModuleSpecifier += "index" + cjsExtension, arg.value = newModuleSpecifier;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const filePathWithJs = resolvedPath + jsExtension;
|
|
31
|
-
if (existsSync(filePathWithJs)) {
|
|
32
|
-
newModuleSpecifier += cjsExtension, arg.value = newModuleSpecifier;
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function isLocalDirectory(absolutePath) {
|
|
44
|
-
return existsSync(absolutePath) && lstatSync(absolutePath).isDirectory();
|
|
45
|
-
}
|
|
46
|
-
export { fullySpecifyCommonJS as default };
|
|
47
|
-
//# sourceMappingURL=commonjs.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["existsSync","lstatSync","dirname","extname","resolve","fullySpecifyCommonJS","api","assertVersion","name","visitor","CallExpression","path","state","get","isIdentifier","node","arguments","length","arg","type","moduleSpecifier","value","startsWith","filePath","file","opts","filename","fileDir","cjsExtension","jsExtension","resolvedPath","newModuleSpecifier","isLocalDirectory","indexPath","endsWith","filePathWithJs","absolutePath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,CAAmBG,QAAA,CAAS,GAAG,MAClCH,kBAAA,IAAsB,MAExBA,kBAAA,IAAsB,UAAUH,YAAA,EAChCV,GAAA,CAAIG,KAAA,GAAQU,kBAAA;oBACZ;kBACF;gBACF;gBAGA,MAAMI,cAAA,GAAiBL,YAAA,GAAeD,WAAA;gBACtC,IAAI7B,UAAA,CAAWmC,cAAc,GAAG;kBAC9BJ,kBAAA,IAAsBH,YAAA,EACtBV,GAAA,CAAIG,KAAA,GAAQU,kBAAA;kBACZ;gBACF;cACF;YACF;UACF;QACF;MACF;IACF;EACF;AACF;AAEA,SAASC,iBAAiBI,YAAA,EAAc;EACtC,OAAOpC,UAAA,CAAWoC,YAAY,KAAKnC,SAAA,CAAUmC,YAAY,EAAEC,WAAA,CAAY;AACzE","ignoreList":[]}
|
package/dist/esm/index.mjs
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { existsSync, lstatSync } from "node:fs";
|
|
2
|
-
import { dirname, extname, resolve } from "node:path";
|
|
3
|
-
const DEFAULT_OPTIONS = {
|
|
4
|
-
ensureFileExists: !0,
|
|
5
|
-
esExtensionDefault: ".mjs",
|
|
6
|
-
tryExtensions: [".js"],
|
|
7
|
-
esExtensions: [".mjs"]
|
|
8
|
-
};
|
|
9
|
-
function FullySpecified(api, rawOptions) {
|
|
10
|
-
api.assertVersion(7);
|
|
11
|
-
const options = {
|
|
12
|
-
...DEFAULT_OPTIONS,
|
|
13
|
-
...rawOptions
|
|
14
|
-
},
|
|
15
|
-
importDeclarationVisitor = (path, state) => {
|
|
16
|
-
const filePath = state.file.opts.filename;
|
|
17
|
-
if (!filePath) return;
|
|
18
|
-
const {
|
|
19
|
-
node
|
|
20
|
-
} = path;
|
|
21
|
-
if (node.importKind === "type") return;
|
|
22
|
-
const originalModuleSpecifier = node.source.value,
|
|
23
|
-
fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
|
|
24
|
-
filePath,
|
|
25
|
-
options
|
|
26
|
-
});
|
|
27
|
-
fullySpecifiedModuleSpecifier && (node.source.value = fullySpecifiedModuleSpecifier);
|
|
28
|
-
},
|
|
29
|
-
exportDeclarationVisitor = (path, state) => {
|
|
30
|
-
const filePath = state.file.opts.filename;
|
|
31
|
-
if (!filePath) return;
|
|
32
|
-
const {
|
|
33
|
-
node
|
|
34
|
-
} = path;
|
|
35
|
-
if (node.exportKind === "type") return;
|
|
36
|
-
const source = node.source;
|
|
37
|
-
if (!source) return;
|
|
38
|
-
const originalModuleSpecifier = source.value,
|
|
39
|
-
fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
|
|
40
|
-
filePath,
|
|
41
|
-
options
|
|
42
|
-
});
|
|
43
|
-
fullySpecifiedModuleSpecifier && (source.value = fullySpecifiedModuleSpecifier);
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
name: "babel-plugin-fully-specified",
|
|
47
|
-
visitor: {
|
|
48
|
-
ImportDeclaration: importDeclarationVisitor,
|
|
49
|
-
ExportNamedDeclaration: exportDeclarationVisitor,
|
|
50
|
-
ExportAllDeclaration: exportDeclarationVisitor,
|
|
51
|
-
Import: (path, state) => {
|
|
52
|
-
const filePath = state.file.opts.filename;
|
|
53
|
-
if (!filePath) return;
|
|
54
|
-
const parent = path.parent;
|
|
55
|
-
if (parent.type !== "CallExpression") return;
|
|
56
|
-
const firstArgOfImportCall = parent.arguments[0];
|
|
57
|
-
if (firstArgOfImportCall.type !== "StringLiteral") return;
|
|
58
|
-
const originalModuleSpecifier = firstArgOfImportCall.value,
|
|
59
|
-
fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
|
|
60
|
-
filePath,
|
|
61
|
-
options
|
|
62
|
-
});
|
|
63
|
-
fullySpecifiedModuleSpecifier && (firstArgOfImportCall.value = fullySpecifiedModuleSpecifier);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
function getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
|
|
69
|
-
filePath,
|
|
70
|
-
options
|
|
71
|
-
}) {
|
|
72
|
-
const fileExt = extname(filePath),
|
|
73
|
-
fileDir = dirname(filePath),
|
|
74
|
-
isDirectory = isLocalDirectory(resolve(fileDir, originalModuleSpecifier)),
|
|
75
|
-
currentModuleExtension = extname(originalModuleSpecifier),
|
|
76
|
-
{
|
|
77
|
-
tryExtensions,
|
|
78
|
-
esExtensions,
|
|
79
|
-
esExtensionDefault,
|
|
80
|
-
ensureFileExists
|
|
81
|
-
} = options,
|
|
82
|
-
targetModule = evaluateTargetModule({
|
|
83
|
-
moduleSpecifier: originalModuleSpecifier,
|
|
84
|
-
filenameDirectory: fileDir,
|
|
85
|
-
filenameExtension: fileExt,
|
|
86
|
-
currentModuleExtension,
|
|
87
|
-
isDirectory,
|
|
88
|
-
tryExtensions,
|
|
89
|
-
esExtensions,
|
|
90
|
-
esExtensionDefault,
|
|
91
|
-
ensureFileExists
|
|
92
|
-
});
|
|
93
|
-
return targetModule === !1 ? null : targetModule;
|
|
94
|
-
}
|
|
95
|
-
function isLocalDirectory(absoluteDirectory) {
|
|
96
|
-
return existsSync(absoluteDirectory) && lstatSync(absoluteDirectory).isDirectory();
|
|
97
|
-
}
|
|
98
|
-
function evaluateTargetModule({
|
|
99
|
-
moduleSpecifier,
|
|
100
|
-
currentModuleExtension,
|
|
101
|
-
isDirectory,
|
|
102
|
-
filenameDirectory,
|
|
103
|
-
filenameExtension,
|
|
104
|
-
tryExtensions,
|
|
105
|
-
esExtensions,
|
|
106
|
-
esExtensionDefault,
|
|
107
|
-
ensureFileExists
|
|
108
|
-
}) {
|
|
109
|
-
if (currentModuleExtension && !esExtensions.includes(currentModuleExtension)) return !1;
|
|
110
|
-
const targetFile = resolve(filenameDirectory, moduleSpecifier);
|
|
111
|
-
if (ensureFileExists) {
|
|
112
|
-
for (const extension of tryExtensions) if (existsSync(targetFile + extension)) return moduleSpecifier + esExtensionDefault;
|
|
113
|
-
isDirectory && !existsSync(resolve(filenameDirectory, currentModuleExtension ? moduleSpecifier : moduleSpecifier + esExtensionDefault)) && (moduleSpecifier = `${moduleSpecifier}/index`);
|
|
114
|
-
} else return esExtensions.includes(filenameExtension), moduleSpecifier + esExtensionDefault;
|
|
115
|
-
return !1;
|
|
116
|
-
}
|
|
117
|
-
export { FullySpecified as default };
|
|
118
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["existsSync","lstatSync","dirname","extname","resolve","DEFAULT_OPTIONS","ensureFileExists","esExtensionDefault","tryExtensions","esExtensions","FullySpecified","api","rawOptions","assertVersion","options","importDeclarationVisitor","path","state","filePath","file","opts","filename","node","importKind","originalModuleSpecifier","source","value","fullySpecifiedModuleSpecifier","getFullySpecifiedModuleSpecifier","exportDeclarationVisitor","exportKind","name","visitor","ImportDeclaration","ExportNamedDeclaration","ExportAllDeclaration","Import","parent","type","firstArgOfImportCall","arguments","fileExt","fileDir","isDirectory","isLocalDirectory","currentModuleExtension","targetModule","evaluateTargetModule","moduleSpecifier","filenameDirectory","filenameExtension","absoluteDirectory","includes","targetFile","extension"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAA,EAAYC,SAAA,QAAiB;AACtC,SAASC,OAAA,EAASC,OAAA,EAASC,OAAA,QAAe;AAmB1C,MAAMC,eAAA,GAAkB;EACtBC,gBAAA,EAAkB;EAClBC,kBAAA,EAAoB;EACpBC,aAAA,EAAe,CAAC,KAAK;EACrBC,YAAA,EAAc,CAAC,MAAM;AACvB;AAEe,SAARC,eACLC,GAAA,EACAC,UAAA,EACW;EACXD,GAAA,CAAIE,aAAA,CAAc,CAAC;EAEnB,MAAMC,OAAA,GAAU;MAAE,GAAGT,eAAA;MAAiB,GAAGO;IAAW;IAG9CG,wBAAA,GAA2BA,CAC/BC,IAAA,EACAC,KAAA,KACG;MACH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