Skip to content

Commit

Permalink
fix: output subapp v2 info to dist
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Oct 14, 2020
1 parent 5a26418 commit 91d88ea
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
8 changes: 7 additions & 1 deletion packages/xarc-webpack/src/partials/subapp2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import { JsonpScriptSrcPlugin } from "../plugins/jsonp-script-src-plugin";

module.exports = function(opts) {
return {
plugins: [new SubAppWebpackPlugin({ webpackVersion: 4 }), new JsonpScriptSrcPlugin()]
plugins: [
new SubAppWebpackPlugin({
webpackVersion: 4,
assetsFile: "../subapps.json"
}),
new JsonpScriptSrcPlugin()
]
};
};
25 changes: 22 additions & 3 deletions packages/xarc-webpack/src/plugins/subapp-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,33 @@ export class SubAppWebpackPlugin {
_wVer: number;
_makeIdentifierBEE: Function;
_tapAssets: Function;
_assetsFile: string;

/**
*
* @param options - subapp plugin options
*/
constructor({
declareApiName = ["declareSubApp", "createDynamicComponent"],
webpackVersion = findWebpackVersion()
}: { declareApiName?: string | string[]; webpackVersion?: number } = {}) {
webpackVersion = findWebpackVersion(),
assetsFile = "subapps.json"
}: {
/**
* The API names for declaring subapp and components
*/
declareApiName?: string | string[];
/**
* Webpack version (4, 5, etc)
*
* minimum 4
*/
webpackVersion?: number;
/**
* Filename to output the subapp assets JSON file
* **default**: `subapps.json`
*/
assetsFile?: string;
} = {}) {
this._declareApiNames = [].concat(declareApiName);
this._subApps = {};
this._wVer = webpackVersion;
Expand All @@ -56,6 +74,7 @@ export class SubAppWebpackPlugin {

this._makeIdentifierBEE = makeIdentifierBEE;
this._tapAssets = tapAssets;
this._assetsFile = assetsFile;
}

initWebpackVer4() {
Expand Down Expand Up @@ -104,7 +123,7 @@ export class SubAppWebpackPlugin {
);
}
const subapps = JSON.stringify(subappMeta, null, 2) + "\n";
assets["subapps.json"] = {
assets[this._assetsFile] = {
source: () => subapps,
size: () => subapps.length
};
Expand Down

0 comments on commit 91d88ea

Please sign in to comment.