Skip to content

Latest commit

 

History

History
222 lines (180 loc) · 8.19 KB

table.md

File metadata and controls

222 lines (180 loc) · 8.19 KB

Import behavior matrix

What is available as a result of import * as namespace from "x.cjs"

❌ - missing
☑ - own property, but falsy
✔️ - truthy

endo node-v12 node-v12 node-v16 node-v20 bun esbuild parcel rollup tsc tscInterop webpack
1.cjs even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
1.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
1.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
2.cjs even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
2.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
2.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
3.cjs even ✔️ ✔️ ✔️ ✔️ ✔️
3.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
3.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
4.cjs even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
4.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
4.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
5.cjs even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
5.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
5.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
6.cjs even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
6.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
6.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
7.cjs even
7.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
7.cjs default.even
8.cjs even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
8.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
8.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
9.cjs even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
9.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
9.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
10.cjs even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
10.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
10.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
11.cjs even
11.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
11.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️
12.cjs even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
12.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
12.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
13.cjs even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
13.cjs default ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
13.cjs default.even ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
endo node-v12 node-v12 node-v16 node-v20 bun esbuild parcel rollup tsc tscInterop webpack

Matching results

  • 2,5,
  • 9,10

Cases

file 1.cjs

module.exports = {
  even: n => n % 2 === 0
};

file 2.cjs

module.exports = {
  version: '1.1.0',
  even: n => n % 2 === 0
};

file 3.cjs

let o = Object.create({ even: n => n % 2 === 0 })
module.exports = o;

file 4.cjs

Object.defineProperty(exports, 'even', {
  enumerable: false,
  value: n => n % 2 === 0
})

file 5.cjs

const api = {
  version: '1.1.0',
  even: n => n % 2 === 0,
}
module.exports = api

file 6.cjs

const even = n => n % 2 === 0;

// "The Infamous Triplet"
module.exports = even
module.exports.even = even
module.exports.default = even

file 7.cjs

if (false) {
    exports.even = true
}

file 8.cjs

const even = n => n % 2 === 0;

module.exports = {
    even,
    default: { even: false }
}

file 9.cjs

'use strict';
// derived from real package
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, '__esModule', { value: true });
const stuff = { even: n => n % 2 === 0 };
__exportStar(stuff, exports);

file 10.cjs

'use strict';
// derived from real package
var letsCallItSomethingElse = exports;
function defineThingy(name) {
  Object.defineProperty(letsCallItSomethingElse, name, {
    configurable: true,
    enumerable: true,
    get: function() {
      Object.defineProperty(letsCallItSomethingElse, name, {
        configurable: true,
        enumerable: true,
        value: true
      });
      return true
    },
  });
}
defineThingy('even')

file 11.cjs

exports.__esModule = true;
exports.default = {
  even: n => n % 2 === 0
};

file 12.cjs

// should be exactly the same as 9
exports.__esModule = true;
exports.even = n => n % 2 === 0

file 13.cjs

//popular shape of typescript output for reexports
const ex = require('./1.cjs');
Object.defineProperty(exports, 'even', {
  enumerable: true,
  get() {
    return ex.even
  }
});


<style> /* these are useful locally */ tr:nth-child(3n+1){ border-top:2px solid #333 !important; } td:nth-child(n+1){ background-color: #eee !important; } </style>