Skip to content

Commit

Permalink
feat: refactor plugins - PreloadBundlesPlugin, PreloadModulesDllPlugi…
Browse files Browse the repository at this point in the history
…n and LooseModePlugin (#749)
zamotany authored Jul 8, 2020
1 parent c0bfea7 commit 0747fd4
Showing 37 changed files with 793 additions and 783 deletions.
Original file line number Diff line number Diff line change
@@ -22,4 +22,4 @@ do

Get-Content $dir\err
Get-Content $dir\out
Get-Content $vsconfig
Get-Content $vsconfig
2 changes: 1 addition & 1 deletion packages/haul-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "0.22.1",
"name": "@haul-bundler/core",
"description": "Haul core library (legacy)",
"description": "Haul core library",
"main": "build/index.js",
"files": [
"build/",
11 changes: 6 additions & 5 deletions packages/haul-core/src/config/types.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import webpack from 'webpack';
import { MinifyOptions } from 'terser';
import { DeepNonNullable, Overwrite, Assign } from 'utility-types';
import Runtime from '../runtime/Runtime';
import { LooseModeConfig, BundleType, BundlingMode } from '../types';

export type ServerConfig = {
port?: number;
@@ -15,8 +16,8 @@ export type EnvOptions = {
platform: string;
root: string;
dev: boolean;
bundleType?: 'basic-bundle' | 'indexed-ram-bundle' | 'file-ram-bundle';
bundleMode: 'single-bundle' | 'multi-bundle';
bundleType?: BundleType;
bundleMode: BundlingMode;
bundleTarget?: 'file' | 'server';
assetsDest?: string;
bundleOutput?: string;
@@ -30,7 +31,7 @@ export type BundleConfig = Assign<
{
name?: string;
entry: string | string[] | { entryFiles: string[]; setupFiles: string[] };
type?: 'basic-bundle' | 'indexed-ram-bundle' | 'file-ram-bundle';
type?: BundleType;
platform?: string;
root?: string;
dev?: boolean;
@@ -41,7 +42,7 @@ export type BundleConfig = Assign<
Exclude<keyof MinifyOptions, 'sourceMap'>
>;
sourceMap?: boolean | 'inline';
looseMode?: true | Array<string | RegExp> | ((filename: string) => boolean);
looseMode?: LooseModeConfig;
dll?: boolean;
app?: boolean;
dependsOn?: string[];
@@ -95,7 +96,7 @@ export type NormalizedBundleConfig = Assign<
DeepNonNullable<ExternalBundleConfig>,
{ manifestPath: ExternalBundleConfig['manifestPath'] }
>;
looseMode: (filename: string) => boolean;
looseMode?: LooseModeConfig;
}
>;

12 changes: 11 additions & 1 deletion packages/haul-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -6,10 +6,14 @@ export { default as getBabelConfigPath } from './preset/getBabelConfigPath';
export { default as makeConfigFactory } from './preset/makeConfigFactory';
export { getBundleFilename } from './preset/utils/applyMultiBundleTweaks';

// Webpack utils
// Webpack
export { default as AssetResolver } from './webpack/resolvers/AssetResolver';
export { default as HasteResolver } from './webpack/resolvers/HasteResolver';
export { default as resolveModule } from './webpack/resolvers/resolveModule';
export { LooseModePlugin } from './webpack/plugins/LooseModePlugin';
export { PreloadBundlesPlugin } from './webpack/plugins/PreloadBundlesPlugin';
export { PreloadModulesDllPlugin } from './webpack/plugins/PreloadModulesDllPlugin';
export { RamBundlePlugin } from './webpack/plugins/RamBundlePlugin';

// Shared CLI utils
export { default as Runtime } from './runtime/Runtime';
@@ -36,6 +40,12 @@ export {
NormalizedProjectConfig,
NormalizedProjectConfigBuilder,
} from './config/types';
export {
BundleType,
BundlingMode,
RamBundleType,
LooseModeConfig,
} from './types';
export { default as getReactNativeVersion } from './utils/getReactNativeVersion';
export { default as parseEntry } from './utils/parseEntry';
export { default as sortBundlesByDependencies } from './utils/sortBundlesByDependencies';
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
@@ -46,7 +46,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
@@ -75,7 +75,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
@@ -142,28 +142,29 @@ Object {
},
},
},
RamBundleWebpackPlugin {
"bundleId": "app",
"bundleName": "app",
"indexRamBundle": true,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
RamBundlePlugin {
"config": Object {
"bundleId": "app",
"bundleName": "app",
"bundlingMode": "multi-bundle",
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
"preloadBundles": Array [
"base_dll",
],
"sourceMap": true,
"type": "indexed-ram-bundle",
},
"modules": Array [],
"name": "RamBundleWebpackPlugin",
"preloadBundles": Array [
"base_dll",
],
"singleBundleMode": false,
"sourceMap": true,
},
DefinePlugin {
"definitions": Object {
"process.env.HAUL_BUNDLES": "{\\"index\\":0,\\"base_dll\\":1,\\"app\\":2}",
},
},
LooseModeWebpackPlugin {
"checkLooseMode": [Function],
LooseModePlugin {
"shouldUseLoosMode": [Function],
},
DllReferencePlugin {
"options": Object {
@@ -212,26 +213,27 @@ Object {
},
},
},
RamBundleWebpackPlugin {
"bundleId": "base_dll",
"bundleName": "base_dll",
"indexRamBundle": true,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
RamBundlePlugin {
"config": Object {
"bundleId": "base_dll",
"bundleName": "base_dll",
"bundlingMode": "multi-bundle",
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
"preloadBundles": Array [],
"sourceMap": true,
"type": "indexed-ram-bundle",
},
"modules": Array [],
"name": "RamBundleWebpackPlugin",
"preloadBundles": Array [],
"singleBundleMode": false,
"sourceMap": true,
},
DefinePlugin {
"definitions": Object {
"process.env.HAUL_BUNDLES": "{\\"index\\":0,\\"base_dll\\":1,\\"app\\":2}",
},
},
LooseModeWebpackPlugin {
"checkLooseMode": [Function],
LooseModePlugin {
"shouldUseLoosMode": [Function],
},
DllPlugin {
"options": Object {
@@ -291,8 +293,8 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
BasicBundleWebpackPlugin {
"preloadBundles": Array [
PreloadBundlesPlugin {
"bundles": Array [
"base_dll",
],
},
@@ -301,8 +303,8 @@ Object {
"process.env.HAUL_BUNDLES": "{\\"index\\":0,\\"base_dll\\":1,\\"app\\":2}",
},
},
LooseModeWebpackPlugin {
"checkLooseMode": [Function],
LooseModePlugin {
"shouldUseLoosMode": [Function],
},
DllReferencePlugin {
"options": Object {
@@ -337,7 +339,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
@@ -364,7 +366,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
@@ -393,7 +395,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
@@ -474,8 +476,8 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
BasicBundleWebpackPlugin {
"preloadBundles": Array [
PreloadBundlesPlugin {
"bundles": Array [
"base_dll",
],
},
@@ -484,8 +486,8 @@ Object {
"process.env.HAUL_BUNDLES": "{\\"index\\":0,\\"base_dll\\":1,\\"app\\":2}",
},
},
LooseModeWebpackPlugin {
"checkLooseMode": [Function],
LooseModePlugin {
"shouldUseLoosMode": [Function],
},
DllReferencePlugin {
"options": Object {
@@ -548,16 +550,16 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
BasicBundleWebpackPlugin {
"preloadBundles": Array [],
PreloadBundlesPlugin {
"bundles": Array [],
},
DefinePlugin {
"definitions": Object {
"process.env.HAUL_BUNDLES": "{\\"index\\":0,\\"base_dll\\":1,\\"app\\":2}",
},
},
LooseModeWebpackPlugin {
"checkLooseMode": [Function],
LooseModePlugin {
"shouldUseLoosMode": [Function],
},
DllPlugin {
"options": Object {
@@ -617,8 +619,8 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
BasicBundleWebpackPlugin {
"preloadBundles": Array [
PreloadBundlesPlugin {
"bundles": Array [
"base_dll",
],
},
@@ -627,8 +629,8 @@ Object {
"process.env.HAUL_BUNDLES": "{\\"index\\":0,\\"base_dll\\":1,\\"app\\":2}",
},
},
LooseModeWebpackPlugin {
"checkLooseMode": [Function],
LooseModePlugin {
"shouldUseLoosMode": [Function],
},
DllReferencePlugin {
"options": Object {
@@ -664,7 +666,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
@@ -746,16 +748,16 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
BasicBundleWebpackPlugin {
"preloadBundles": Array [],
PreloadBundlesPlugin {
"bundles": Array [],
},
DefinePlugin {
"definitions": Object {
"process.env.HAUL_BUNDLES": "{\\"index\\":0}",
},
},
LooseModeWebpackPlugin {
"checkLooseMode": [Function],
LooseModePlugin {
"shouldUseLoosMode": [Function],
},
],
"target": "webworker",
Loading

0 comments on commit 0747fd4

Please sign in to comment.