@tamagui/babel-plugin-fully-specified 2.0.0-rc.0 → 2.0.0-rc.0-1769998500160
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/package.json +14 -16
- package/permanent/cjs/commonjs.js +73 -47
- package/permanent/cjs/commonjs.mjs +83 -56
- package/permanent/cjs/index.js +157 -119
- package/permanent/cjs/index.mjs +153 -111
- package/permanent/esm/commonjs.js +43 -34
- package/permanent/esm/commonjs.mjs +45 -36
- package/permanent/esm/index.js +116 -100
- package/permanent/esm/index.mjs +100 -80
package/package.json
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/babel-plugin-fully-specified",
|
|
3
|
-
"version": "2.0.0-rc.0",
|
|
3
|
+
"version": "2.0.0-rc.0-1769998500160",
|
|
4
|
+
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
|
+
"license": "MIT",
|
|
4
6
|
"source": "src/index.ts",
|
|
5
|
-
"main": "permanent/cjs/index.js",
|
|
6
|
-
"module": "permanent/esm/index.mjs",
|
|
7
7
|
"files": [
|
|
8
8
|
"src",
|
|
9
9
|
"types",
|
|
10
10
|
"permanent"
|
|
11
11
|
],
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"access": "public"
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"lint": "biome check src",
|
|
18
|
-
"lint:fix": "biome check --write src",
|
|
19
|
-
"test": "vitest --run"
|
|
20
|
-
},
|
|
12
|
+
"main": "permanent/cjs/index.js",
|
|
13
|
+
"module": "permanent/esm/index.mjs",
|
|
21
14
|
"exports": {
|
|
22
15
|
".": {
|
|
23
16
|
"types": "./types/index.d.ts",
|
|
@@ -33,12 +26,17 @@
|
|
|
33
26
|
"require": "./permanent/cjs/commonjs.js"
|
|
34
27
|
}
|
|
35
28
|
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "vitest --run"
|
|
34
|
+
},
|
|
36
35
|
"dependencies": {
|
|
37
36
|
"@babel/core": "^7.25.2"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
39
|
"@babel/types": "^7.25.4",
|
|
41
|
-
"vitest": "
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
}
|
|
40
|
+
"vitest": "4.0.4"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,60 +1,86 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
1
|
+
var __defProp = Object.defineProperty
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 })
|
|
7
|
+
},
|
|
8
|
+
__copyProps = (to, from, except, desc) => {
|
|
9
|
+
if ((from && typeof from == 'object') || typeof from == 'function')
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) &&
|
|
12
|
+
key !== except &&
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
16
|
+
})
|
|
17
|
+
return to
|
|
18
|
+
}
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: !0 }), mod)
|
|
20
|
+
var commonjs_exports = {}
|
|
16
21
|
__export(commonjs_exports, {
|
|
17
|
-
default: () => fullySpecifyCommonJS
|
|
18
|
-
})
|
|
19
|
-
module.exports = __toCommonJS(commonjs_exports)
|
|
20
|
-
var import_node_fs = require(
|
|
22
|
+
default: () => fullySpecifyCommonJS,
|
|
23
|
+
})
|
|
24
|
+
module.exports = __toCommonJS(commonjs_exports)
|
|
25
|
+
var import_node_fs = require('node:fs'),
|
|
26
|
+
import_node_path = require('node:path')
|
|
21
27
|
function fullySpecifyCommonJS(api, options) {
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
return (
|
|
29
|
+
api.assertVersion(7),
|
|
30
|
+
{
|
|
31
|
+
name: 'babel-plugin-fully-specified-cjs',
|
|
32
|
+
visitor: {
|
|
33
|
+
CallExpression(path, state) {
|
|
34
|
+
if (
|
|
35
|
+
path.get('callee').isIdentifier({ name: 'require' }) &&
|
|
36
|
+
path.node.arguments.length === 1
|
|
37
|
+
) {
|
|
38
|
+
const arg = path.node.arguments[0]
|
|
39
|
+
if (arg.type === 'StringLiteral') {
|
|
40
|
+
let moduleSpecifier = arg.value
|
|
41
|
+
if (moduleSpecifier.startsWith('.') || moduleSpecifier.startsWith('/')) {
|
|
42
|
+
const filePath = state.file.opts.filename
|
|
43
|
+
if (!filePath) return
|
|
44
|
+
const fileDir = (0, import_node_path.dirname)(filePath),
|
|
45
|
+
cjsExtension = options.esExtensionDefault || '.cjs',
|
|
46
|
+
jsExtension = '.js'
|
|
47
|
+
if (!(0, import_node_path.extname)(moduleSpecifier)) {
|
|
48
|
+
const resolvedPath = (0, import_node_path.resolve)(
|
|
49
|
+
fileDir,
|
|
50
|
+
moduleSpecifier
|
|
51
|
+
)
|
|
52
|
+
let newModuleSpecifier = moduleSpecifier
|
|
53
|
+
if (isLocalDirectory(resolvedPath)) {
|
|
54
|
+
const indexPath = (0, import_node_path.resolve)(
|
|
55
|
+
resolvedPath,
|
|
56
|
+
'index' + jsExtension
|
|
57
|
+
)
|
|
58
|
+
if ((0, import_node_fs.existsSync)(indexPath)) {
|
|
59
|
+
;(newModuleSpecifier.endsWith('/') || (newModuleSpecifier += '/'),
|
|
60
|
+
(newModuleSpecifier += 'index' + cjsExtension),
|
|
61
|
+
(arg.value = newModuleSpecifier))
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const filePathWithJs = resolvedPath + jsExtension
|
|
66
|
+
if ((0, import_node_fs.existsSync)(filePathWithJs)) {
|
|
67
|
+
;((newModuleSpecifier += cjsExtension),
|
|
68
|
+
(arg.value = newModuleSpecifier))
|
|
69
|
+
return
|
|
42
70
|
}
|
|
43
|
-
}
|
|
44
|
-
const filePathWithJs = resolvedPath + jsExtension;
|
|
45
|
-
if ((0, import_node_fs.existsSync)(filePathWithJs)) {
|
|
46
|
-
newModuleSpecifier += cjsExtension, arg.value = newModuleSpecifier;
|
|
47
|
-
return;
|
|
48
71
|
}
|
|
49
72
|
}
|
|
50
73
|
}
|
|
51
74
|
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
75
|
+
},
|
|
76
|
+
},
|
|
54
77
|
}
|
|
55
|
-
|
|
78
|
+
)
|
|
56
79
|
}
|
|
57
80
|
function isLocalDirectory(absolutePath) {
|
|
58
|
-
return (
|
|
81
|
+
return (
|
|
82
|
+
(0, import_node_fs.existsSync)(absolutePath) &&
|
|
83
|
+
(0, import_node_fs.lstatSync)(absolutePath).isDirectory()
|
|
84
|
+
)
|
|
59
85
|
}
|
|
60
86
|
//# sourceMappingURL=commonjs.js.map
|
|
@@ -1,71 +1,98 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
1
|
+
var __defProp = Object.defineProperty
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: !0,
|
|
10
|
+
})
|
|
10
11
|
},
|
|
11
12
|
__copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from ==
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
if ((from && typeof from == 'object') || typeof from == 'function')
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
!__hasOwnProp.call(to, key) &&
|
|
16
|
+
key !== except &&
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
20
|
+
})
|
|
21
|
+
return to
|
|
22
|
+
}
|
|
23
|
+
var __toCommonJS = (mod) =>
|
|
24
|
+
__copyProps(
|
|
25
|
+
__defProp({}, '__esModule', {
|
|
26
|
+
value: !0,
|
|
27
|
+
}),
|
|
28
|
+
mod
|
|
29
|
+
)
|
|
30
|
+
var commonjs_exports = {}
|
|
22
31
|
__export(commonjs_exports, {
|
|
23
|
-
default: () => fullySpecifyCommonJS
|
|
24
|
-
})
|
|
25
|
-
module.exports = __toCommonJS(commonjs_exports)
|
|
26
|
-
var import_node_fs = require(
|
|
27
|
-
import_node_path = require(
|
|
32
|
+
default: () => fullySpecifyCommonJS,
|
|
33
|
+
})
|
|
34
|
+
module.exports = __toCommonJS(commonjs_exports)
|
|
35
|
+
var import_node_fs = require('node:fs'),
|
|
36
|
+
import_node_path = require('node:path')
|
|
28
37
|
function fullySpecifyCommonJS(api, options) {
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
38
|
+
return (
|
|
39
|
+
api.assertVersion(7),
|
|
40
|
+
{
|
|
41
|
+
name: 'babel-plugin-fully-specified-cjs',
|
|
42
|
+
visitor: {
|
|
43
|
+
CallExpression(path, state) {
|
|
44
|
+
if (
|
|
45
|
+
path.get('callee').isIdentifier({
|
|
46
|
+
name: 'require',
|
|
47
|
+
}) &&
|
|
48
|
+
path.node.arguments.length === 1
|
|
49
|
+
) {
|
|
50
|
+
const arg = path.node.arguments[0]
|
|
51
|
+
if (arg.type === 'StringLiteral') {
|
|
52
|
+
let moduleSpecifier = arg.value
|
|
53
|
+
if (moduleSpecifier.startsWith('.') || moduleSpecifier.startsWith('/')) {
|
|
54
|
+
const filePath = state.file.opts.filename
|
|
55
|
+
if (!filePath) return
|
|
56
|
+
const fileDir = (0, import_node_path.dirname)(filePath),
|
|
57
|
+
cjsExtension = options.esExtensionDefault || '.cjs',
|
|
58
|
+
jsExtension = '.js'
|
|
59
|
+
if (!(0, import_node_path.extname)(moduleSpecifier)) {
|
|
60
|
+
const resolvedPath = (0, import_node_path.resolve)(
|
|
61
|
+
fileDir,
|
|
62
|
+
moduleSpecifier
|
|
63
|
+
)
|
|
64
|
+
let newModuleSpecifier = moduleSpecifier
|
|
65
|
+
if (isLocalDirectory(resolvedPath)) {
|
|
66
|
+
const indexPath = (0, import_node_path.resolve)(
|
|
67
|
+
resolvedPath,
|
|
68
|
+
'index' + jsExtension
|
|
69
|
+
)
|
|
70
|
+
if ((0, import_node_fs.existsSync)(indexPath)) {
|
|
71
|
+
;(newModuleSpecifier.endsWith('/') || (newModuleSpecifier += '/'),
|
|
72
|
+
(newModuleSpecifier += 'index' + cjsExtension),
|
|
73
|
+
(arg.value = newModuleSpecifier))
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const filePathWithJs = resolvedPath + jsExtension
|
|
78
|
+
if ((0, import_node_fs.existsSync)(filePathWithJs)) {
|
|
79
|
+
;((newModuleSpecifier += cjsExtension),
|
|
80
|
+
(arg.value = newModuleSpecifier))
|
|
81
|
+
return
|
|
53
82
|
}
|
|
54
|
-
}
|
|
55
|
-
const filePathWithJs = resolvedPath + jsExtension;
|
|
56
|
-
if ((0, import_node_fs.existsSync)(filePathWithJs)) {
|
|
57
|
-
newModuleSpecifier += cjsExtension, arg.value = newModuleSpecifier;
|
|
58
|
-
return;
|
|
59
83
|
}
|
|
60
84
|
}
|
|
61
85
|
}
|
|
62
86
|
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
87
|
+
},
|
|
88
|
+
},
|
|
65
89
|
}
|
|
66
|
-
|
|
90
|
+
)
|
|
67
91
|
}
|
|
68
92
|
function isLocalDirectory(absolutePath) {
|
|
69
|
-
return (
|
|
93
|
+
return (
|
|
94
|
+
(0, import_node_fs.existsSync)(absolutePath) &&
|
|
95
|
+
(0, import_node_fs.lstatSync)(absolutePath).isDirectory()
|
|
96
|
+
)
|
|
70
97
|
}
|
|
71
98
|
//# sourceMappingURL=commonjs.mjs.map
|
package/permanent/cjs/index.js
CHANGED
|
@@ -1,127 +1,161 @@
|
|
|
1
|
-
var __create = Object.create
|
|
2
|
-
var __defProp = Object.defineProperty
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
1
|
+
var __create = Object.create
|
|
2
|
+
var __defProp = Object.defineProperty
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty
|
|
6
7
|
var __export = (target, all) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 })
|
|
9
|
+
},
|
|
10
|
+
__copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from == 'object') || typeof from == 'function')
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) &&
|
|
14
|
+
key !== except &&
|
|
15
|
+
__defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
18
|
+
})
|
|
19
|
+
return to
|
|
20
|
+
}
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (
|
|
22
|
+
(target = mod != null ? __create(__getProtoOf(mod)) : {}),
|
|
23
|
+
__copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule
|
|
29
|
+
? __defProp(target, 'default', { value: mod, enumerable: !0 })
|
|
30
|
+
: target,
|
|
31
|
+
mod
|
|
32
|
+
)
|
|
33
|
+
),
|
|
34
|
+
__toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: !0 }), mod)
|
|
35
|
+
var index_exports = {}
|
|
24
36
|
__export(index_exports, {
|
|
25
|
-
default: () => FullySpecified
|
|
26
|
-
})
|
|
27
|
-
module.exports = __toCommonJS(index_exports)
|
|
28
|
-
var import_node_fs = require(
|
|
37
|
+
default: () => FullySpecified,
|
|
38
|
+
})
|
|
39
|
+
module.exports = __toCommonJS(index_exports)
|
|
40
|
+
var import_node_fs = require('node:fs'),
|
|
41
|
+
import_node_path = require('node:path'),
|
|
42
|
+
t = __toESM(require('@babel/types'))
|
|
29
43
|
const DEFAULT_OPTIONS = {
|
|
30
44
|
ensureFileExists: !0,
|
|
31
|
-
esExtensionDefault:
|
|
32
|
-
tryExtensions: [
|
|
33
|
-
esExtensions: [
|
|
34
|
-
convertProcessEnvToImportMetaEnv: !1
|
|
35
|
-
}
|
|
45
|
+
esExtensionDefault: '.mjs',
|
|
46
|
+
tryExtensions: ['.js'],
|
|
47
|
+
esExtensions: ['.mjs'],
|
|
48
|
+
convertProcessEnvToImportMetaEnv: !1,
|
|
49
|
+
}
|
|
36
50
|
function FullySpecified(api, rawOptions) {
|
|
37
|
-
api.assertVersion(7)
|
|
38
|
-
const options = { ...DEFAULT_OPTIONS, ...rawOptions },
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
originalModuleSpecifier,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
51
|
+
api.assertVersion(7)
|
|
52
|
+
const options = { ...DEFAULT_OPTIONS, ...rawOptions },
|
|
53
|
+
importDeclarationVisitor = (path, state) => {
|
|
54
|
+
const filePath = state.file.opts.filename
|
|
55
|
+
if (!filePath) return
|
|
56
|
+
const { node } = path
|
|
57
|
+
if (node.importKind === 'type') return
|
|
58
|
+
const originalModuleSpecifier = node.source.value,
|
|
59
|
+
fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(
|
|
60
|
+
originalModuleSpecifier,
|
|
61
|
+
{
|
|
62
|
+
filePath,
|
|
63
|
+
options,
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
fullySpecifiedModuleSpecifier && (node.source.value = fullySpecifiedModuleSpecifier)
|
|
67
|
+
},
|
|
68
|
+
exportDeclarationVisitor = (path, state) => {
|
|
69
|
+
const filePath = state.file.opts.filename
|
|
70
|
+
if (!filePath) return
|
|
71
|
+
const { node } = path
|
|
72
|
+
if (node.exportKind === 'type') return
|
|
73
|
+
const source = node.source
|
|
74
|
+
if (!source) return
|
|
75
|
+
const originalModuleSpecifier = source.value,
|
|
76
|
+
fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(
|
|
77
|
+
originalModuleSpecifier,
|
|
78
|
+
{
|
|
79
|
+
filePath,
|
|
80
|
+
options,
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
fullySpecifiedModuleSpecifier && (source.value = fullySpecifiedModuleSpecifier)
|
|
84
|
+
}
|
|
67
85
|
return {
|
|
68
|
-
name:
|
|
86
|
+
name: 'babel-plugin-fully-specified',
|
|
69
87
|
visitor: {
|
|
70
88
|
ImportDeclaration: importDeclarationVisitor,
|
|
71
89
|
ExportNamedDeclaration: exportDeclarationVisitor,
|
|
72
90
|
ExportAllDeclaration: exportDeclarationVisitor,
|
|
73
91
|
Import: (path, state) => {
|
|
74
|
-
const filePath = state.file.opts.filename
|
|
75
|
-
if (!filePath) return
|
|
76
|
-
const parent = path.parent
|
|
77
|
-
if (parent.type !==
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
const filePath = state.file.opts.filename
|
|
93
|
+
if (!filePath) return
|
|
94
|
+
const parent = path.parent
|
|
95
|
+
if (parent.type !== 'CallExpression') return
|
|
96
|
+
const firstArgOfImportCall = parent.arguments[0]
|
|
97
|
+
if (firstArgOfImportCall.type !== 'StringLiteral') return
|
|
98
|
+
const originalModuleSpecifier = firstArgOfImportCall.value,
|
|
99
|
+
fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(
|
|
100
|
+
originalModuleSpecifier,
|
|
101
|
+
{
|
|
102
|
+
filePath,
|
|
103
|
+
options,
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
fullySpecifiedModuleSpecifier &&
|
|
107
|
+
(firstArgOfImportCall.value = fullySpecifiedModuleSpecifier)
|
|
90
108
|
},
|
|
91
109
|
MemberExpression: (path) => {
|
|
92
|
-
if (!options.convertProcessEnvToImportMetaEnv) return
|
|
93
|
-
const { node } = path
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
110
|
+
if (!options.convertProcessEnvToImportMetaEnv) return
|
|
111
|
+
const { node } = path
|
|
112
|
+
if (
|
|
113
|
+
node.object.type === 'MemberExpression' &&
|
|
114
|
+
node.object.object.type === 'Identifier' &&
|
|
115
|
+
node.object.object.name === 'process' &&
|
|
116
|
+
node.object.property.type === 'Identifier' &&
|
|
117
|
+
node.object.property.name === 'env'
|
|
118
|
+
) {
|
|
119
|
+
if (node.property.type === 'Identifier' && node.property.name === 'NODE_ENV')
|
|
120
|
+
return
|
|
97
121
|
node.object = t.memberExpression(
|
|
98
|
-
t.metaProperty(t.identifier(
|
|
99
|
-
t.identifier(
|
|
100
|
-
)
|
|
122
|
+
t.metaProperty(t.identifier('import'), t.identifier('meta')),
|
|
123
|
+
t.identifier('env')
|
|
124
|
+
)
|
|
101
125
|
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}
|
|
105
129
|
}
|
|
106
|
-
function getFullySpecifiedModuleSpecifier(
|
|
107
|
-
|
|
108
|
-
options
|
|
109
|
-
|
|
110
|
-
const fileExt = (0, import_node_path.extname)(filePath),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
tryExtensions,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
130
|
+
function getFullySpecifiedModuleSpecifier(
|
|
131
|
+
originalModuleSpecifier,
|
|
132
|
+
{ filePath, options }
|
|
133
|
+
) {
|
|
134
|
+
const fileExt = (0, import_node_path.extname)(filePath),
|
|
135
|
+
fileDir = (0, import_node_path.dirname)(filePath),
|
|
136
|
+
isDirectory = isLocalDirectory(
|
|
137
|
+
(0, import_node_path.resolve)(fileDir, originalModuleSpecifier)
|
|
138
|
+
),
|
|
139
|
+
currentModuleExtension = (0, import_node_path.extname)(originalModuleSpecifier),
|
|
140
|
+
{ tryExtensions, esExtensions, esExtensionDefault, ensureFileExists } = options,
|
|
141
|
+
targetModule = evaluateTargetModule({
|
|
142
|
+
moduleSpecifier: originalModuleSpecifier,
|
|
143
|
+
filenameDirectory: fileDir,
|
|
144
|
+
filenameExtension: fileExt,
|
|
145
|
+
currentModuleExtension,
|
|
146
|
+
isDirectory,
|
|
147
|
+
tryExtensions,
|
|
148
|
+
esExtensions,
|
|
149
|
+
esExtensionDefault,
|
|
150
|
+
ensureFileExists,
|
|
151
|
+
})
|
|
152
|
+
return targetModule === !1 ? null : targetModule
|
|
122
153
|
}
|
|
123
154
|
function isLocalDirectory(absoluteDirectory) {
|
|
124
|
-
return (
|
|
155
|
+
return (
|
|
156
|
+
(0, import_node_fs.existsSync)(absoluteDirectory) &&
|
|
157
|
+
(0, import_node_fs.lstatSync)(absoluteDirectory).isDirectory()
|
|
158
|
+
)
|
|
125
159
|
}
|
|
126
160
|
function evaluateTargetModule({
|
|
127
161
|
moduleSpecifier,
|
|
@@ -132,22 +166,26 @@ function evaluateTargetModule({
|
|
|
132
166
|
tryExtensions,
|
|
133
167
|
esExtensions,
|
|
134
168
|
esExtensionDefault,
|
|
135
|
-
ensureFileExists
|
|
169
|
+
ensureFileExists,
|
|
136
170
|
}) {
|
|
137
|
-
if (currentModuleExtension && !esExtensions.includes(currentModuleExtension))
|
|
138
|
-
|
|
139
|
-
const targetFile = (0, import_node_path.resolve)(filenameDirectory, moduleSpecifier);
|
|
171
|
+
if (currentModuleExtension && !esExtensions.includes(currentModuleExtension)) return !1
|
|
172
|
+
const targetFile = (0, import_node_path.resolve)(filenameDirectory, moduleSpecifier)
|
|
140
173
|
if (ensureFileExists) {
|
|
141
174
|
for (const extension of tryExtensions)
|
|
142
175
|
if ((0, import_node_fs.existsSync)(targetFile + extension))
|
|
143
|
-
return moduleSpecifier + esExtensionDefault
|
|
144
|
-
isDirectory &&
|
|
145
|
-
(0,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
176
|
+
return moduleSpecifier + esExtensionDefault
|
|
177
|
+
isDirectory &&
|
|
178
|
+
!(0, import_node_fs.existsSync)(
|
|
179
|
+
(0, import_node_path.resolve)(
|
|
180
|
+
filenameDirectory,
|
|
181
|
+
currentModuleExtension ? moduleSpecifier : moduleSpecifier + esExtensionDefault
|
|
182
|
+
)
|
|
183
|
+
) &&
|
|
184
|
+
(moduleSpecifier = `${moduleSpecifier}/index`)
|
|
185
|
+
} else
|
|
186
|
+
return (
|
|
187
|
+
esExtensions.includes(filenameExtension), moduleSpecifier + esExtensionDefault
|
|
188
|
+
)
|
|
189
|
+
return !1
|
|
152
190
|
}
|
|
153
191
|
//# sourceMappingURL=index.js.map
|