bare-module 3.1.11 → 3.1.12
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/index.js +20 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -132,7 +132,7 @@ const Module = module.exports = exports = class Module {
|
|
|
132
132
|
|
|
133
133
|
if (this._type === constants.types.MODULE) return
|
|
134
134
|
|
|
135
|
-
const names = ['default']
|
|
135
|
+
const names = new Set(['default'])
|
|
136
136
|
const queue = [this]
|
|
137
137
|
const seen = new Set()
|
|
138
138
|
|
|
@@ -147,7 +147,7 @@ const Module = module.exports = exports = class Module {
|
|
|
147
147
|
case constants.types.SCRIPT: {
|
|
148
148
|
const result = parse(module._function.toString())
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
for (const name of result.exports) names.add(name)
|
|
151
151
|
|
|
152
152
|
const referrer = module
|
|
153
153
|
|
|
@@ -165,20 +165,16 @@ const Module = module.exports = exports = class Module {
|
|
|
165
165
|
case constants.types.MODULE:
|
|
166
166
|
module._evaluate()
|
|
167
167
|
|
|
168
|
-
for (const name of Object.keys(module._exports))
|
|
169
|
-
names.push(name)
|
|
170
|
-
}
|
|
168
|
+
for (const name of Object.keys(module._exports)) names.add(name)
|
|
171
169
|
|
|
172
170
|
break
|
|
173
171
|
|
|
174
172
|
case constants.types.JSON:
|
|
175
|
-
for (const name of Object.keys(module._exports))
|
|
176
|
-
names.push(name)
|
|
177
|
-
}
|
|
173
|
+
for (const name of Object.keys(module._exports)) names.add(name)
|
|
178
174
|
}
|
|
179
175
|
}
|
|
180
176
|
|
|
181
|
-
this._names = names
|
|
177
|
+
this._names = Array.from(names)
|
|
182
178
|
|
|
183
179
|
this._handle = binding.createSyntheticModule(this._url.href, this._names, Module._handle)
|
|
184
180
|
}
|
|
@@ -296,7 +292,21 @@ const Module = module.exports = exports = class Module {
|
|
|
296
292
|
module._evaluate()
|
|
297
293
|
|
|
298
294
|
for (const name of module._names) {
|
|
299
|
-
|
|
295
|
+
let value
|
|
296
|
+
|
|
297
|
+
if (
|
|
298
|
+
name === 'default' && (
|
|
299
|
+
typeof module._exports !== 'object' ||
|
|
300
|
+
module._exports === null ||
|
|
301
|
+
name in module._exports === false
|
|
302
|
+
)
|
|
303
|
+
) {
|
|
304
|
+
value = module._exports
|
|
305
|
+
} else {
|
|
306
|
+
value = module._exports[name]
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
binding.setExport(module._handle, name, value)
|
|
300
310
|
}
|
|
301
311
|
}
|
|
302
312
|
|