@tamagui/babel-plugin-fully-specified 2.7.7 → 3.0.0-beta.637.1
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 +3 -1
- package/permanent/cjs/commonjs.js +68 -59
- package/permanent/cjs/commonjs.js.map +1 -1
- package/permanent/esm/commonjs.mjs +50 -41
- package/permanent/esm/commonjs.mjs.map +1 -1
- package/src/commonjs.ts +11 -2
- package/types/commonjs.d.ts +5 -0
- package/types/index.d.ts +14 -0
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/babel-plugin-fully-specified",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.637.1",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"source": "src/index.ts",
|
|
7
|
+
"types": "./types/index.d.ts",
|
|
7
8
|
"files": [
|
|
8
9
|
"src",
|
|
9
10
|
"types",
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"access": "public"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
37
|
+
"build": "tamagui-build",
|
|
36
38
|
"test": "vitest --run"
|
|
37
39
|
},
|
|
38
40
|
"dependencies": {
|
|
@@ -3,81 +3,90 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
return to
|
|
6
|
+
for (var name in all) __defProp(target, name, { get: all[name], enumerable: true })
|
|
7
|
+
}
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if ((from && typeof from === 'object') || typeof from === 'function') {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
15
|
+
})
|
|
18
16
|
}
|
|
19
|
-
|
|
17
|
+
return to
|
|
18
|
+
}
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: true }), mod)
|
|
20
20
|
var commonjs_exports = {}
|
|
21
21
|
__export(commonjs_exports, {
|
|
22
22
|
default: () => fullySpecifyCommonJS,
|
|
23
23
|
})
|
|
24
24
|
module.exports = __toCommonJS(commonjs_exports)
|
|
25
|
-
var import_node_fs = require('node:fs')
|
|
26
|
-
|
|
25
|
+
var import_node_fs = require('node:fs')
|
|
26
|
+
var import_node_path = require('node:path')
|
|
27
27
|
function fullySpecifyCommonJS(api, options) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
28
|
+
api.assertVersion(7)
|
|
29
|
+
return {
|
|
30
|
+
name: 'babel-plugin-fully-specified-cjs',
|
|
31
|
+
visitor: {
|
|
32
|
+
CallExpression(path, state) {
|
|
33
|
+
const callee = path.get('callee')
|
|
34
|
+
if (
|
|
35
|
+
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
|
+
const cjsExtension = options.esExtensionDefault || '.cjs'
|
|
46
|
+
const jsExtension = '.js'
|
|
47
|
+
const specifierExtension = (0, import_node_path.extname)(moduleSpecifier)
|
|
48
|
+
const hasModuleExtension = [
|
|
49
|
+
'.js',
|
|
50
|
+
'.cjs',
|
|
51
|
+
'.mjs',
|
|
52
|
+
'.json',
|
|
53
|
+
'.node',
|
|
54
|
+
].includes(specifierExtension)
|
|
55
|
+
if (!hasModuleExtension) {
|
|
56
|
+
const resolvedPath = (0, import_node_path.resolve)(
|
|
57
|
+
fileDir,
|
|
58
|
+
moduleSpecifier
|
|
59
|
+
)
|
|
60
|
+
let newModuleSpecifier = moduleSpecifier
|
|
61
|
+
if (isLocalDirectory(resolvedPath)) {
|
|
62
|
+
const indexPath = (0, import_node_path.resolve)(
|
|
63
|
+
resolvedPath,
|
|
64
|
+
'index' + jsExtension
|
|
51
65
|
)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
66
|
+
if ((0, import_node_fs.existsSync)(indexPath)) {
|
|
67
|
+
if (!newModuleSpecifier.endsWith('/')) {
|
|
68
|
+
newModuleSpecifier += '/'
|
|
63
69
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
(0, import_node_fs.existsSync)(resolvedPath + jsExtension) ||
|
|
67
|
-
(0, import_node_fs.existsSync)(resolvedPath + cjsExtension)
|
|
68
|
-
) {
|
|
69
|
-
;((newModuleSpecifier += cjsExtension),
|
|
70
|
-
(arg.value = newModuleSpecifier))
|
|
70
|
+
newModuleSpecifier += 'index' + cjsExtension
|
|
71
|
+
arg.value = newModuleSpecifier
|
|
71
72
|
return
|
|
72
73
|
}
|
|
73
74
|
}
|
|
75
|
+
if (
|
|
76
|
+
(0, import_node_fs.existsSync)(resolvedPath + jsExtension) ||
|
|
77
|
+
(0, import_node_fs.existsSync)(resolvedPath + cjsExtension)
|
|
78
|
+
) {
|
|
79
|
+
newModuleSpecifier += cjsExtension
|
|
80
|
+
arg.value = newModuleSpecifier
|
|
81
|
+
return
|
|
82
|
+
}
|
|
74
83
|
}
|
|
75
84
|
}
|
|
76
85
|
}
|
|
77
|
-
}
|
|
86
|
+
}
|
|
78
87
|
},
|
|
79
|
-
}
|
|
80
|
-
|
|
88
|
+
},
|
|
89
|
+
}
|
|
81
90
|
}
|
|
82
91
|
function isLocalDirectory(absolutePath) {
|
|
83
92
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commonjs.ts"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsC;AACtC,uBAA0C;AAE3B,SAAR,qBACL,KACA,SAGiB;AACjB,MAAI,cAAc,CAAC;AAEnB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,MACP,eAAe,MAAM,OAAO;AAC1B,cAAM,SAAS,KAAK,IAAI,QAAQ;AAEhC,YACE,OAAO,aAAa,EAAE,MAAM,UAAU,CAAC,KACvC,KAAK,KAAK,UAAU,WAAW,GAC/B;AACA,gBAAM,MAAM,KAAK,KAAK,UAAU,CAAC;AACjC,cAAI,IAAI,SAAS,iBAAiB;AAChC,gBAAI,kBAAkB,IAAI;AAG1B,gBAAI,gBAAgB,WAAW,GAAG,KAAK,gBAAgB,WAAW,GAAG,GAAG;AACtE,oBAAM,WAAW,MAAM,KAAK,KAAK;AACjC,kBAAI,CAAC,SAAU;AAEf,oBAAM,cAAU,0BAAQ,QAAQ;AAChC,oBAAM,eAAe,QAAQ,sBAAsB;AACnD,oBAAM,cAAc;AAIpB,oBAAM,yBAAqB,0BAAQ,eAAe;AAClD,oBAAM,qBAAqB;AAAA,gBACzB;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cACF,EAAE,SAAS,kBAAkB;AAC7B,kBAAI,CAAC,oBAAoB;AACvB,sBAAM,mBAAe,0BAAQ,SAAS,eAAe;AACrD,oBAAI,qBAAqB;AAGzB,oBAAI,iBAAiB,YAAY,GAAG;AAClC,wBAAM,gBAAY,0BAAQ,cAAc,UAAU,WAAW;AAC7D,0BAAI,2BAAW,SAAS,GAAG;AAEzB,wBAAI,CAAC,mBAAmB,SAAS,GAAG,GAAG;AACrC,4CAAsB;AAAA,oBACxB;AACA,0CAAsB,UAAU;AAChC,wBAAI,QAAQ;AACZ;AAAA,kBACF;AAAA,gBACF;AAGA,wBACE,2BAAW,eAAe,WAAW,SACrC,2BAAW,eAAe,YAAY,GACtC;AACA,wCAAsB;AACtB,sBAAI,QAAQ;AACZ;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,iBAAiB,cAA+B;AACvD,aAAO,2BAAW,YAAY,SAAK,0BAAU,YAAY,EAAE,YAAY;AACzE;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,55 +1,64 @@
|
|
|
1
1
|
import { existsSync, lstatSync } from 'node:fs'
|
|
2
2
|
import { dirname, extname, resolve } from 'node:path'
|
|
3
3
|
function fullySpecifyCommonJS(api, options) {
|
|
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
|
-
|
|
4
|
+
api.assertVersion(7)
|
|
5
|
+
return {
|
|
6
|
+
name: 'babel-plugin-fully-specified-cjs',
|
|
7
|
+
visitor: {
|
|
8
|
+
CallExpression(path, state) {
|
|
9
|
+
const callee = path.get('callee')
|
|
10
|
+
if (
|
|
11
|
+
callee.isIdentifier({
|
|
12
|
+
name: 'require',
|
|
13
|
+
}) &&
|
|
14
|
+
path.node.arguments.length === 1
|
|
15
|
+
) {
|
|
16
|
+
const arg = path.node.arguments[0]
|
|
17
|
+
if (arg.type === 'StringLiteral') {
|
|
18
|
+
let moduleSpecifier = arg.value
|
|
19
|
+
if (moduleSpecifier.startsWith('.') || moduleSpecifier.startsWith('/')) {
|
|
20
|
+
const filePath = state.file.opts.filename
|
|
21
|
+
if (!filePath) return
|
|
22
|
+
const fileDir = dirname(filePath)
|
|
23
|
+
const cjsExtension = options.esExtensionDefault || '.cjs'
|
|
24
|
+
const jsExtension = '.js'
|
|
25
|
+
const specifierExtension = extname(moduleSpecifier)
|
|
26
|
+
const hasModuleExtension = [
|
|
27
|
+
'.js',
|
|
28
|
+
'.cjs',
|
|
29
|
+
'.mjs',
|
|
30
|
+
'.json',
|
|
31
|
+
'.node',
|
|
32
|
+
].includes(specifierExtension)
|
|
33
|
+
if (!hasModuleExtension) {
|
|
34
|
+
const resolvedPath = resolve(fileDir, moduleSpecifier)
|
|
35
|
+
let newModuleSpecifier = moduleSpecifier
|
|
36
|
+
if (isLocalDirectory(resolvedPath)) {
|
|
37
|
+
const indexPath = resolve(resolvedPath, 'index' + jsExtension)
|
|
38
|
+
if (existsSync(indexPath)) {
|
|
39
|
+
if (!newModuleSpecifier.endsWith('/')) {
|
|
40
|
+
newModuleSpecifier += '/'
|
|
35
41
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
existsSync(resolvedPath + jsExtension) ||
|
|
39
|
-
existsSync(resolvedPath + cjsExtension)
|
|
40
|
-
) {
|
|
41
|
-
;((newModuleSpecifier += cjsExtension),
|
|
42
|
-
(arg.value = newModuleSpecifier))
|
|
42
|
+
newModuleSpecifier += 'index' + cjsExtension
|
|
43
|
+
arg.value = newModuleSpecifier
|
|
43
44
|
return
|
|
44
45
|
}
|
|
45
46
|
}
|
|
47
|
+
if (
|
|
48
|
+
existsSync(resolvedPath + jsExtension) ||
|
|
49
|
+
existsSync(resolvedPath + cjsExtension)
|
|
50
|
+
) {
|
|
51
|
+
newModuleSpecifier += cjsExtension
|
|
52
|
+
arg.value = newModuleSpecifier
|
|
53
|
+
return
|
|
54
|
+
}
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
57
|
}
|
|
49
|
-
}
|
|
58
|
+
}
|
|
50
59
|
},
|
|
51
|
-
}
|
|
52
|
-
|
|
60
|
+
},
|
|
61
|
+
}
|
|
53
62
|
}
|
|
54
63
|
function isLocalDirectory(absolutePath) {
|
|
55
64
|
return existsSync(absolutePath) && lstatSync(absolutePath).isDirectory()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["existsSync","lstatSync","dirname","extname","resolve","fullySpecifyCommonJS","api","options","assertVersion","name","visitor","CallExpression","path","state","get","isIdentifier","node","arguments","length","arg","type","moduleSpecifier","value","startsWith","filePath","file","opts","filename","fileDir","cjsExtension","esExtensionDefault","jsExtension","resolvedPath","newModuleSpecifier","isLocalDirectory","indexPath","endsWith","
|
|
1
|
+
{"version":3,"names":["existsSync","lstatSync","dirname","extname","resolve","fullySpecifyCommonJS","api","options","assertVersion","name","visitor","CallExpression","path","state","callee","get","isIdentifier","node","arguments","length","arg","type","moduleSpecifier","value","startsWith","filePath","file","opts","filename","fileDir","cjsExtension","esExtensionDefault","jsExtension","specifierExtension","hasModuleExtension","includes","resolvedPath","newModuleSpecifier","isLocalDirectory","indexPath","endsWith","absolutePath","isDirectory"],"sources":["../../src/commonjs.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAA,EAAYC,SAAA,QAAiB;AACtC,SAASC,OAAA,EAASC,OAAA,EAASC,OAAA,QAAe;AAE3B,SAARC,qBACLC,GAAA,EACAC,OAAA,EAGiB;EACjBD,GAAA,CAAIE,aAAA,CAAc,CAAC;EAEnB,OAAO;IACLC,IAAA,EAAM;IACNC,OAAA,EAAS;MACPC,eAAeC,IAAA,EAAMC,KAAA,EAAO;QAC1B,MAAMC,MAAA,GAASF,IAAA,CAAKG,GAAA,CAAI,QAAQ;QAEhC,IACED,MAAA,CAAOE,YAAA,CAAa;UAAEP,IAAA,EAAM;QAAU,CAAC,KACvCG,IAAA,CAAKK,IAAA,CAAKC,SAAA,CAAUC,MAAA,KAAW,GAC/B;UACA,MAAMC,GAAA,GAAMR,IAAA,CAAKK,IAAA,CAAKC,SAAA,CAAU,CAAC;UACjC,IAAIE,GAAA,CAAIC,IAAA,KAAS,iBAAiB;YAChC,IAAIC,eAAA,GAAkBF,GAAA,CAAIG,KAAA;YAG1B,IAAID,eAAA,CAAgBE,UAAA,CAAW,GAAG,KAAKF,eAAA,CAAgBE,UAAA,CAAW,GAAG,GAAG;cACtE,MAAMC,QAAA,GAAWZ,KAAA,CAAMa,IAAA,CAAKC,IAAA,CAAKC,QAAA;cACjC,IAAI,CAACH,QAAA,EAAU;cAEf,MAAMI,OAAA,GAAU3B,OAAA,CAAQuB,QAAQ;cAChC,MAAMK,YAAA,GAAevB,OAAA,CAAQwB,kBAAA,IAAsB;cACnD,MAAMC,WAAA,GAAc;cAIpB,MAAMC,kBAAA,GAAqB9B,OAAA,CAAQmB,eAAe;cAClD,MAAMY,kBAAA,GAAqB,CACzB,OACA,QACA,QACA,SACA,QACF,CAAEC,QAAA,CAASF,kBAAkB;cAC7B,IAAI,CAACC,kBAAA,EAAoB;gBACvB,MAAME,YAAA,GAAehC,OAAA,CAAQyB,OAAA,EAASP,eAAe;gBACrD,IAAIe,kBAAA,GAAqBf,eAAA;gBAGzB,IAAIgB,gBAAA,CAAiBF,YAAY,GAAG;kBAClC,MAAMG,SAAA,GAAYnC,OAAA,CAAQgC,YAAA,EAAc,UAAUJ,WAAW;kBAC7D,IAAIhC,UAAA,CAAWuC,SAAS,GAAG;oBAEzB,IAAI,CAACF,kBAAA,CAAmBG,QAAA,CAAS,GAAG,GAAG;sBACrCH,kBAAA,IAAsB;oBACxB;oBACAA,kBAAA,IAAsB,UAAUP,YAAA;oBAChCV,GAAA,CAAIG,KAAA,GAAQc,kBAAA;oBACZ;kBACF;gBACF;gBAGA,IACErC,UAAA,CAAWoC,YAAA,GAAeJ,WAAW,KACrChC,UAAA,CAAWoC,YAAA,GAAeN,YAAY,GACtC;kBACAO,kBAAA,IAAsBP,YAAA;kBACtBV,GAAA,CAAIG,KAAA,GAAQc,kBAAA;kBACZ;gBACF;cACF;YACF;UACF;QACF;MACF;IACF;EACF;AACF;AAEA,SAASC,iBAAiBG,YAAA,EAA+B;EACvD,OAAOzC,UAAA,CAAWyC,YAAY,KAAKxC,SAAA,CAAUwC,YAAY,EAAEC,WAAA,CAAY;AACzE","ignoreList":[]}
|
package/src/commonjs.ts
CHANGED
|
@@ -32,8 +32,17 @@ export default function fullySpecifyCommonJS(
|
|
|
32
32
|
const cjsExtension = options.esExtensionDefault || '.cjs'
|
|
33
33
|
const jsExtension = '.js'
|
|
34
34
|
|
|
35
|
-
// Check if moduleSpecifier already has
|
|
36
|
-
|
|
35
|
+
// Check if moduleSpecifier already has a module extension. extname alone
|
|
36
|
+
// is wrong here: dotted basenames like ./foo.generated have no extension.
|
|
37
|
+
const specifierExtension = extname(moduleSpecifier)
|
|
38
|
+
const hasModuleExtension = [
|
|
39
|
+
'.js',
|
|
40
|
+
'.cjs',
|
|
41
|
+
'.mjs',
|
|
42
|
+
'.json',
|
|
43
|
+
'.node',
|
|
44
|
+
].includes(specifierExtension)
|
|
45
|
+
if (!hasModuleExtension) {
|
|
37
46
|
const resolvedPath = resolve(fileDir, moduleSpecifier)
|
|
38
47
|
let newModuleSpecifier = moduleSpecifier
|
|
39
48
|
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ConfigAPI, PluginObj } from "@babel/core";
|
|
2
|
+
export interface FullySpecifiedOptions {
|
|
3
|
+
ensureFileExists: boolean;
|
|
4
|
+
esExtensionDefault: string;
|
|
5
|
+
/** List of all extensions which we try to find. */
|
|
6
|
+
tryExtensions: Array<string>;
|
|
7
|
+
/** List of extensions that can run in Node.js or in the Browser. */
|
|
8
|
+
esExtensions: Array<string>;
|
|
9
|
+
/** Convert process.env.XYZ to import.meta.env.XYZ */
|
|
10
|
+
convertProcessEnvToImportMetaEnv?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export default function FullySpecified(api: ConfigAPI, rawOptions?: Partial<FullySpecifiedOptions>): PluginObj;
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|