Skip to content

Instantly share code, notes, and snippets.

@tbranyen
Last active September 27, 2018 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbranyen/8648019e37e7d65a9100b5c5907669c2 to your computer and use it in GitHub Desktop.
Save tbranyen/8648019e37e7d65a9100b5c5907669c2 to your computer and use it in GitHub Desktop.
CommonJS Tree Shaking Test Case
it('will treekshake a static named import', async () => {
const input = register('./a')`
const { a } = require('./b');
console.log(a);
`;
register('./b')`
function b() {}
exports.a = 'hello world';
exports.b = b;
`;
const { source } = await webapp({
...defaults,
input,
inputType,
});
equal(source.code, format`
var module = {
exports: {}
};
var exports = module.exports;
exports.a = 'hello world';
const a = exports.a;
var a_module_1 = {
exports: {}
};
var a_exports_1 = a_module_1.exports;
console.log(a);
this.webapp = a_module_1.exports;
`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment