Skip to content

Commit

Permalink
chore: move basic bundle plugin to core (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
Noemi Rozpara authored Apr 21, 2020
1 parent 4b06ef1 commit d7319a2
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 93 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"test": "jest",
"clean": "rimraf ./packages/*/build ./packages/*/tsconfig.tsbuildinfo",
"watch": "yarn clean && concurrently \"yarn:watch:source\" \"yarn:watch:ts\"",
"build:source": "lerna exec --parallel \"babel src --out-dir build --extensions .js,.ts,.tsx --source-maps --config-file=../../babel.config.js\"",
"watch:source": "lerna exec --parallel \"babel src --out-dir build --extensions .js,.ts,.tsx --source-maps --config-file=../../babel.config.js --watch\"",
"build:source": "lerna --ignore @haul-bundler/basic-bundle-webpack-plugin exec --parallel \"babel src --out-dir build --extensions .js,.ts,.tsx --source-maps --config-file=../../babel.config.js\"",
"watch:source": "lerna --ignore @haul-bundler/basic-bundle-webpack-plugin exec --parallel \"babel src --out-dir build --extensions .js,.ts,.tsx --source-maps --config-file=../../babel.config.js --watch\"",
"build:ts": "node ./scripts/build_ts.js",
"watch:ts": "node ./scripts/build_ts.js --watch",
"prepare": "yarn clean && yarn build:source && yarn build:ts",
Expand Down
41 changes: 1 addition & 40 deletions packages/haul-basic-bundle-webpack-plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,3 @@
# @haul-bundler/basic-bundle-webpack-plugin

[![Version][version]][package]

[![PRs Welcome][prs-welcome-badge]][prs-welcome]
[![MIT License][license-badge]][license]
[![Chat][chat-badge]][chat]
[![Code of Conduct][coc-badge]][coc]

Basic bundle plugin for Haul and Webpack. This module is intended for internal use.

Basic bundle is a regular plain JavaScript bundle, where all modules are stored in a single file.

__When using `@haul-bundler/cli bundle` command, this plugin will be added and configured automatically__, based on passed options.

You can read more about Haul here: https://github.com/callstack/haul.

## API

```ts
import BasicBundleWebpackPlugin from '@haul-bundler/basic-bundle-webpack-plugin';

new BasicBundleWebpackPlugin({
bundle: true, // set true when generating static bundle and false when serving from packager server
sourceMap: true, // whether to generate source maps
preloadBundles: [] // bundle names to preload
});
```

<!-- badges (common) -->

[license-badge]: https://img.shields.io/npm/l/@haul-bundler/basic-bundle-webpack-plugin.svg?style=flat-square
[license]: https://opensource.org/licenses/MIT
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs-welcome]: http://makeapullrequest.com
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
[coc]: https://github.com/callstack/haul/blob/master/CODE_OF_CONDUCT.md
[chat-badge]: https://img.shields.io/badge/chat-discord-brightgreen.svg?style=flat-square&colorB=7289DA&logo=discord
[chat]: https://discord.gg/zwR2Cdh

[version]: https://img.shields.io/npm/v/@haul-bundler/basic-bundle-webpack-plugin.svg?style=flat-square
[package]: https://www.npmjs.com/package/@haul-bundler/basic-bundle-webpack-plugin
`BasicBundleWebpackPlugin` was moved into `@haul-bundler/core` package. This module exists only for backwards compatibility and should not be used.
1 change: 1 addition & 0 deletions packages/haul-basic-bundle-webpack-plugin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@haul-bundler/core/dist/webpack/plugins/BasicBundleWebpackPlugin');
5 changes: 0 additions & 5 deletions packages/haul-basic-bundle-webpack-plugin/jest.config.js

This file was deleted.

13 changes: 3 additions & 10 deletions packages/haul-basic-bundle-webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@
"version": "0.18.0",
"name": "@haul-bundler/basic-bundle-webpack-plugin",
"description": "Basic bundle plugin for Haul and Webpack",
"main": "build/index.js",
"files": [
"build/"
],
"main": "./index.js",
"author": "Pawel Trysla <pawel.trysla@callstack.com>",
"repository": "github:callstack/haul",
"license": "MIT",
"bugs": "https://github.com/callstack/haul/issues",
"peerDependencies": {
"webpack": "4.x",
"webpack-sources": "1.x"
},
"dependencies": {
"concat-with-sourcemaps": "^1.1.0"
"@haul-bundler/core": ">=0.19.0"
},
"gitHead": "c41becc82dfeafb07b642ebed8f082775647ec3f"
}
}
1 change: 0 additions & 1 deletion packages/haul-basic-bundle-webpack-plugin/src/index.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/haul-basic-bundle-webpack-plugin/tsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
WebpackBasicBundlePlugin {
BasicBundleWebpackPlugin {
"preloadBundles": Array [
"base_dll",
],
Expand Down Expand Up @@ -474,7 +474,7 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
WebpackBasicBundlePlugin {
BasicBundleWebpackPlugin {
"preloadBundles": Array [
"base_dll",
],
Expand Down Expand Up @@ -548,7 +548,7 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
WebpackBasicBundlePlugin {
BasicBundleWebpackPlugin {
"preloadBundles": Array [],
},
DefinePlugin {
Expand Down Expand Up @@ -617,7 +617,7 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
WebpackBasicBundlePlugin {
BasicBundleWebpackPlugin {
"preloadBundles": Array [
"base_dll",
],
Expand Down Expand Up @@ -746,7 +746,7 @@ Object {
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
WebpackBasicBundlePlugin {
BasicBundleWebpackPlugin {
"preloadBundles": Array [],
},
DefinePlugin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('makeConfig', () => {
};
const config = makeConfig(projectConfig)(runtime, env);
expect(
hasPlugin(config.webpackConfigs.index, 'WebpackBasicBundlePlugin')
hasPlugin(config.webpackConfigs.index, 'BasicBundleWebpackPlugin')
).toBeTruthy();
expect(replacePathsInObject(config)).toMatchSnapshot();
});
Expand Down Expand Up @@ -213,7 +213,7 @@ describe('makeConfig', () => {
};
const config = makeConfig(projectConfig)(runtime, env);
expect(
hasPlugin(config.webpackConfigs.index, 'WebpackBasicBundlePlugin')
hasPlugin(config.webpackConfigs.index, 'BasicBundleWebpackPlugin')
).toBeTruthy();
expect(
hasPlugin(config.webpackConfigs.index, 'WebpackRamBundlePlugin')
Expand Down Expand Up @@ -317,7 +317,7 @@ describe('makeConfig', () => {
};
const config = makeConfig(projectConfig)(runtime, env);
expect(
hasPlugin(config.webpackConfigs.index, 'WebpackBasicBundlePlugin')
hasPlugin(config.webpackConfigs.index, 'BasicBundleWebpackPlugin')
).toBeTruthy();
expect(
hasPlugin(config.webpackConfigs.base_dll, 'WebpackRamBundlePlugin')
Expand Down Expand Up @@ -354,13 +354,13 @@ describe('makeConfig', () => {
};
const config = makeConfig(projectConfig)(runtime, env);
expect(
hasPlugin(config.webpackConfigs.index, 'WebpackBasicBundlePlugin')
hasPlugin(config.webpackConfigs.index, 'BasicBundleWebpackPlugin')
).toBeTruthy();
expect(
hasPlugin(config.webpackConfigs.base_dll, 'WebpackBasicBundlePlugin')
hasPlugin(config.webpackConfigs.base_dll, 'BasicBundleWebpackPlugin')
).toBeTruthy();
expect(
hasPlugin(config.webpackConfigs.app, 'WebpackBasicBundlePlugin')
hasPlugin(config.webpackConfigs.app, 'BasicBundleWebpackPlugin')
).toBeTruthy();
expect(replacePathsInObject(config)).toMatchSnapshot();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/haul-core/src/preset/makeConfigFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import path from 'path';
import { cpus } from 'os';
import isCi from 'is-ci';
import RamBundlePlugin from '@haul-bundler/ram-bundle-webpack-plugin';
import BasicBundleWebpackPlugin from '@haul-bundler/basic-bundle-webpack-plugin';
import {
Runtime,
EnvOptions,
Expand All @@ -27,6 +26,7 @@ import applySingleBundleTweaks from './utils/applySingleBundleTweaks';
import applyMultiBundleTweaks from './utils/applyMultiBundleTweaks';
import LooseModeWebpackPlugin from '../webpack/plugins/LooseModeWebpackPlugin';
import InitCoreDllPlugin from '../webpack/plugins/InitCoreDllPlugin';
import BasicBundleWebpackPlugin from '../webpack/plugins/BasicBundleWebpackPlugin';

type GetDefaultConfig = (
runtime: Runtime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import webpack from 'webpack';
/**
* Adds React Native specific tweaks to bootstrap logic.
*/
export default class WebpackBasicBundlePlugin {
export default class BasicBundleWebpackPlugin {
private preloadBundles: string[];

constructor({ preloadBundles }: { preloadBundles?: string[] }) {
this.preloadBundles = preloadBundles || [];
}

apply(compiler: webpack.Compiler) {
compiler.hooks.compilation.tap('WebpackBasicBundlePlugin', compilation => {
compiler.hooks.compilation.tap('BasicBundleWebpackPlugin', compilation => {
(compilation.mainTemplate as any).hooks.bootstrap.tap(
'WebpackBasicBundlePlugin',
'BasicBundleWebpackPlugin',
(source: string) => {
const preload = this.preloadBundles.length
? `${this.preloadBundles.map(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import WebpackBasicBundlePlugin from '..';
import BasicBundleWebpackPlugin from '../BasicBundleWebpackPlugin';
import webpack from 'webpack';
import fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -38,7 +38,7 @@ const getConfig = () =>
target: 'webworker',
} as webpack.Configuration);

describe('WebpackBasicBundlePlugin', () => {
describe('BasicBundleWebpackPlugin', () => {
afterAll(async () => {
await del(path.join(__dirname, './__fixtures__/tmp-*'));
});
Expand All @@ -47,7 +47,7 @@ describe('WebpackBasicBundlePlugin', () => {
const bundle = await build({
...getConfig(),
plugins: [
new WebpackBasicBundlePlugin({
new BasicBundleWebpackPlugin({
preloadBundles: ['test_bundle'],
}),
],
Expand Down
3 changes: 0 additions & 3 deletions packages/haul-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
"jsx": "react"
},
"references": [
{
"path": "../haul-basic-bundle-webpack-plugin"
},
{
"path": "../haul-ram-bundle-webpack-plugin"
}
Expand Down
7 changes: 0 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6053,13 +6053,6 @@ concat-stream@^2.0.0:
readable-stream "^3.0.2"
typedarray "^0.0.6"

concat-with-sourcemaps@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e"
integrity sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg==
dependencies:
source-map "^0.6.1"

concurrently@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-5.0.2.tgz#4d2911018c0f15ddec34a8e668fc48dced7f3b1e"
Expand Down

0 comments on commit d7319a2

Please sign in to comment.