@tamagui/babel-plugin-fully-specified 2.7.7 → 3.0.0-0.canary.1791056644527

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 CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@tamagui/babel-plugin-fully-specified",
3
- "version": "2.7.7",
3
+ "version": "3.0.0-0.canary.1791056644527",
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": {
@@ -40,11 +42,12 @@
40
42
  },
41
43
  "devDependencies": {
42
44
  "@babel/types": "^7.25.4",
43
- "vitest": "4.0.4"
45
+ "vitest": "4.1.0"
44
46
  },
45
47
  "repository": {
46
48
  "type": "git",
47
49
  "url": "git+https://github.com/tamagui/tamagui.git",
48
50
  "directory": "code/packages/babel-plugin-fully-specified"
49
- }
51
+ },
52
+ "releaseSourceCommit": "e09267246167b52afd620a498678f5cce456cb5a"
50
53
  }
@@ -3,81 +3,105 @@ 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) __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
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
- var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: !0 }), mod)
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
- import_node_path = require('node:path')
25
+ var import_node_fs = require('node:fs')
26
+ var import_node_path = require('node:path')
27
27
  function fullySpecifyCommonJS(api, options) {
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
- }
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 (
62
+ cjsExtension.startsWith('.native') &&
63
+ ((0, import_node_fs.existsSync)(`${resolvedPath}.ios.js`) ||
64
+ (0, import_node_fs.existsSync)(`${resolvedPath}.android.js`))
65
+ ) {
66
+ return
67
+ }
68
+ if (isLocalDirectory(resolvedPath)) {
69
+ const indexBase = (0, import_node_path.resolve)(resolvedPath, 'index')
65
70
  if (
66
- (0, import_node_fs.existsSync)(resolvedPath + jsExtension) ||
67
- (0, import_node_fs.existsSync)(resolvedPath + cjsExtension)
71
+ cjsExtension.startsWith('.native') &&
72
+ ((0, import_node_fs.existsSync)(`${indexBase}.ios.js`) ||
73
+ (0, import_node_fs.existsSync)(`${indexBase}.android.js`))
68
74
  ) {
69
- ;((newModuleSpecifier += cjsExtension),
70
- (arg.value = newModuleSpecifier))
75
+ return
76
+ }
77
+ const indexPath = (0, import_node_path.resolve)(
78
+ resolvedPath,
79
+ 'index' + jsExtension
80
+ )
81
+ if ((0, import_node_fs.existsSync)(indexPath)) {
82
+ if (!newModuleSpecifier.endsWith('/')) {
83
+ newModuleSpecifier += '/'
84
+ }
85
+ newModuleSpecifier += 'index' + cjsExtension
86
+ arg.value = newModuleSpecifier
71
87
  return
72
88
  }
73
89
  }
90
+ if (
91
+ (0, import_node_fs.existsSync)(resolvedPath + jsExtension) ||
92
+ (0, import_node_fs.existsSync)(resolvedPath + cjsExtension)
93
+ ) {
94
+ newModuleSpecifier += cjsExtension
95
+ arg.value = newModuleSpecifier
96
+ return
97
+ }
74
98
  }
75
99
  }
76
100
  }
77
- },
101
+ }
78
102
  },
79
- }
80
- )
103
+ },
104
+ }
81
105
  }
82
106
  function isLocalDirectory(absolutePath) {
83
107
  return (
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/commonjs.ts"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsC,oBACtC,mBAA0C;AAE3B,SAAR,qBACL,KACA,SAGiB;AACjB,aAAI,cAAc,CAAC,GAEZ;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,MACP,eAAe,MAAM,OAAO;AAG1B,YAFe,KAAK,IAAI,QAAQ,EAGvB,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,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YAAY,EAAE,YAAY;AACzE;",
5
5
  "names": []
6
6
  }
@@ -2,169 +2,185 @@ var __create = Object.create
2
2
  var __defProp = Object.defineProperty
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty
5
+ var __getProtoOf = Object.getPrototypeOf
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty
7
7
  var __export = (target, all) => {
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
8
+ for (var name in all) __defProp(target, name, { get: all[name], enumerable: true })
9
+ }
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if ((from && typeof from === 'object') || typeof from === 'function') {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
+ })
20
18
  }
19
+ return to
20
+ }
21
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)
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: true })
30
+ : target,
31
+ mod
32
+ )
33
+ )
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: true }), mod)
35
35
  var index_exports = {}
36
36
  __export(index_exports, {
37
37
  default: () => FullySpecified,
38
38
  })
39
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'))
40
+ var import_node_fs = require('node:fs')
41
+ var import_node_path = require('node:path')
42
+ var t = __toESM(require('@babel/types'))
43
43
  const DEFAULT_OPTIONS = {
44
- ensureFileExists: !0,
44
+ ensureFileExists: true,
45
45
  esExtensionDefault: '.mjs',
46
46
  tryExtensions: ['.js'],
47
47
  esExtensions: ['.mjs'],
48
- convertProcessEnvToImportMetaEnv: !1,
48
+ convertProcessEnvToImportMetaEnv: false,
49
49
  }
50
50
  function FullySpecified(api, rawOptions = {}) {
51
51
  api.assertVersion(7)
52
- const options = normalizeOptions(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)
52
+ const options = normalizeOptions(rawOptions)
53
+ const 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
+ const fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(
60
+ originalModuleSpecifier,
61
+ {
62
+ filePath,
63
+ options,
64
+ }
65
+ )
66
+ if (fullySpecifiedModuleSpecifier) {
67
+ node.source.value = fullySpecifiedModuleSpecifier
68
+ }
69
+ }
70
+ const exportDeclarationVisitor = (path, state) => {
71
+ const filePath = state.file.opts.filename
72
+ if (!filePath) return
73
+ const { node } = path
74
+ if (node.exportKind === 'type') return
75
+ const source = node.source
76
+ if (!source) return
77
+ const originalModuleSpecifier = source.value
78
+ const fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(
79
+ originalModuleSpecifier,
80
+ {
81
+ filePath,
82
+ options,
83
+ }
84
+ )
85
+ if (fullySpecifiedModuleSpecifier) {
86
+ source.value = fullySpecifiedModuleSpecifier
84
87
  }
88
+ }
89
+ const importVisitor = (path, state) => {
90
+ const filePath = state.file.opts.filename
91
+ if (!filePath) return
92
+ const parent = path.parent
93
+ if (parent.type !== 'CallExpression') {
94
+ return
95
+ }
96
+ const firstArgOfImportCall = parent.arguments[0]
97
+ if (firstArgOfImportCall.type !== 'StringLiteral') {
98
+ return
99
+ }
100
+ const originalModuleSpecifier = firstArgOfImportCall.value
101
+ const fullySpecifiedModuleSpecifier = getFullySpecifiedModuleSpecifier(
102
+ originalModuleSpecifier,
103
+ {
104
+ filePath,
105
+ options,
106
+ }
107
+ )
108
+ if (fullySpecifiedModuleSpecifier) {
109
+ firstArgOfImportCall.value = fullySpecifiedModuleSpecifier
110
+ }
111
+ }
112
+ const memberExpressionVisitor = (path) => {
113
+ if (!options.convertProcessEnvToImportMetaEnv) return
114
+ const { node } = path
115
+ if (
116
+ node.object.type === 'MemberExpression' &&
117
+ node.object.object.type === 'Identifier' &&
118
+ node.object.object.name === 'process' &&
119
+ node.object.property.type === 'Identifier' &&
120
+ node.object.property.name === 'env'
121
+ ) {
122
+ if (node.property.type === 'Identifier' && node.property.name === 'NODE_ENV') {
123
+ return
124
+ }
125
+ node.object = t.memberExpression(
126
+ t.metaProperty(t.identifier('import'), t.identifier('meta')),
127
+ t.identifier('env')
128
+ )
129
+ }
130
+ }
85
131
  return {
86
132
  name: 'babel-plugin-fully-specified',
87
133
  visitor: {
88
134
  ImportDeclaration: importDeclarationVisitor,
89
135
  ExportNamedDeclaration: exportDeclarationVisitor,
90
136
  ExportAllDeclaration: exportDeclarationVisitor,
91
- Import: (path, state) => {
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)
108
- },
109
- MemberExpression: (path) => {
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
121
- node.object = t.memberExpression(
122
- t.metaProperty(t.identifier('import'), t.identifier('meta')),
123
- t.identifier('env')
124
- )
125
- }
126
- },
137
+ Import: importVisitor,
138
+ MemberExpression: memberExpressionVisitor,
127
139
  },
128
140
  }
129
141
  }
130
142
  function normalizeOptions(rawOptions) {
131
143
  const options = { ...DEFAULT_OPTIONS, ...rawOptions }
132
- return (
144
+ if (
133
145
  rawOptions.esExtensionDefault &&
134
- !rawOptions.tryExtensions &&
135
- rawOptions.esExtensionDefault !== DEFAULT_OPTIONS.esExtensionDefault &&
136
- (options.tryExtensions = [
137
- rawOptions.esExtensionDefault,
138
- ...DEFAULT_OPTIONS.tryExtensions.filter(
139
- (extension) => extension !== rawOptions.esExtensionDefault
140
- ),
141
- ]),
142
- options
143
- )
146
+ !rawOptions.tryExtensions &&
147
+ rawOptions.esExtensionDefault !== DEFAULT_OPTIONS.esExtensionDefault
148
+ ) {
149
+ options.tryExtensions = [
150
+ rawOptions.esExtensionDefault,
151
+ ...DEFAULT_OPTIONS.tryExtensions.filter(
152
+ (extension) => extension !== rawOptions.esExtensionDefault
153
+ ),
154
+ ]
155
+ }
156
+ return options
144
157
  }
145
158
  function getFullySpecifiedModuleSpecifier(
146
159
  originalModuleSpecifier,
147
160
  { filePath, options }
148
161
  ) {
149
- const fileExt = (0, import_node_path.extname)(filePath),
150
- fileDir = (0, import_node_path.dirname)(filePath),
151
- isDirectory = isLocalDirectory(
152
- (0, import_node_path.resolve)(fileDir, originalModuleSpecifier)
153
- ),
154
- currentModuleExtension = (0, import_node_path.extname)(originalModuleSpecifier),
155
- { tryExtensions, esExtensions, esExtensionDefault, ensureFileExists } = options,
156
- targetModule = evaluateTargetModule({
157
- moduleSpecifier: originalModuleSpecifier,
158
- filenameDirectory: fileDir,
159
- filenameExtension: fileExt,
160
- currentModuleExtension,
161
- isDirectory,
162
- tryExtensions,
163
- esExtensions,
164
- esExtensionDefault,
165
- ensureFileExists,
166
- })
167
- return targetModule === !1 ? null : targetModule
162
+ const fileExt = (0, import_node_path.extname)(filePath)
163
+ const fileDir = (0, import_node_path.dirname)(filePath)
164
+ const isDirectory = isLocalDirectory(
165
+ (0, import_node_path.resolve)(fileDir, originalModuleSpecifier)
166
+ )
167
+ const currentModuleExtension = (0, import_node_path.extname)(originalModuleSpecifier)
168
+ const { tryExtensions, esExtensions, esExtensionDefault, ensureFileExists } = options
169
+ const targetModule = evaluateTargetModule({
170
+ moduleSpecifier: originalModuleSpecifier,
171
+ filenameDirectory: fileDir,
172
+ filenameExtension: fileExt,
173
+ currentModuleExtension,
174
+ isDirectory,
175
+ tryExtensions,
176
+ esExtensions,
177
+ esExtensionDefault,
178
+ ensureFileExists,
179
+ })
180
+ if (targetModule === false) {
181
+ return null
182
+ }
183
+ return targetModule
168
184
  }
169
185
  function isLocalDirectory(absoluteDirectory) {
170
186
  return (
@@ -172,6 +188,15 @@ function isLocalDirectory(absoluteDirectory) {
172
188
  (0, import_node_fs.lstatSync)(absoluteDirectory).isDirectory()
173
189
  )
174
190
  }
191
+ function isNativeOutput(esExtensionDefault) {
192
+ return esExtensionDefault.startsWith('.native')
193
+ }
194
+ function hasPlatformSibling(absoluteBasePath) {
195
+ return (
196
+ (0, import_node_fs.existsSync)(`${absoluteBasePath}.ios.js`) ||
197
+ (0, import_node_fs.existsSync)(`${absoluteBasePath}.android.js`)
198
+ )
199
+ }
175
200
  function evaluateTargetModule({
176
201
  moduleSpecifier,
177
202
  currentModuleExtension,
@@ -185,25 +210,37 @@ function evaluateTargetModule({
185
210
  }) {
186
211
  const targetFile = (0, import_node_path.resolve)(filenameDirectory, moduleSpecifier)
187
212
  if (ensureFileExists) {
188
- for (const extension of tryExtensions)
189
- if ((0, import_node_fs.existsSync)(targetFile + extension))
213
+ if (isNativeOutput(esExtensionDefault) && hasPlatformSibling(targetFile)) {
214
+ return false
215
+ }
216
+ for (const extension of tryExtensions) {
217
+ if ((0, import_node_fs.existsSync)(targetFile + extension)) {
190
218
  return moduleSpecifier + esExtensionDefault
191
- if (currentModuleExtension && !esExtensions.includes(currentModuleExtension))
192
- return !1
219
+ }
220
+ }
221
+ if (currentModuleExtension && !esExtensions.includes(currentModuleExtension)) {
222
+ return false
223
+ }
193
224
  if (isDirectory) {
194
- const indexModuleSpecifier = `${moduleSpecifier.replace(/\/$/, '')}/index`,
195
- indexTargetFile = (0, import_node_path.resolve)(
196
- filenameDirectory,
197
- indexModuleSpecifier
198
- )
199
- for (const extension of tryExtensions)
200
- if ((0, import_node_fs.existsSync)(indexTargetFile + extension))
225
+ const indexModuleSpecifier = `${moduleSpecifier.replace(/\/$/, '')}/index`
226
+ const indexTargetFile = (0, import_node_path.resolve)(
227
+ filenameDirectory,
228
+ indexModuleSpecifier
229
+ )
230
+ if (isNativeOutput(esExtensionDefault) && hasPlatformSibling(indexTargetFile)) {
231
+ return false
232
+ }
233
+ for (const extension of tryExtensions) {
234
+ if ((0, import_node_fs.existsSync)(indexTargetFile + extension)) {
201
235
  return indexModuleSpecifier + esExtensionDefault
236
+ }
237
+ }
202
238
  }
203
- } else
204
- return (
205
- esExtensions.includes(filenameExtension), moduleSpecifier + esExtensionDefault
206
- )
207
- return !1
239
+ } else if (esExtensions.includes(filenameExtension)) {
240
+ return moduleSpecifier + esExtensionDefault
241
+ } else {
242
+ return moduleSpecifier + esExtensionDefault
243
+ }
244
+ return false
208
245
  }
209
246
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsC,oBACtC,mBAA0C,sBAG1C,IAAmB;AAoBnB,MAAM,kBAAkB;AAAA,EACtB,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,eAAe,CAAC,KAAK;AAAA,EACrB,cAAc,CAAC,MAAM;AAAA,EACrB,kCAAkC;AACpC;AAEe,SAAR,eACL,KACA,YACW;AACX,MAAI,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