Skip to content

Commit bfc81b4

Browse files
committed
remove unwrapExports entirely
1 parent 92166de commit bfc81b4

File tree

4 files changed

+7
-95
lines changed

4 files changed

+7
-95
lines changed

β€Žpackages/commonjs/src/helpers.jsβ€Ž

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ export const HELPERS_ID = '\0commonjsHelpers.js';
2323
export const HELPERS = `
2424
export var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2525
26-
export function unwrapExports (x) {
27-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
28-
}
29-
3026
export function createCommonjsModule(fn, basedir, module) {
3127
return module = {
3228
path: basedir,

β€Žpackages/commonjs/src/transform.jsβ€Ž

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,7 @@ export function transformCommonjs(
642642
}
643643
}
644644

645-
const defaultExport = /__esModule/.test(code)
646-
? `export default /*@__PURE__*/${HELPERS_NAME}.unwrapExports(${moduleName});`
647-
: `export default ${moduleName};`;
645+
const defaultExport = `export default ${moduleName};`;
648646

649647
const named = namedExportDeclarations
650648
.filter((x) => x.name !== 'default' || !hasDefaultExport)

β€Žpackages/commonjs/test/snapshots/function.js.mdβ€Ž

Lines changed: 6 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ Generated by [AVA](https://ava.li).
1111
{
1212
'main.js': `'use strict';␊
1313
␊
14-
function unwrapExports (x) {␊
15-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
16-
}␊
17-
␊
1814
function createCommonjsModule(fn, basedir, module) {␊
1915
return module = {␊
2016
path: basedir,␊
@@ -35,10 +31,8 @@ Generated by [AVA](https://ava.li).
3531
exports.answer = 42;␊
3632
});␊
3733
␊
38-
var answer$1 = /*@__PURE__*/unwrapExports(answer);␊
39-
␊
40-
var x = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), answer$1, {␊
41-
'default': answer$1,␊
34+
var x = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), answer, {␊
35+
'default': answer,␊
4236
__moduleExports: answer␊
4337
}));␊
4438
␊
@@ -263,10 +257,6 @@ Generated by [AVA](https://ava.li).
263257
␊
264258
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
265259
␊
266-
function unwrapExports (x) {␊
267-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
268-
}␊
269-
␊
270260
function createCommonjsModule(fn, basedir, module) {␊
271261
return module = {␊
272262
path: basedir,␊
@@ -420,7 +410,6 @@ Generated by [AVA](https://ava.li).
420410
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
421411
__proto__: null,␊
422412
commonjsGlobal: commonjsGlobal,␊
423-
unwrapExports: unwrapExports,␊
424413
createCommonjsModule: createCommonjsModule,␊
425414
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
426415
commonjsRegister: commonjsRegister,␊
@@ -466,10 +455,6 @@ Generated by [AVA](https://ava.li).
466455
␊
467456
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
468457
␊
469-
function unwrapExports (x) {␊
470-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
471-
}␊
472-
␊
473458
function createCommonjsModule(fn, basedir, module) {␊
474459
return module = {␊
475460
path: basedir,␊
@@ -623,7 +608,6 @@ Generated by [AVA](https://ava.li).
623608
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
624609
__proto__: null,␊
625610
commonjsGlobal: commonjsGlobal,␊
626-
unwrapExports: unwrapExports,␊
627611
createCommonjsModule: createCommonjsModule,␊
628612
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
629613
commonjsRegister: commonjsRegister,␊
@@ -665,10 +649,6 @@ Generated by [AVA](https://ava.li).
665649
␊
666650
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
667651
␊
668-
function unwrapExports (x) {␊
669-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
670-
}␊
671-
␊
672652
function createCommonjsModule(fn, basedir, module) {␊
673653
return module = {␊
674654
path: basedir,␊
@@ -822,7 +802,6 @@ Generated by [AVA](https://ava.li).
822802
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
823803
__proto__: null,␊
824804
commonjsGlobal: commonjsGlobal,␊
825-
unwrapExports: unwrapExports,␊
826805
createCommonjsModule: createCommonjsModule,␊
827806
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
828807
commonjsRegister: commonjsRegister,␊
@@ -883,10 +862,6 @@ Generated by [AVA](https://ava.li).
883862
␊
884863
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
885864
␊
886-
function unwrapExports (x) {␊
887-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
888-
}␊
889-
␊
890865
function createCommonjsModule(fn, basedir, module) {␊
891866
return module = {␊
892867
path: basedir,␊
@@ -1040,7 +1015,6 @@ Generated by [AVA](https://ava.li).
10401015
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
10411016
__proto__: null,␊
10421017
commonjsGlobal: commonjsGlobal,␊
1043-
unwrapExports: unwrapExports,␊
10441018
createCommonjsModule: createCommonjsModule,␊
10451019
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
10461020
commonjsRegister: commonjsRegister,␊
@@ -1067,14 +1041,10 @@ Generated by [AVA](https://ava.li).
10671041
> Snapshot 1
10681042
10691043
{
1070-
'lib2-07a971d0.js': `'use strict';␊
1044+
'lib2-f863e9df.js': `'use strict';␊
10711045
␊
10721046
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
10731047
␊
1074-
function unwrapExports (x) {␊
1075-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
1076-
}␊
1077-
␊
10781048
function createCommonjsModule(fn, basedir, module) {␊
10791049
return module = {␊
10801050
path: basedir,␊
@@ -1228,7 +1198,6 @@ Generated by [AVA](https://ava.li).
12281198
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
12291199
__proto__: null,␊
12301200
commonjsGlobal: commonjsGlobal,␊
1231-
unwrapExports: unwrapExports,␊
12321201
createCommonjsModule: createCommonjsModule,␊
12331202
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
12341203
commonjsRegister: commonjsRegister,␊
@@ -1262,7 +1231,7 @@ Generated by [AVA](https://ava.li).
12621231
`,
12631232
'main.js': `'use strict';␊
12641233
␊
1265-
var lib2 = require('./lib2-07a971d0.js');␊
1234+
var lib2 = require('./lib2-f863e9df.js');␊
12661235
␊
12671236
/* eslint-disable import/no-dynamic-require, global-require */␊
12681237
␊
@@ -1279,7 +1248,7 @@ Generated by [AVA](https://ava.li).
12791248
`,
12801249
'main2.js': `'use strict';␊
12811250
␊
1282-
require('./lib2-07a971d0.js');␊
1251+
require('./lib2-f863e9df.js');␊
12831252
␊
12841253
`,
12851254
}
@@ -1293,10 +1262,6 @@ Generated by [AVA](https://ava.li).
12931262
␊
12941263
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
12951264
␊
1296-
function unwrapExports (x) {␊
1297-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
1298-
}␊
1299-
␊
13001265
function createCommonjsModule(fn, basedir, module) {␊
13011266
return module = {␊
13021267
path: basedir,␊
@@ -1450,7 +1415,6 @@ Generated by [AVA](https://ava.li).
14501415
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
14511416
__proto__: null,␊
14521417
commonjsGlobal: commonjsGlobal,␊
1453-
unwrapExports: unwrapExports,␊
14541418
createCommonjsModule: createCommonjsModule,␊
14551419
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
14561420
commonjsRegister: commonjsRegister,␊
@@ -1483,10 +1447,6 @@ Generated by [AVA](https://ava.li).
14831447
␊
14841448
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
14851449
␊
1486-
function unwrapExports (x) {␊
1487-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
1488-
}␊
1489-
␊
14901450
function createCommonjsModule(fn, basedir, module) {␊
14911451
return module = {␊
14921452
path: basedir,␊
@@ -1640,7 +1600,6 @@ Generated by [AVA](https://ava.li).
16401600
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
16411601
__proto__: null,␊
16421602
commonjsGlobal: commonjsGlobal,␊
1643-
unwrapExports: unwrapExports,␊
16441603
createCommonjsModule: createCommonjsModule,␊
16451604
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
16461605
commonjsRegister: commonjsRegister,␊
@@ -1679,10 +1638,6 @@ Generated by [AVA](https://ava.li).
16791638
␊
16801639
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
16811640
␊
1682-
function unwrapExports (x) {␊
1683-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
1684-
}␊
1685-
␊
16861641
function createCommonjsModule(fn, basedir, module) {␊
16871642
return module = {␊
16881643
path: basedir,␊
@@ -1836,7 +1791,6 @@ Generated by [AVA](https://ava.li).
18361791
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
18371792
__proto__: null,␊
18381793
commonjsGlobal: commonjsGlobal,␊
1839-
unwrapExports: unwrapExports,␊
18401794
createCommonjsModule: createCommonjsModule,␊
18411795
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
18421796
commonjsRegister: commonjsRegister,␊
@@ -1888,10 +1842,6 @@ Generated by [AVA](https://ava.li).
18881842
␊
18891843
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
18901844
␊
1891-
function unwrapExports (x) {␊
1892-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
1893-
}␊
1894-
␊
18951845
function createCommonjsModule(fn, basedir, module) {␊
18961846
return module = {␊
18971847
path: basedir,␊
@@ -2045,7 +1995,6 @@ Generated by [AVA](https://ava.li).
20451995
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
20461996
__proto__: null,␊
20471997
commonjsGlobal: commonjsGlobal,␊
2048-
unwrapExports: unwrapExports,␊
20491998
createCommonjsModule: createCommonjsModule,␊
20501999
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
20512000
commonjsRegister: commonjsRegister,␊
@@ -2095,10 +2044,6 @@ Generated by [AVA](https://ava.li).
20952044
␊
20962045
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
20972046
␊
2098-
function unwrapExports (x) {␊
2099-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
2100-
}␊
2101-
␊
21022047
function createCommonjsModule(fn, basedir, module) {␊
21032048
return module = {␊
21042049
path: basedir,␊
@@ -2252,7 +2197,6 @@ Generated by [AVA](https://ava.li).
22522197
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
22532198
__proto__: null,␊
22542199
commonjsGlobal: commonjsGlobal,␊
2255-
unwrapExports: unwrapExports,␊
22562200
createCommonjsModule: createCommonjsModule,␊
22572201
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
22582202
commonjsRegister: commonjsRegister,␊
@@ -2296,10 +2240,6 @@ Generated by [AVA](https://ava.li).
22962240
␊
22972241
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
22982242
␊
2299-
function unwrapExports (x) {␊
2300-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
2301-
}␊
2302-
␊
23032243
function createCommonjsModule(fn, basedir, module) {␊
23042244
return module = {␊
23052245
path: basedir,␊
@@ -2453,7 +2393,6 @@ Generated by [AVA](https://ava.li).
24532393
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
24542394
__proto__: null,␊
24552395
commonjsGlobal: commonjsGlobal,␊
2456-
unwrapExports: unwrapExports,␊
24572396
createCommonjsModule: createCommonjsModule,␊
24582397
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
24592398
commonjsRegister: commonjsRegister,␊
@@ -2514,10 +2453,6 @@ Generated by [AVA](https://ava.li).
25142453
␊
25152454
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
25162455
␊
2517-
function unwrapExports (x) {␊
2518-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
2519-
}␊
2520-
␊
25212456
function createCommonjsModule(fn, basedir, module) {␊
25222457
return module = {␊
25232458
path: basedir,␊
@@ -2671,7 +2606,6 @@ Generated by [AVA](https://ava.li).
26712606
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
26722607
__proto__: null,␊
26732608
commonjsGlobal: commonjsGlobal,␊
2674-
unwrapExports: unwrapExports,␊
26752609
createCommonjsModule: createCommonjsModule,␊
26762610
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
26772611
commonjsRegister: commonjsRegister,␊
@@ -2718,10 +2652,6 @@ Generated by [AVA](https://ava.li).
27182652
␊
27192653
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
27202654
␊
2721-
function unwrapExports (x) {␊
2722-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
2723-
}␊
2724-
␊
27252655
function createCommonjsModule(fn, basedir, module) {␊
27262656
return module = {␊
27272657
path: basedir,␊
@@ -2875,7 +2805,6 @@ Generated by [AVA](https://ava.li).
28752805
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
28762806
__proto__: null,␊
28772807
commonjsGlobal: commonjsGlobal,␊
2878-
unwrapExports: unwrapExports,␊
28792808
createCommonjsModule: createCommonjsModule,␊
28802809
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
28812810
commonjsRegister: commonjsRegister,␊
@@ -2914,10 +2843,6 @@ Generated by [AVA](https://ava.li).
29142843
␊
29152844
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
29162845
␊
2917-
function unwrapExports (x) {␊
2918-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
2919-
}␊
2920-
␊
29212846
function createCommonjsModule(fn, basedir, module) {␊
29222847
return module = {␊
29232848
path: basedir,␊
@@ -3071,7 +2996,6 @@ Generated by [AVA](https://ava.li).
30712996
var _commonjsHelpers = /*#__PURE__*/Object.freeze({␊
30722997
__proto__: null,␊
30732998
commonjsGlobal: commonjsGlobal,␊
3074-
unwrapExports: unwrapExports,␊
30752999
createCommonjsModule: createCommonjsModule,␊
30763000
getCjsExportFromNamespace: getCjsExportFromNamespace,␊
30773001
commonjsRegister: commonjsRegister,␊
@@ -3551,10 +3475,6 @@ Generated by [AVA](https://ava.li).
35513475
{
35523476
'main.js': `'use strict';␊
35533477
␊
3554-
function unwrapExports (x) {␊
3555-
return x && !x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
3556-
}␊
3557-
␊
35583478
function createCommonjsModule(fn, basedir, module) {␊
35593479
return module = {␊
35603480
path: basedir,␊
@@ -3587,9 +3507,7 @@ Generated by [AVA](https://ava.li).
35873507
exports.Bar = commonjsBar.default;␊
35883508
});␊
35893509
␊
3590-
var commonjsFoo$1 = /*@__PURE__*/unwrapExports(commonjsFoo);␊
3591-
␊
3592-
t.is(new commonjsFoo$1.Bar().x, 42);␊
3510+
t.is(new commonjsFoo.Bar().x, 42);␊
35933511
`,
35943512
}
35953513

-159 Bytes
Binary file not shown.

0 commit comments

Comments
Β (0)