YahooArchive/strip-loader

Prevents build when encounters convoluted console.log

Opened this issue · 2 comments

doei commented

I'm using strip-loader on a project scaffolded with create-react-app, on which I ran npm run eject

At some point the project wouldn't build anymore, the build process never exited while exhausting all the cpu resources it could find...
After trying to build previous commits to find the breaking change, I managed to have the build work fine again by removing this console.log:

		console.log( (selectedWeek === 0 ? 'first_week' : 'second_week') +
			((startDate.week() + selectedWeek) % 2 === 1 ? "odd" : "even") );

startDate is a moment object if that helps...

Anyway my guess is that this is an issue coming from strip-loader...

Hope it helps

Vijar commented

If you're just stripping console.log, I'd recommend using uglifyjs loader. You can use uglifyjs's drop_console option. Here is what that would look like in a webpack plugin:

new webpack.optimize.UglifyJsPlugin({
    compress: {
        drop_console: true
    }
})

Uglify js would be able to catch all kinds of convoluted invocations of console.log because it uses an ast parser. Hope this helps.

doei commented

Thanks for the tip, I'll try.