This file contains 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
const path = require('path'); | |
const VirtualStats = require('./virtual-stats'); | |
class SyntheticPlugin { | |
constructor(options) { | |
this.options = options; | |
} | |
apply(compiler) { | |
const moduleName = this.options.moduleName; |
This file contains 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] = {}; |
This file contains 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
-Xms1024m | |
-Xmx3072m | |
-Xss64m | |
-XX:ReservedCodeCacheSize=512m | |
-XX:+UseCompressedOops | |
-XX:NewRatio=2 | |
-Dfile.encoding=UTF-8 | |
-XX:+UseConcMarkSweepGC | |
-XX:SoftRefLRUPolicyMSPerMB=250 | |
-XX:NewSize=512m |
This file contains 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
# custom IntelliJ IDEA properties | |
editor.zero.latency.typing=true | |
idea.max.intellisense.filesize=3500 | |
idea.cycle.buffer.size=2048 |
This file contains 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
compiler.hooks.thisCompilation.tap( | |
"FlagEntryExportAsUsedPlugin", | |
compilation => { | |
const moduleGraph = compilation.moduleGraph; | |
compilation.hooks.seal.tap("FlagEntryExportAsUsedPlugin", () => { | |
for (const deps of compilation.entryDependencies.values()) { | |
for (const dep of deps) { | |
const module = moduleGraph.getModule(dep); | |
if (module) { | |
const exportsInfo = moduleGraph.getExportsInfo(module); |
This file contains 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
import React from 'react' | |
import Nav from './components/Menu' //Didnt use {MobileNav}, will be tree shaken | |
export default class App extends React { | |
render(){ | |
return (<Nav>) | |
} | |
} |
This file contains 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
let files = compilation.chunks.reduce((files, chunk) => chunk.files.reduce((files, path) => { | |
let name = chunk.name ? chunk.name : null; | |
const dependencyChains = {}; | |
if (name) { | |
name = `${name}.${this.getFileType(path)}`; | |
} else { | |
// For nameless chunks, just map the files directly. | |
name = path; | |
} | |
// check if the current chunk exists in externalModules, an object that is keeping track of keys |
This file contains 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(!window.entryManifest) {window.entryManifest = {}}; | |
window.entryManifest["some-namespace"] = { | |
"commons.js": { | |
"path": "static/chunks/commons.7343b2658e7f703389c2.js", | |
"dependencies": null, | |
"isInitial": true | |
}, | |
"static/runtime/webpack.js.js": { | |
"path": "static/runtime/webpack-035ac2b14bde147cb4a8.js", |
This file contains 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(!window.entryManifest) {window.entryManifest = {}}; | |
window.entryManifest["some-namespace"] = { | |
"commons.js": { | |
"path": "static/chunks/commons.7343b2658e7f703389c2.js", | |
"isInitial": true | |
}, | |
"static/runtime/webpack.js.js": { | |
"path": "static/runtime/webpack-035ac2b14bde147cb4a8.js", | |
"isInitial": true |
This file contains 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
const createHash = require('webpack/lib/util/createHash'); | |
const usedIds = new Set(); | |
compilation.hooks.beforeModuleIds.tap('URLImportPlugin', (modules) => { | |
for (const module of modules) { | |
// if the module has an id, and its got a path to a real file | |
if (module.id === null && module.resource) { | |
const hash = createHash(this.opts.hashFunction || 'md4'); | |
// grab the resource path, without any loader queries |