Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(treeshaking): allowing treeshaking in terser
The code currently generated by this plugin looks something like the following when building a library: src/index.js ```js export {default as Foo} from './component.vue'; ``` ```js var __component__ = /*#__PURE__*/ normalizeComponent(...) var Foo = __component__.exports ``` In the event you aren't actually using the Foo export, using a minifier like Terser, this code is unable to be dropped because Terser assumes that property access (__component__.exports) is not side-effect free and as a result it decides it can not drop it, and thus it can't drop the rest of the components. To work around this, I have wrapped the `__component__.exports` statement in a function so that we can mark the function invokation as `#__PURE__` and thus allow for unused components to be dropped fully. The resulting code looks like: ```js var __component__ = /*#__PURE__*/ normalizeComponent(...) var Foo = /*#__PURE__*/ getExports(__component__) ```
- Loading branch information