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)
  • Loading branch information
zamotany authored Jul 8, 2020
1 parent c0bfea7 commit 0747fd4
Show file tree
Hide file tree
Showing 37 changed files with 793 additions and 783 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
11 changes: 6 additions & 5 deletions packages/haul-core/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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[];
Expand Down Expand Up @@ -95,7 +96,7 @@ export type NormalizedBundleConfig = Assign<
DeepNonNullable<ExternalBundleConfig>,
{ manifestPath: ExternalBundleConfig['manifestPath'] }
>;
looseMode: (filename: string) => boolean;
looseMode?: LooseModeConfig;
}
>;

Expand Down
12 changes: 11 additions & 1 deletion packages/haul-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
Expand All @@ -46,7 +46,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
Expand Down Expand Up @@ -75,7 +75,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -291,8 +293,8 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
BasicBundleWebpackPlugin {
"preloadBundles": Array [
PreloadBundlesPlugin {
"bundles": Array [
"base_dll",
],
},
Expand All @@ -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 {
Expand Down Expand Up @@ -337,7 +339,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
Expand All @@ -364,7 +366,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
Expand Down Expand Up @@ -393,7 +395,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
Expand Down Expand Up @@ -474,8 +476,8 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
BasicBundleWebpackPlugin {
"preloadBundles": Array [
PreloadBundlesPlugin {
"bundles": Array [
"base_dll",
],
},
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -617,8 +619,8 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
BasicBundleWebpackPlugin {
"preloadBundles": Array [
PreloadBundlesPlugin {
"bundles": Array [
"base_dll",
],
},
Expand All @@ -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 {
Expand Down Expand Up @@ -664,7 +666,7 @@ Object {
},
"external": false,
"hasteOptions": Object {},
"looseMode": [Function],
"looseMode": undefined,
"maxWorkers": 7,
"minify": false,
"minifyOptions": undefined,
Expand Down Expand Up @@ -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",
Expand Down
Loading

0 comments on commit 0747fd4

Please sign in to comment.