Last active
November 28, 2019 04:22
-
-
Save ScriptedAlchemy/befc896e358d912487cadeb91e0d1300 to your computer and use it in GitHub Desktop.
Modifying tree-shaking module by module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (moduleSource?.indexOf('externalize') > -1 || false) { | |
| module.buildMeta = mergeDeep(module.buildMeta, { isExternalized: true }); | |
| // add exports back to usedExports, prevents tree shaking on module | |
| Object.assign(module, { usedExports: module?.buildMeta?.providedExports || true }); | |
| try { | |
| // look at refactoring this to use buildMeta not mutate id | |
| module.id = moduleSource.match(/\/\*\s*externalize\s*:\s*(\S+)\s*\*\//)[1]; | |
| externalModules[module.id] = {}; | |
| } catch (error) { | |
| throw new Error('external-import', error.message); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment