Closed PieterSwitten closed 5 years ago
It's a bug, I thought I had a test for this though. Will check it out.
@matthewp my old suggestion was wrong i now see the fail the fail is we import some thing that exports nothing look exactly at his code its not a global that gets treeshaken away he did not export anything so there is nothing
@PieterSwitten this is expected result!
When I do a import like import './foobar.js' It will removed after the build. Inside foobar.js there is only one line with console.log('foobar');.
main.js
import './foobar.js'
foobar.js
console.log('foobar');.
I have to explicit export something before it is not being removed in the build.
foobar.js
console.log('foobar');
export default {};
Then it does work after I have build.
this is because the depdency foobar in the don't works example simply exports nothing this is not what we talk about in 'https://stealjs.com/docs/steal-tools.tree-shaking.html#preventing-code-removal'
Ok, so there is a similar test, however the test exports a function. Once I removed the export the test no longer works. So I was able to recreate this. Now to figure out why...
According to 'https://stealjs.com/docs/steal-tools.tree-shaking.html#preventing-code-removal' the
imports
without a variable should not be removed in the build by tree shaking.When I do a import like
import './foobar.js'
It will removed after the build. Insidefoobar.js
there is only one line withconsole.log('foobar');
.I have to explicit export something before it is not being removed in the build.
Then it does work after I have build.
Is this a bug in the tree shaking or is it the expected result and should we update our code?