If there's an import/export declaration, we know that this is a module and that it's therefore safe to a) mangle/remove top-level declarations, and b) remove 'use strict' pragmas.
Probably makes sense to have a module: true option to force it, in cases where there's no import/export.
(The mangling part also applies to CommonJS but I'm not sure it's worth worrying about that — it's rare to minify stuff for Node, and CommonJS will die out soon enough anyway.)
If there's an
import
/export
declaration, we know that this is a module and that it's therefore safe to a) mangle/remove top-level declarations, and b) remove 'use strict' pragmas.Probably makes sense to have a
module: true
option to force it, in cases where there's noimport
/export
.(The mangling part also applies to CommonJS but I'm not sure it's worth worrying about that — it's rare to minify stuff for Node, and CommonJS will die out soon enough anyway.)