Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed May 27, 2022
1 parent 5d3ce18 commit cf29e77
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
@@ -0,0 +1,7 @@
module.exports = function () {
if(process.env.ABC === 'a') {
return require("./unused.js");
} else {
return "ok";
}
};
@@ -0,0 +1 @@
module.exports = "unused";
22 changes: 22 additions & 0 deletions packages/core/integration-tests/test/javascript.js
Expand Up @@ -347,6 +347,28 @@ describe('javascript', function () {
assert(!contents.includes('import'));
});

it('should ignore unused requires after process.env inlining', async function () {
let b = await bundle(
path.join(__dirname, '/integration/env-unused-require/index.js'),
{
env: {ABC: 'XYZ'},
},
);

assertBundles(b, [
{
type: 'js',
assets: ['index.js'],
},
]);

let contents = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
assert(!contents.includes('unused'));

let output = await run(b);
assert.strictEqual(output(), 'ok');
});

it('should produce a basic JS bundle with object rest spread support', async function () {
let b = await bundle(
path.join(
Expand Down

0 comments on commit cf29e77

Please sign in to comment.