Skip to content

Commit e533954

Browse files
committed
feat: support bundle dev dll
1 parent 303ce70 commit e533954

File tree

3 files changed

+44
-7
lines changed

3 files changed

+44
-7
lines changed

CHANGELOG.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<a name="4.2.0-beta.4"></a>
2-
# [4.2.0-beta.4](https://github.com/prijs/pri/compare/3.3.28-beta.5...4.2.0-beta.4) (2020-08-11)
1+
<a name="4.2.0-beta.6"></a>
2+
# [4.2.0-beta.6](https://github.com/prijs/pri/compare/3.3.28-beta.5...4.2.0-beta.6) (2020-08-19)
33

44

55
### Bug Fixes
@@ -43,9 +43,10 @@
4343
* add babelPluginReactWrappedDisplayName ([6dd820e](https://github.com/prijs/pri/commit/6dd820e))
4444
* add changeLog to publish script ([66526f7](https://github.com/prijs/pri/commit/66526f7))
4545
* add ensure files config ([2e78cc5](https://github.com/prijs/pri/commit/2e78cc5))
46-
* add hotLoader option ([52c8bdb](https://github.com/prijs/pri/commit/52c8bdb))
4746
* add hotLoader option ([ceb6f48](https://github.com/prijs/pri/commit/ceb6f48))
47+
* add hotLoader option ([52c8bdb](https://github.com/prijs/pri/commit/52c8bdb))
4848
* add jest react babel support ([949d38f](https://github.com/prijs/pri/commit/949d38f))
49+
* add path ([7cc1705](https://github.com/prijs/pri/commit/7cc1705))
4950
* add project root id to pri config ([ae38a55](https://github.com/prijs/pri/commit/ae38a55))
5051
* add pub options ([c357306](https://github.com/prijs/pri/commit/c357306))
5152
* add publish error tip when package reference project content ([20c13be](https://github.com/prijs/pri/commit/20c13be))
@@ -58,6 +59,8 @@
5859
* deploy 4.0.10 ([93970bb](https://github.com/prijs/pri/commit/93970bb))
5960
* deploy 4.0.3 ([2c38dd8](https://github.com/prijs/pri/commit/2c38dd8))
6061
* deploy 4.0.8 ([a97852a](https://github.com/prijs/pri/commit/a97852a))
62+
* extradll ([8c9ed2d](https://github.com/prijs/pri/commit/8c9ed2d))
63+
* extradll ([4535505](https://github.com/prijs/pri/commit/4535505))
6164
* fix bug ([ecbe690](https://github.com/prijs/pri/commit/ecbe690))
6265
* fix bug ([5c6e107](https://github.com/prijs/pri/commit/5c6e107))
6366
* fix memo name ([a5ea73d](https://github.com/prijs/pri/commit/a5ea73d))
@@ -71,18 +74,18 @@
7174
* support remote version ([8712f28](https://github.com/prijs/pri/commit/8712f28))
7275
* support skiplint for test command ([f251b22](https://github.com/prijs/pri/commit/f251b22))
7376
* support webpack for component build ([ff78bfe](https://github.com/prijs/pri/commit/ff78bfe))
74-
* update ([e959701](https://github.com/prijs/pri/commit/e959701))
75-
* update ([bb4ea0b](https://github.com/prijs/pri/commit/bb4ea0b))
7677
* update ([b0c585b](https://github.com/prijs/pri/commit/b0c585b))
78+
* update ([bb4ea0b](https://github.com/prijs/pri/commit/bb4ea0b))
79+
* update ([e959701](https://github.com/prijs/pri/commit/e959701))
7780
* update .vscode ([4f48549](https://github.com/prijs/pri/commit/4f48549))
7881
* update deps ([5678dcc](https://github.com/prijs/pri/commit/5678dcc))
7982
* update docs ([afa3110](https://github.com/prijs/pri/commit/afa3110))
8083
* update docs ([8118dc7](https://github.com/prijs/pri/commit/8118dc7))
8184
* update eslintrc ([d949c81](https://github.com/prijs/pri/commit/d949c81))
8285
* update gitignore ([6ac2310](https://github.com/prijs/pri/commit/6ac2310))
86+
* update lock ([4efdb17](https://github.com/prijs/pri/commit/4efdb17))
8387
* update lock ([ede0ce8](https://github.com/prijs/pri/commit/ede0ce8))
8488
* update lock ([692edae](https://github.com/prijs/pri/commit/692edae))
85-
* update lock ([4efdb17](https://github.com/prijs/pri/commit/4efdb17))
8689
* update type check ([16353e1](https://github.com/prijs/pri/commit/16353e1))
8790
* upgrade eslint-plugin-react-hooks ([5f5ae96](https://github.com/prijs/pri/commit/5f5ae96))
8891
* upgrade ts 3.8 ([261bf1d](https://github.com/prijs/pri/commit/261bf1d))

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pri",
3-
"version": "4.2.0-beta.6",
3+
"version": "4.2.0-beta.7",
44
"types": "src/node/index.ts",
55
"main": "built/node/index.js",
66
"scripts": {

src/built-in-plugins/command-bundle/plugin/command-bundle.ts

+34
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import * as path from 'path';
22
import * as portfinder from 'portfinder';
3+
import * as webpack from 'webpack';
4+
import * as urlJoin from 'url-join';
35
import { componentEntry, pri } from '../../../node';
46
import { logFatal } from '../../../utils/log';
57
import { plugin } from '../../../utils/plugins';
68
import { IOpts } from './interface';
79
import { runWebpack } from '../../../utils/webpack';
810
import { runWebpackDevServer } from '../../../utils/webpack-dev-server';
11+
import { bundleDlls, dllMainfestName, dllOutPath, libraryStaticPath } from '../../command-dev/plugin/dll';
12+
import { globalState } from '../../../utils/global-state';
13+
import { WrapContent } from '../../../utils/webpack-plugin-wrap-content';
914

1015
export const commandBundle = async (opts: IOpts = {}) => {
1116
if (pri.sourceConfig.type !== 'component') {
@@ -33,6 +38,8 @@ export const commandBundle = async (opts: IOpts = {}) => {
3338
} else {
3439
const freePort = await portfinder.getPortPromise({ port: pri.sourceConfig.devPort });
3540

41+
await bundleDlls();
42+
3643
runWebpackDevServer({
3744
mode: 'development',
3845
outFileName: pri.sourceConfig.bundleFileName,
@@ -49,6 +56,33 @@ export const commandBundle = async (opts: IOpts = {}) => {
4956
return fn(await nextConfig);
5057
}, Promise.resolve(config));
5158

59+
// bundle dev 模式支持 dll
60+
config.plugins.push(
61+
new webpack.DllReferencePlugin({
62+
context: '.',
63+
// eslint-disable-next-line import/no-dynamic-require,global-require
64+
manifest: require(path.join(dllOutPath, dllMainfestName)),
65+
}),
66+
);
67+
68+
const dllHttpPath = urlJoin(
69+
`${globalState.sourceConfig.useHttps ? 'https' : 'http'}://localhost:${freePort}`,
70+
libraryStaticPath,
71+
);
72+
73+
config.plugins.push(
74+
new WrapContent(
75+
`
76+
var dllScript = document.createElement("script");
77+
dllScript.src = "${dllHttpPath}";
78+
dllScript.onload = runEntry;
79+
document.body.appendChild(dllScript);
80+
function runEntry() {
81+
`,
82+
'}',
83+
),
84+
);
85+
5286
return newConfig;
5387
},
5488
});

0 commit comments

Comments
 (0)