@tamagui/babel-plugin-fully-specified 1.101.7 → 1.102.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.
Files changed (28) hide show
  1. package/dist/cjs/index.js +98 -74
  2. package/dist/cjs/index.js.map +2 -2
  3. package/dist/cjs/index.native.js +98 -121
  4. package/dist/cjs/index.native.js.map +2 -2
  5. package/dist/esm/index.js +97 -79
  6. package/dist/esm/index.js.map +1 -1
  7. package/dist/esm/index.mjs +105 -91
  8. package/dist/esm/index.native.js +97 -121
  9. package/dist/esm/index.native.js.map +2 -2
  10. package/package.json +6 -4
  11. package/src/__tests__/__snapshots__/index.test.ts.snap +21 -0
  12. package/src/__tests__/fixtures/force-extension/bar.js +1 -0
  13. package/src/__tests__/fixtures/force-extension/foo.js +1 -0
  14. package/src/__tests__/fixtures/multiple-extensions-exists/modules/module.cjs +2 -0
  15. package/src/__tests__/fixtures/multiple-extensions-exists/modules/module.js +2 -0
  16. package/src/__tests__/fixtures/multiple-extensions-exists/modules/module.mjs +4 -0
  17. package/src/__tests__/fixtures/multiple-extensions-exists/test.mjs +2 -0
  18. package/src/__tests__/fixtures/sample-project-1/modules/cjs-module.cjs +2 -0
  19. package/src/__tests__/fixtures/sample-project-1/modules/module.mjs +4 -0
  20. package/src/__tests__/fixtures/sample-project-1/node_modules/@my-org/my-pkg/lib/exampleFunction.js +3 -0
  21. package/src/__tests__/fixtures/sample-project-1/node_modules/@my-org/my-pkg/lib/index.js +1 -0
  22. package/src/__tests__/fixtures/sample-project-1/node_modules/@my-org/my-pkg/package.json +4 -0
  23. package/src/__tests__/fixtures/sample-project-1/node_modules/README.md +1 -0
  24. package/src/__tests__/fixtures/sample-project-1/test.mjs +13 -0
  25. package/src/__tests__/index.test.ts +139 -0
  26. package/src/index.ts +220 -140
  27. package/types/index.d.ts +14 -21
  28. package/types/index.d.ts.map +1 -1
@@ -1,14 +1,5 @@
1
1
  import { existsSync, readFileSync, lstatSync } from "node:fs";
2
2
  import { resolve, extname, dirname } from "node:path";
3
- import { importDeclaration, exportNamedDeclaration, exportAllDeclaration, stringLiteral } from "@babel/types";
4
- function _array_like_to_array(arr, len) {
5
- (len == null || len > arr.length) && (len = arr.length);
6
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
7
- return arr2;
8
- }
9
- function _array_without_holes(arr) {
10
- if (Array.isArray(arr)) return _array_like_to_array(arr);
11
- }
12
3
  function _define_property(obj, key, value) {
13
4
  return key in obj ? Object.defineProperty(obj, key, {
14
5
  value,
@@ -17,129 +8,114 @@ function _define_property(obj, key, value) {
17
8
  writable: !0
18
9
  }) : obj[key] = value, obj;
19
10
  }
20
- function _iterable_to_array(iter) {
21
- if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
22
- }
23
- function _non_iterable_spread() {
24
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
25
- }
26
11
  function _object_spread(target) {
27
12
  for (var i = 1; i < arguments.length; i++) {
28
- var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
29
- typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
13
+ var source = arguments[i] != null ? arguments[i] : {}, ownKeys = Object.keys(source);
14
+ typeof Object.getOwnPropertySymbols == "function" && (ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
30
15
  return Object.getOwnPropertyDescriptor(source, sym).enumerable;
31
- }))), ownKeys2.forEach(function(key) {
16
+ }))), ownKeys.forEach(function(key) {
32
17
  _define_property(target, key, source[key]);
33
18
  });
34
19
  }
35
20
  return target;
36
21
  }
37
- function ownKeys(object, enumerableOnly) {
38
- var keys = Object.keys(object);
39
- if (Object.getOwnPropertySymbols) {
40
- var symbols = Object.getOwnPropertySymbols(object);
41
- enumerableOnly && (symbols = symbols.filter(function(sym) {
42
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
43
- })), keys.push.apply(keys, symbols);
44
- }
45
- return keys;
46
- }
47
- function _object_spread_props(target, source) {
48
- return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
49
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
50
- }), target;
51
- }
52
- function _to_consumable_array(arr) {
53
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
54
- }
55
- function _unsupported_iterable_to_array(o, minLen) {
56
- if (o) {
57
- if (typeof o == "string") return _array_like_to_array(o, minLen);
58
- var n = Object.prototype.toString.call(o).slice(8, -1);
59
- if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
60
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
61
- }
62
- }
63
- var makeDeclaration = function(param) {
64
- var declaration = param.declaration, makeNodes = param.makeNodes, _param_ensureFileExists = param.ensureFileExists, ensureFileExists = _param_ensureFileExists === void 0 ? !1 : _param_ensureFileExists, _param_esExtensionDefault = param.esExtensionDefault, esExtensionDefault = _param_esExtensionDefault === void 0 ? ".js" : _param_esExtensionDefault, _param_tryExtensions = param.tryExtensions, tryExtensions = _param_tryExtensions === void 0 ? [
22
+ var DEFAULT_OPTIONS = {
23
+ ensureFileExists: !1,
24
+ esExtensionDefault: ".js",
25
+ tryExtensions: [
65
26
  ".js",
66
27
  ".mjs",
67
28
  ".cjs"
68
- ] : _param_tryExtensions, _param_esExtensions = param.esExtensions, esExtensions = _param_esExtensions === void 0 ? [
29
+ ],
30
+ esExtensions: [
69
31
  ".js",
70
32
  ".mjs",
71
33
  ".cjs"
72
- ] : _param_esExtensions, _param_includePackages = param.includePackages, includePackages = _param_includePackages === void 0 ? [] : _param_includePackages;
73
- return function(path, param2) {
74
- var _param_file = param2.file, filename = _param_file.opts.filename, source = path.node.source;
75
- if (!(!source || !filename)) {
76
- var _path_node = path.node, exportKind = _path_node.exportKind, importKind = _path_node.importKind, isTypeOnly = exportKind === "type" || importKind === "type";
77
- if (!isTypeOnly) {
78
- var value = source.value, module = value, packageData = null;
79
- if (!(!isLocalFile(module) && (includePackages.some(function(name) {
80
- return module.startsWith(name);
81
- }) && (packageData = getPackageData(module)), !(packageData && packageData.hasPath)))) {
82
- var filenameExtension = extname(filename), filenameDirectory = dirname(filename), isDirectory = isLocalDirectory(resolve(filenameDirectory, module)), currentModuleExtension = extname(module), targetModule = evaluateTargetModule({
83
- module,
84
- filenameDirectory,
85
- filenameExtension,
86
- packageData,
87
- currentModuleExtension,
88
- isDirectory,
89
- tryExtensions,
90
- esExtensions,
91
- esExtensionDefault,
92
- ensureFileExists
34
+ ],
35
+ includePackages: []
36
+ };
37
+ function FullySpecified(api, rawOptions) {
38
+ api.assertVersion(7);
39
+ var options = _object_spread({}, DEFAULT_OPTIONS, rawOptions), importDeclarationVisitor = function(path, state) {
40
+ var filePath = state.file.opts.filename;
41
+ if (filePath) {
42
+ var node = path.node;
43
+ if (node.importKind !== "type") {
44
+ var originalModuleSpecifier = node.source.value, fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
45
+ filePath,
46
+ options
47
+ });
48
+ fullySpecifiedModuleSpecifier && (node.source.value = fullySpecifiedModuleSpecifier);
49
+ }
50
+ }
51
+ }, exportDeclarationVisitor = function(path, state) {
52
+ var filePath = state.file.opts.filename;
53
+ if (filePath) {
54
+ var node = path.node;
55
+ if (node.exportKind !== "type") {
56
+ var source = node.source;
57
+ if (source) {
58
+ var originalModuleSpecifier = source.value, fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
59
+ filePath,
60
+ options
61
+ });
62
+ fullySpecifiedModuleSpecifier && (source.value = fullySpecifiedModuleSpecifier);
63
+ }
64
+ }
65
+ }
66
+ }, importVisitor = function(path, state) {
67
+ var filePath = state.file.opts.filename;
68
+ if (filePath) {
69
+ var parent = path.parent;
70
+ if (parent.type === "CallExpression") {
71
+ var firstArgOfImportCall = parent.arguments[0];
72
+ if (firstArgOfImportCall.type === "StringLiteral") {
73
+ var originalModuleSpecifier = firstArgOfImportCall.value, fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(originalModuleSpecifier, {
74
+ filePath,
75
+ options
93
76
  });
94
- if (!(targetModule === !1 || currentModuleExtension === targetModule.extension)) {
95
- var nodes = makeNodes(path);
96
- path.replaceWith(
97
- // @ts-ignore
98
- declaration.apply(null, _to_consumable_array(nodes).concat([
99
- stringLiteral(targetModule.module)
100
- ]))
101
- );
102
- }
77
+ fullySpecifiedModuleSpecifier && (firstArgOfImportCall.value = fullySpecifiedModuleSpecifier);
103
78
  }
104
79
  }
105
80
  }
106
81
  };
107
- };
108
- function FullySpecified(api, options) {
109
- return api.assertVersion(7), {
82
+ return {
110
83
  name: "babel-plugin-fully-specified",
111
84
  visitor: {
112
- ImportDeclaration: makeDeclaration(_object_spread_props(_object_spread({}, options), {
113
- declaration: importDeclaration,
114
- makeNodes: function(param) {
115
- var specifiers = param.node.specifiers;
116
- return [
117
- specifiers
118
- ];
119
- }
120
- })),
121
- ExportNamedDeclaration: makeDeclaration(_object_spread_props(_object_spread({}, options), {
122
- declaration: exportNamedDeclaration,
123
- makeNodes: function(param) {
124
- var _param_node = param.node, declaration = _param_node.declaration, specifiers = _param_node.specifiers;
125
- return [
126
- declaration,
127
- specifiers
128
- ];
129
- }
130
- })),
131
- ExportAllDeclaration: makeDeclaration(_object_spread_props(_object_spread({}, options), {
132
- declaration: exportAllDeclaration,
133
- makeNodes: function() {
134
- return [];
135
- }
136
- }))
85
+ ImportDeclaration: importDeclarationVisitor,
86
+ ExportNamedDeclaration: exportDeclarationVisitor,
87
+ ExportAllDeclaration: exportDeclarationVisitor,
88
+ Import: importVisitor
137
89
  }
138
90
  };
139
91
  }
140
- function getPackageData(module) {
92
+ function getFullySpecifiedModuleSpecifier(originalModuleSpecifier, param) {
93
+ var filePath = param.filePath, options = param.options, fileExt = extname(filePath), fileDir = dirname(filePath), includePackages = options.includePackages, packageData = null;
94
+ if (!isLocalFile(originalModuleSpecifier) && (includePackages.some(function(name) {
95
+ return originalModuleSpecifier.startsWith(name);
96
+ }) && (packageData = getPackageData(originalModuleSpecifier, filePath)), !(packageData && packageData.isDeepImport)))
97
+ return null;
98
+ var isDirectory = isLocalDirectory(resolve(fileDir, originalModuleSpecifier)), currentModuleExtension = extname(originalModuleSpecifier), tryExtensions = options.tryExtensions, esExtensions = options.esExtensions, esExtensionDefault = options.esExtensionDefault, ensureFileExists = options.ensureFileExists, targetModule = evaluateTargetModule({
99
+ moduleSpecifier: originalModuleSpecifier,
100
+ filenameDirectory: fileDir,
101
+ filenameExtension: fileExt,
102
+ packageData,
103
+ currentModuleExtension,
104
+ isDirectory,
105
+ tryExtensions,
106
+ esExtensions,
107
+ esExtensionDefault,
108
+ ensureFileExists
109
+ });
110
+ return targetModule === !1 || currentModuleExtension === targetModule.extension ? null : targetModule.module;
111
+ }
112
+ function getPackageData(moduleSpecifier, filePath) {
141
113
  try {
142
- for (var packagePath = require.resolve(module), parts = packagePath.split("/"), packageDir = "", i = parts.length; i >= 0; i--) {
114
+ for (var modulePath = require.resolve(moduleSpecifier, {
115
+ paths: filePath ? [
116
+ filePath
117
+ ] : []
118
+ }), parts = modulePath.split("/"), packageDir = "", i = parts.length; i >= 0; i--) {
143
119
  var dir = dirname(parts.slice(0, i).join("/"));
144
120
  if (existsSync("".concat(dir, "/package.json"))) {
145
121
  packageDir = dir;
@@ -148,36 +124,36 @@ function getPackageData(module) {
148
124
  }
149
125
  if (!packageDir)
150
126
  throw new Error("no package dir");
151
- var packageJson = JSON.parse(readFileSync("".concat(packageDir, "/package.json")).toString()), hasPath = !module.endsWith(packageJson.name);
127
+ var packageJson = JSON.parse(readFileSync("".concat(packageDir, "/package.json")).toString()), isDeepImport = !moduleSpecifier.endsWith(packageJson.name);
152
128
  return {
153
- hasPath,
154
- packagePath
129
+ isDeepImport,
130
+ modulePath
155
131
  };
156
132
  } catch {
157
133
  }
158
134
  return null;
159
135
  }
160
- function isLocalFile(module) {
161
- return module.startsWith(".") || module.startsWith("/");
136
+ function isLocalFile(moduleSpecifier) {
137
+ return moduleSpecifier.startsWith(".") || moduleSpecifier.startsWith("/");
162
138
  }
163
139
  function isLocalDirectory(absoluteDirectory) {
164
140
  return existsSync(absoluteDirectory) && lstatSync(absoluteDirectory).isDirectory();
165
141
  }
166
142
  function evaluateTargetModule(param) {
167
- var module = param.module, currentModuleExtension = param.currentModuleExtension, packageData = param.packageData, isDirectory = param.isDirectory, filenameDirectory = param.filenameDirectory, filenameExtension = param.filenameExtension, tryExtensions = param.tryExtensions, esExtensions = param.esExtensions, esExtensionDefault = param.esExtensionDefault, ensureFileExists = param.ensureFileExists;
143
+ var moduleSpecifier = param.moduleSpecifier, currentModuleExtension = param.currentModuleExtension, packageData = param.packageData, isDirectory = param.isDirectory, filenameDirectory = param.filenameDirectory, filenameExtension = param.filenameExtension, tryExtensions = param.tryExtensions, esExtensions = param.esExtensions, esExtensionDefault = param.esExtensionDefault, ensureFileExists = param.ensureFileExists;
168
144
  if (packageData)
169
- return packageData.packagePath.endsWith("index.js") && !module.endsWith("index.js") && (module = "".concat(module, "/index")), {
170
- module: module + esExtensionDefault,
145
+ return packageData.modulePath.endsWith("index.js") && !moduleSpecifier.endsWith("index.js") && (moduleSpecifier = "".concat(moduleSpecifier, "/index")), {
146
+ module: moduleSpecifier + esExtensionDefault,
171
147
  extension: esExtensionDefault
172
148
  };
173
149
  if (currentModuleExtension && !esExtensions.includes(currentModuleExtension))
174
150
  return !1;
175
- isDirectory && !existsSync(resolve(filenameDirectory, currentModuleExtension ? module : module + esExtensionDefault)) && (module = "".concat(module, "/index"));
176
- var targetFile = resolve(filenameDirectory, module);
151
+ isDirectory && !existsSync(resolve(filenameDirectory, currentModuleExtension ? moduleSpecifier : moduleSpecifier + esExtensionDefault)) && (moduleSpecifier = "".concat(moduleSpecifier, "/index"));
152
+ var targetFile = resolve(filenameDirectory, moduleSpecifier);
177
153
  if (ensureFileExists) {
178
154
  if (esExtensions.includes(filenameExtension) && existsSync(targetFile + filenameExtension))
179
155
  return {
180
- module: module + filenameExtension,
156
+ module: moduleSpecifier + (ensureFileExists.forceExtension || filenameExtension),
181
157
  extension: filenameExtension
182
158
  };
183
159
  var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
@@ -186,7 +162,7 @@ function evaluateTargetModule(param) {
186
162
  var extension = _step.value;
187
163
  if (existsSync(targetFile + extension))
188
164
  return {
189
- module: module + ".mjs",
165
+ module: moduleSpecifier + (ensureFileExists.forceExtension || extension),
190
166
  extension
191
167
  };
192
168
  }
@@ -201,10 +177,10 @@ function evaluateTargetModule(param) {
201
177
  }
202
178
  }
203
179
  } else return esExtensions.includes(filenameExtension) ? {
204
- module: module + filenameExtension,
180
+ module: moduleSpecifier + filenameExtension,
205
181
  extension: filenameExtension
206
182
  } : {
207
- module: module + esExtensionDefault,
183
+ module: moduleSpecifier + esExtensionDefault,
208
184
  extension: esExtensionDefault
209
185
  };
210
186
  return !1;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Users/n8/tamagui/code/packages/babel-plugin-fully-specified/src/index.ts"],
4
- "mappings": "AAAA,SAASA,YAAYC,cAAcC,iBAAiB;AACpD,SAASC,SAASC,SAASC,eAAe;AAC1C,SACEC,mBACAC,wBACAC,sBACAC,qBACK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDP,IAAMC,kBAAkB,SAAA,OAAA;MACtBC,cAAAA,MAAAA,aACAC,YAAAA,MAAAA,WAAAA,0BAAAA,MACAC,kBAAAA,mBAAAA,4BAAAA,SAAmB,KAA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BAAO;YAAEf,QAAQA,SAAS;YAAQe;UAAU;MAEhD;;AAJK,0BAAA,IAAA,iBAAA;;;SAAA,6BAAA,UAAA,UAAA,QAAA,UAAA,OAAA;;YAAA;gBAAA;;;EAKP,MAAO,QAAI3B,aAAawD,SAASpC,iBAAAA,IACxB;IACLR,QAAQA,SAASQ;IACjBO,WAAWP;EACb,IAEO;IACLR,QAAQA,SAASd;IACjB6B,WAAW7B;EACb;AAGF,SAAO;AACT;",
5
- "names": ["existsSync", "readFileSync", "lstatSync", "resolve", "extname", "dirname", "importDeclaration", "exportNamedDeclaration", "exportAllDeclaration", "stringLiteral", "makeDeclaration", "declaration", "makeNodes", "ensureFileExists", "esExtensionDefault", "tryExtensions", "esExtensions", "includePackages", "path", "file", "filename", "opts", "source", "node", "exportKind", "importKind", "isTypeOnly", "value", "module", "packageData", "isLocalFile", "some", "name", "startsWith", "getPackageData", "hasPath", "filenameExtension", "filenameDirectory", "isDirectory", "isLocalDirectory", "currentModuleExtension", "targetModule", "evaluateTargetModule", "extension", "nodes", "replaceWith", "apply", "api", "options", "assertVersion", "visitor", "ImportDeclaration", "specifiers", "ExportNamedDeclaration", "ExportAllDeclaration", "packagePath", "require", "parts", "split", "packageDir", "i", "length", "dir", "slice", "join", "Error", "packageJson", "JSON", "parse", "toString", "endsWith", "absoluteDirectory", "includes", "targetFile"]
4
+ "mappings": "AAAA,SAASA,YAAYC,cAAcC,iBAAiB;AACpD,SAASC,SAASC,SAASC,eAAe;;;;;;;;;;;;;;;;;;;;AA8B1C,IAAMC,kBAAkB;EACtBC,kBAAkB;EAClBC,oBAAoB;EACpBC,eAAe;IAAC;IAAO;IAAQ;;EAC/BC,cAAc;IAAC;IAAO;IAAQ;;EAC9BC,iBAAiB,CAAA;AACnB;AAEe,SAAf,eACEC,KACAC,YAAiC;AAEjCD,MAAIE,cAAc,CAAA;AAElB,MAAMC,UAAU,eAAA,CAAA,GAAKT,iBAAoBO,UAAAA,GAGnCG,2BAA2B,SAC/BC,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,QAAAA,EAAAA,GAAnB,OAAA,EAAA,6BAAA,QAAA,UAAA,KAAA,GAAA,OAAA,4BAAA,IAAkC;AAAlC,YAAMkD,YAAN,MAAA;AACH,YAAI3D,WAAWgF,aAAarB,SAAAA;AAC1B,iBAAO;YACLC,QAAQJ,mBAAmBjD,iBAAiB0E,kBAAkBtB;YAC9DA;UACF;MAEJ;;AAPK,0BAAA,IAAA,iBAAA;;;SAAA,6BAAA,UAAA,UAAA,QAAA,UAAA,OAAA;;YAAA;gBAAA;;;EAQP,MAAO,QAAIjD,aAAaqE,SAASrB,iBAAAA,IACxB;IACLE,QAAQJ,kBAAkBE;IAC1BC,WAAWD;EACb,IAEO;IACLE,QAAQJ,kBAAkBhD;IAC1BmD,WAAWnD;EACb;AAGF,SAAO;AACT;",
5
+ "names": ["existsSync", "readFileSync", "lstatSync", "resolve", "extname", "dirname", "DEFAULT_OPTIONS", "ensureFileExists", "esExtensionDefault", "tryExtensions", "esExtensions", "includePackages", "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", "packageData", "isLocalFile", "some", "startsWith", "getPackageData", "isDeepImport", "isDirectory", "isLocalDirectory", "currentModuleExtension", "targetModule", "evaluateTargetModule", "moduleSpecifier", "filenameDirectory", "filenameExtension", "extension", "module", "modulePath", "require", "paths", "parts", "split", "packageDir", "i", "length", "dir", "slice", "join", "Error", "packageJson", "JSON", "parse", "toString", "endsWith", "absoluteDirectory", "includes", "targetFile", "forceExtension"]
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/babel-plugin-fully-specified",
3
- "version": "1.101.7",
3
+ "version": "1.102.0",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -15,10 +15,11 @@
15
15
  "access": "public"
16
16
  },
17
17
  "scripts": {
18
- "build": "node ../../../node_modules/.bin/tamagui-build",
19
- "watch": "node ../../../node_modules/.bin/tamagui-build --watch",
18
+ "build": "node ../../../node_modules/.bin/tamagui-build --exclude __tests__",
19
+ "watch": "node ../../../node_modules/.bin/tamagui-build --exclude __tests__ --watch",
20
20
  "lint": "npx biome check src",
21
21
  "lint:fix": "npx biome check --apply-unsafe src",
22
+ "test": "vitest --run",
22
23
  "clean": "node ../../../node_modules/.bin/tamagui-build clean",
23
24
  "clean:build": "node ../../../node_modules/.bin/tamagui-build clean:build"
24
25
  },
@@ -26,7 +27,8 @@
26
27
  "@babel/core": "^7.23.3"
27
28
  },
28
29
  "devDependencies": {
29
- "@babel/types": "^7.23.3"
30
+ "@babel/types": "^7.23.3",
31
+ "vitest": "^0.34.3"
30
32
  },
31
33
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
32
34
  }
@@ -0,0 +1,21 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`transforming actual files > multiple extensions exists 1`] = `
4
+ "// Expected to be transformed to use the \`.mjs\` extension, which is same as this file.
5
+ import { foo, bar } from \\"./modules/module.mjs\\";"
6
+ `;
7
+
8
+ exports[`transforming actual files > test 1`] = `
9
+ "import foo, { bar } from \\"./modules/module.mjs\\";
10
+ import { foo as foo2 } from \\"./modules/module.mjs\\";
11
+ import * as someModule from \\"./modules/module.mjs\\";
12
+ import { foo as cjsFoo } from \\"./modules/cjs-module.cjs\\";
13
+
14
+ // Will not be transformed
15
+ import { foo as packageFoo } from '@my-org/my-pkg';
16
+
17
+ // These will be transformed if \`includePackages\` includes \`@my-org/my-pkg\`.
18
+ import { someStuff } from \\"@my-org/my-pkg/lib/index.js\\";
19
+ // import { someOtherStuff } from '@my-org/my-pkg/lib/index' // TODO: Fix me
20
+ import { exampleFunction } from \\"@my-org/my-pkg/lib/exampleFunction.js\\";"
21
+ `;
@@ -0,0 +1 @@
1
+ export const bar = 'bar'
@@ -0,0 +1 @@
1
+ import { bar } from './bar'
@@ -0,0 +1,2 @@
1
+ exports.foo = 'foo'
2
+ exports.bar = 'bar'
@@ -0,0 +1,2 @@
1
+ exports.foo = 'foo'
2
+ exports.bar = 'bar'
@@ -0,0 +1,4 @@
1
+ export const foo = 'foo'
2
+ export const bar = 'bar'
3
+
4
+ export default foo
@@ -0,0 +1,2 @@
1
+ // Expected to be transformed to use the `.mjs` extension, which is same as this file.
2
+ import { foo, bar } from './modules/module'
@@ -0,0 +1,2 @@
1
+ exports.foo = 'foo'
2
+ exports.bar = 'bar'
@@ -0,0 +1,4 @@
1
+ export const foo = 'foo'
2
+ export const bar = 'bar'
3
+
4
+ export default foo
@@ -0,0 +1,3 @@
1
+ exports.exampleFunction = function exampleFunction() {
2
+ return null
3
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "@my-org/my-pkg",
3
+ "main": "lib/index.js"
4
+ }
@@ -0,0 +1 @@
1
+ Note: this is a mocked node_modules directory which is a part of the test mock setup. It is not a real node_modules directory created by package managers and should be commited into the repository.
@@ -0,0 +1,13 @@
1
+ import foo, { bar } from './modules/module'
2
+ import { foo as foo2 } from './modules/module'
3
+ import * as someModule from './modules/module'
4
+
5
+ import { foo as cjsFoo } from './modules/cjs-module'
6
+
7
+ // Will not be transformed
8
+ import { foo as packageFoo } from '@my-org/my-pkg'
9
+
10
+ // These will be transformed if `includePackages` includes `@my-org/my-pkg`.
11
+ import { someStuff } from '@my-org/my-pkg/lib'
12
+ // import { someOtherStuff } from '@my-org/my-pkg/lib/index' // TODO: Fix me
13
+ import { exampleFunction } from '@my-org/my-pkg/lib/exampleFunction'
@@ -0,0 +1,139 @@
1
+ import path from 'node:path'
2
+ import { describe, expect, test } from 'vitest'
3
+ import { type TransformOptions, transform, transformFileSync } from '@babel/core'
4
+
5
+ import plugin, { type FullySpecifiedOptions } from '../'
6
+
7
+ /** A helper function to get the default transform options for the plugin to test. */
8
+ const getTransformOptions = ({
9
+ pluginOptions,
10
+ }: { pluginOptions?: Partial<FullySpecifiedOptions> } = {}) => ({
11
+ plugins: [[plugin, { ensureFileExists: false, ...pluginOptions }]],
12
+ })
13
+
14
+ /** A test helper for calling Babel transform with the plugin to test and some default options. */
15
+ function getTransformResult(
16
+ input,
17
+ {
18
+ transformOptions,
19
+ pluginOptions,
20
+ }: {
21
+ transformOptions?: TransformOptions
22
+ pluginOptions?: Partial<FullySpecifiedOptions>
23
+ } = {}
24
+ ) {
25
+ return transform(input, {
26
+ filename: 'myFile.js',
27
+ configFile: false,
28
+ ...transformOptions,
29
+ ...getTransformOptions({ pluginOptions }),
30
+ })
31
+ }
32
+
33
+ describe('local imports', () => {
34
+ test('named import', () => {
35
+ const example1 = "import { foo } from './foo'"
36
+ expect(getTransformResult(example1)?.code).toBe('import { foo } from "./foo.js";')
37
+
38
+ const example2 = "import { foo as bar } from './foo'"
39
+ expect(getTransformResult(example2)?.code).toBe(
40
+ 'import { foo as bar } from "./foo.js";'
41
+ )
42
+ })
43
+
44
+ test('default import', () => {
45
+ const example1 = "import defaultFoo from './foo'"
46
+ expect(getTransformResult(example1)?.code).toBe('import defaultFoo from "./foo.js";')
47
+
48
+ const example2 = "import defaultFoo, { foo } from './foo'"
49
+ expect(getTransformResult(example2)?.code).toBe(
50
+ 'import defaultFoo, { foo } from "./foo.js";'
51
+ )
52
+ })
53
+
54
+ test('namespace import', () => {
55
+ const example = "import * as fooModule from './foo'"
56
+ expect(getTransformResult(example)?.code).toBe(
57
+ 'import * as fooModule from "./foo.js";'
58
+ )
59
+ })
60
+
61
+ test('side effects only import', () => {
62
+ const example = "import './foo'"
63
+ expect(getTransformResult(example)?.code).toBe('import "./foo.js";')
64
+ })
65
+
66
+ test('dynamic import()', () => {
67
+ const example = "const foo = await import('./foo')"
68
+ expect(getTransformResult(example)?.code).toBe(
69
+ 'const foo = await import("./foo.js");'
70
+ )
71
+ })
72
+ })
73
+
74
+ describe('local re-exports', () => {
75
+ test('named', () => {
76
+ const example1 = "export { foo } from './foo'"
77
+ expect(getTransformResult(example1)?.code).toBe('export { foo } from "./foo.js";')
78
+
79
+ const example2 = "export { foo as bar } from './foo'"
80
+ expect(getTransformResult(example2)?.code).toBe(
81
+ 'export { foo as bar } from "./foo.js";'
82
+ )
83
+ })
84
+
85
+ test('default', () => {
86
+ const example1 = "export { default as fooDefault } from './foo'"
87
+ expect(getTransformResult(example1)?.code).toBe(
88
+ 'export { default as fooDefault } from "./foo.js";'
89
+ )
90
+ })
91
+
92
+ test('namespace', () => {
93
+ const example1 = "export * as fooModule from './foo'"
94
+ expect(getTransformResult(example1)?.code).toBe(
95
+ 'export * as fooModule from "./foo.js";'
96
+ )
97
+
98
+ const example2 = "export * from './foo'"
99
+ expect(getTransformResult(example2)?.code).toBe('export * from "./foo.js";')
100
+ })
101
+ })
102
+
103
+ describe('transforming actual files', () => {
104
+ test('test', () => {
105
+ const { code } =
106
+ transformFileSync(
107
+ path.join(__dirname, 'fixtures', 'sample-project-1', 'test.mjs'),
108
+ getTransformOptions({
109
+ pluginOptions: { ensureFileExists: true, includePackages: ['@my-org/my-pkg'] },
110
+ })
111
+ ) || {}
112
+
113
+ expect(code).toMatchSnapshot()
114
+ })
115
+
116
+ test('multiple extensions exists', () => {
117
+ const { code } =
118
+ transformFileSync(
119
+ path.join(__dirname, 'fixtures', 'multiple-extensions-exists', 'test.mjs'),
120
+ getTransformOptions({
121
+ pluginOptions: { ensureFileExists: true },
122
+ })
123
+ ) || {}
124
+
125
+ expect(code).toMatchSnapshot()
126
+ })
127
+
128
+ test('force extension', () => {
129
+ const { code } =
130
+ transformFileSync(
131
+ path.join(__dirname, 'fixtures', 'force-extension', 'foo.js'),
132
+ getTransformOptions({
133
+ pluginOptions: { ensureFileExists: { forceExtension: '.mjs' } },
134
+ })
135
+ ) || {}
136
+
137
+ expect(code).toBe('import { bar } from "./bar.mjs";')
138
+ })
139
+ })