Skip to content

Instantly share code, notes, and snippets.

View ScriptedAlchemy's full-sized avatar
🎯
Focusing

Zack Jackson ScriptedAlchemy

🎯
Focusing
View GitHub Profile
@ScriptedAlchemy
ScriptedAlchemy / EnteryManifest.js
Last active November 25, 2019 00:49
Entry Manifest with interleaved dependencies
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",
@ScriptedAlchemy
ScriptedAlchemy / Index.js
Last active November 25, 2019 00:49
Emitting a manifest map with dependencies
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
@ScriptedAlchemy
ScriptedAlchemy / App1.js
Created November 24, 2019 23:38
Tree-shaking drops interleaved modules if not used
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>)
}
}
@ScriptedAlchemy
ScriptedAlchemy / Index.js
Last active November 25, 2019 00:47
Export used in unknown ways
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);
@ScriptedAlchemy
ScriptedAlchemy / idea.propertie
Last active October 21, 2023 23:21
custom IntelliJ IDEA properties
# custom IntelliJ IDEA properties
editor.zero.latency.typing=true
idea.max.intellisense.filesize=3500
idea.cycle.buffer.size=2048
@ScriptedAlchemy
ScriptedAlchemy / idea.vmoptions
Created November 26, 2019 22:23
improved perf vmoptions
-Xms1024m
-Xmx3072m
-Xss64m
-XX:ReservedCodeCacheSize=512m
-XX:+UseCompressedOops
-XX:NewRatio=2
-Dfile.encoding=UTF-8
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=250
-XX:NewSize=512m
@ScriptedAlchemy
ScriptedAlchemy / Index.js
Last active November 28, 2019 04:22
Modifying tree-shaking module by module
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] = {};
@ScriptedAlchemy
ScriptedAlchemy / Index.js
Last active December 9, 2019 00:40
Module plugin
const path = require('path');
const VirtualStats = require('./virtual-stats');
class SyntheticPlugin {
constructor(options) {
this.options = options;
}
apply(compiler) {
const moduleName = this.options.moduleName;
@ScriptedAlchemy
ScriptedAlchemy / .js
Created December 31, 2019 08:21
manifest
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ function webpackJsonpCallback(data) {
/******/ var chunkIds = data[0];
/******/ var moreModules = data[1];
/******/ var executeModules = data[2];
/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, resolves = [];
@ScriptedAlchemy
ScriptedAlchemy / .js
Last active January 1, 2020 22:16
runtime
var chunkMap = {}/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ function webpackJsonpCallback(data) {
/******/ var chunkIds = data[0];
/******/ var moreModules = data[1];
/******/ var executeModules = data[2];
/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, resolves = [];