@tamagui/babel-plugin-fully-specified 1.114.4 → 1.115.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.
@@ -3,34 +3,44 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
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) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
15
21
  var commonjs_exports = {};
16
22
  __export(commonjs_exports, {
17
23
  default: () => fullySpecifyCommonJS
18
24
  });
19
25
  module.exports = __toCommonJS(commonjs_exports);
20
- var import_node_fs = require("node:fs"), import_node_path = require("node:path");
26
+ var import_node_fs = require("node:fs"),
27
+ import_node_path = require("node:path");
21
28
  function fullySpecifyCommonJS(api) {
22
29
  return api.assertVersion(7), {
23
30
  name: "babel-plugin-fully-specified-cjs",
24
31
  visitor: {
25
32
  CallExpression(path, state) {
26
- if (path.get("callee").isIdentifier({ name: "require" }) && path.node.arguments.length === 1) {
33
+ if (path.get("callee").isIdentifier({
34
+ name: "require"
35
+ }) && path.node.arguments.length === 1) {
27
36
  const arg = path.node.arguments[0];
28
37
  if (arg.type === "StringLiteral") {
29
38
  let moduleSpecifier = arg.value;
30
39
  if (moduleSpecifier.startsWith(".") || moduleSpecifier.startsWith("/")) {
31
40
  const filePath = state.file.opts.filename;
32
41
  if (!filePath) return;
33
- const fileDir = (0, import_node_path.dirname)(filePath), cjsExtension = ".cjs";
42
+ const fileDir = (0, import_node_path.dirname)(filePath),
43
+ cjsExtension = ".cjs";
34
44
  if (!(0, import_node_path.extname)(moduleSpecifier)) {
35
45
  const resolvedPath = (0, import_node_path.resolve)(fileDir, moduleSpecifier);
36
46
  let newModuleSpecifier = moduleSpecifier;
@@ -56,5 +66,4 @@ function fullySpecifyCommonJS(api) {
56
66
  }
57
67
  function isLocalDirectory(absolutePath) {
58
68
  return (0, import_node_fs.existsSync)(absolutePath) && (0, import_node_fs.lstatSync)(absolutePath).isDirectory();
59
- }
60
- //# sourceMappingURL=commonjs.js.map
69
+ }
@@ -0,0 +1,141 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ default: () => FullySpecified
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+ var import_node_fs = require("node:fs"),
27
+ import_node_path = require("node:path");
28
+ const DEFAULT_OPTIONS = {
29
+ ensureFileExists: !0,
30
+ esExtensionDefault: ".mjs",
31
+ tryExtensions: [".js"],
32
+ esExtensions: [".mjs"]
33
+ };
34
+ function FullySpecified(api, rawOptions) {
35
+ api.assertVersion(7);
36
+ const options = {
37
+ ...DEFAULT_OPTIONS,
38
+ ...rawOptions
39
+ },
40
+ importDeclarationVisitor = (path, state) => {
41
+ const filePath = state.file.opts.filename;
42
+ if (!filePath) return;
43
+ const {
44
+ node
45
+ } = path;
46
+ if (node.importKind === "type") return;
47
+ const originalModuleSpecifier = node.source.value,
48
+ fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
49
+ filePath,
50
+ options
51
+ });
52
+ fullySpecifiedModuleSpecifier && (node.source.value = fullySpecifiedModuleSpecifier);
53
+ },
54
+ exportDeclarationVisitor = (path, state) => {
55
+ const filePath = state.file.opts.filename;
56
+ if (!filePath) return;
57
+ const {
58
+ node
59
+ } = path;
60
+ if (node.exportKind === "type") return;
61
+ const source = node.source;
62
+ if (!source) return;
63
+ const originalModuleSpecifier = source.value,
64
+ fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
65
+ filePath,
66
+ options
67
+ });
68
+ fullySpecifiedModuleSpecifier && (source.value = fullySpecifiedModuleSpecifier);
69
+ };
70
+ return {
71
+ name: "babel-plugin-fully-specified",
72
+ visitor: {
73
+ ImportDeclaration: importDeclarationVisitor,
74
+ ExportNamedDeclaration: exportDeclarationVisitor,
75
+ ExportAllDeclaration: exportDeclarationVisitor,
76
+ Import: (path, state) => {
77
+ const filePath = state.file.opts.filename;
78
+ if (!filePath) return;
79
+ const parent = path.parent;
80
+ if (parent.type !== "CallExpression") return;
81
+ const firstArgOfImportCall = parent.arguments[0];
82
+ if (firstArgOfImportCall.type !== "StringLiteral") return;
83
+ const originalModuleSpecifier = firstArgOfImportCall.value,
84
+ fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
85
+ filePath,
86
+ options
87
+ });
88
+ fullySpecifiedModuleSpecifier && (firstArgOfImportCall.value = fullySpecifiedModuleSpecifier);
89
+ }
90
+ }
91
+ };
92
+ }
93
+ function getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
94
+ filePath,
95
+ options
96
+ }) {
97
+ const fileExt = (0, import_node_path.extname)(filePath),
98
+ fileDir = (0, import_node_path.dirname)(filePath),
99
+ isDirectory = isLocalDirectory((0, import_node_path.resolve)(fileDir, originalModuleSpecifier)),
100
+ currentModuleExtension = (0, import_node_path.extname)(originalModuleSpecifier),
101
+ {
102
+ tryExtensions,
103
+ esExtensions,
104
+ esExtensionDefault,
105
+ ensureFileExists
106
+ } = options,
107
+ targetModule = evaluateTargetModule({
108
+ moduleSpecifier: originalModuleSpecifier,
109
+ filenameDirectory: fileDir,
110
+ filenameExtension: fileExt,
111
+ currentModuleExtension,
112
+ isDirectory,
113
+ tryExtensions,
114
+ esExtensions,
115
+ esExtensionDefault,
116
+ ensureFileExists
117
+ });
118
+ return targetModule === !1 ? null : targetModule;
119
+ }
120
+ function isLocalDirectory(absoluteDirectory) {
121
+ return (0, import_node_fs.existsSync)(absoluteDirectory) && (0, import_node_fs.lstatSync)(absoluteDirectory).isDirectory();
122
+ }
123
+ function evaluateTargetModule({
124
+ moduleSpecifier,
125
+ currentModuleExtension,
126
+ isDirectory,
127
+ filenameDirectory,
128
+ filenameExtension,
129
+ tryExtensions,
130
+ esExtensions,
131
+ esExtensionDefault,
132
+ ensureFileExists
133
+ }) {
134
+ if (currentModuleExtension && !esExtensions.includes(currentModuleExtension)) return !1;
135
+ const targetFile = (0, import_node_path.resolve)(filenameDirectory, moduleSpecifier);
136
+ if (ensureFileExists) {
137
+ for (const extension of tryExtensions) if ((0, import_node_fs.existsSync)(targetFile + extension)) return moduleSpecifier + esExtensionDefault;
138
+ isDirectory && !(0, import_node_fs.existsSync)((0, import_node_path.resolve)(filenameDirectory, currentModuleExtension ? moduleSpecifier : moduleSpecifier + esExtensionDefault)) && (moduleSpecifier = `${moduleSpecifier}/index`);
139
+ } else return esExtensions.includes(filenameExtension), moduleSpecifier + esExtensionDefault;
140
+ return !1;
141
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/babel-plugin-fully-specified",
3
- "version": "1.114.4",
3
+ "version": "1.115.0",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -27,12 +27,15 @@
27
27
  ".": {
28
28
  "types": "./types/index.d.ts",
29
29
  "import": "./dist/esm/index.mjs",
30
- "require": "./dist/cjs/index.js"
30
+ "require": "./dist/cjs/index.cjs",
31
+ "react-native": "./dist/cjs/index.cjs",
32
+ "default": "./dist/cjs/index.cjs"
31
33
  },
32
34
  "./commonjs": {
33
35
  "types": "./types/commonjs.d.ts",
34
36
  "import": "./dist/esm/commonjs.mjs",
35
- "require": "./dist/cjs/commonjs.js"
37
+ "require": "./dist/cjs/commonjs.cjs",
38
+ "react-native": "./dist/cjs/commonjs.cjs"
36
39
  }
37
40
  },
38
41
  "dependencies": {
package/dist/cjs/index.js DELETED
@@ -1,132 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
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) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var src_exports = {};
16
- __export(src_exports, {
17
- default: () => FullySpecified
18
- });
19
- module.exports = __toCommonJS(src_exports);
20
- var import_node_fs = require("node:fs"), import_node_path = require("node:path");
21
- const DEFAULT_OPTIONS = {
22
- ensureFileExists: !0,
23
- esExtensionDefault: ".mjs",
24
- tryExtensions: [".js"],
25
- esExtensions: [".mjs"]
26
- };
27
- function FullySpecified(api, rawOptions) {
28
- api.assertVersion(7);
29
- const options = { ...DEFAULT_OPTIONS, ...rawOptions }, importDeclarationVisitor = (path, state) => {
30
- const filePath = state.file.opts.filename;
31
- if (!filePath) return;
32
- const { node } = path;
33
- if (node.importKind === "type") return;
34
- const originalModuleSpecifier = node.source.value, fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(
35
- originalModuleSpecifier,
36
- {
37
- filePath,
38
- options
39
- }
40
- );
41
- fullySpecifiedModuleSpecifier && (node.source.value = fullySpecifiedModuleSpecifier);
42
- }, exportDeclarationVisitor = (path, state) => {
43
- const filePath = state.file.opts.filename;
44
- if (!filePath) return;
45
- const { node } = path;
46
- if (node.exportKind === "type") return;
47
- const source = node.source;
48
- if (!source) return;
49
- const originalModuleSpecifier = source.value, fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(
50
- originalModuleSpecifier,
51
- {
52
- filePath,
53
- options
54
- }
55
- );
56
- fullySpecifiedModuleSpecifier && (source.value = fullySpecifiedModuleSpecifier);
57
- };
58
- return {
59
- name: "babel-plugin-fully-specified",
60
- visitor: {
61
- ImportDeclaration: importDeclarationVisitor,
62
- ExportNamedDeclaration: exportDeclarationVisitor,
63
- ExportAllDeclaration: exportDeclarationVisitor,
64
- Import: (path, state) => {
65
- const filePath = state.file.opts.filename;
66
- if (!filePath) return;
67
- const parent = path.parent;
68
- if (parent.type !== "CallExpression")
69
- return;
70
- const firstArgOfImportCall = parent.arguments[0];
71
- if (firstArgOfImportCall.type !== "StringLiteral")
72
- return;
73
- const originalModuleSpecifier = firstArgOfImportCall.value, fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(
74
- originalModuleSpecifier,
75
- {
76
- filePath,
77
- options
78
- }
79
- );
80
- fullySpecifiedModuleSpecifier && (firstArgOfImportCall.value = fullySpecifiedModuleSpecifier);
81
- }
82
- }
83
- };
84
- }
85
- function getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
86
- filePath,
87
- options
88
- }) {
89
- const fileExt = (0, import_node_path.extname)(filePath), fileDir = (0, import_node_path.dirname)(filePath), isDirectory = isLocalDirectory((0, import_node_path.resolve)(fileDir, originalModuleSpecifier)), currentModuleExtension = (0, import_node_path.extname)(originalModuleSpecifier), { tryExtensions, esExtensions, esExtensionDefault, ensureFileExists } = options, targetModule = evaluateTargetModule({
90
- moduleSpecifier: originalModuleSpecifier,
91
- filenameDirectory: fileDir,
92
- filenameExtension: fileExt,
93
- currentModuleExtension,
94
- isDirectory,
95
- tryExtensions,
96
- esExtensions,
97
- esExtensionDefault,
98
- ensureFileExists
99
- });
100
- return targetModule === !1 ? null : targetModule;
101
- }
102
- function isLocalDirectory(absoluteDirectory) {
103
- return (0, import_node_fs.existsSync)(absoluteDirectory) && (0, import_node_fs.lstatSync)(absoluteDirectory).isDirectory();
104
- }
105
- function evaluateTargetModule({
106
- moduleSpecifier,
107
- currentModuleExtension,
108
- isDirectory,
109
- filenameDirectory,
110
- filenameExtension,
111
- tryExtensions,
112
- esExtensions,
113
- esExtensionDefault,
114
- ensureFileExists
115
- }) {
116
- if (currentModuleExtension && !esExtensions.includes(currentModuleExtension))
117
- return !1;
118
- const targetFile = (0, import_node_path.resolve)(filenameDirectory, moduleSpecifier);
119
- if (ensureFileExists) {
120
- for (const extension of tryExtensions)
121
- if ((0, import_node_fs.existsSync)(targetFile + extension))
122
- return moduleSpecifier + esExtensionDefault;
123
- isDirectory && !(0, import_node_fs.existsSync)(
124
- (0, import_node_path.resolve)(
125
- filenameDirectory,
126
- currentModuleExtension ? moduleSpecifier : moduleSpecifier + esExtensionDefault
127
- )
128
- ) && (moduleSpecifier = `${moduleSpecifier}/index`);
129
- } else return esExtensions.includes(filenameExtension), moduleSpecifier + esExtensionDefault;
130
- return !1;
131
- }
132
- //# sourceMappingURL=index.js.map
File without changes
File without changes