Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/1.2.1 #3898

Merged
merged 28 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c9426b0
chore: version
ClarkXia Dec 7, 2020
81de8ae
feat: support webIDE dev url (#3907)
ClarkXia Dec 10, 2020
fc77de7
fix: use debug in ssr (#3908)
luhc228 Dec 10, 2020
3dfc034
feat: support use name define mpa page name (#3906)
SoloJiang Dec 11, 2020
37bdf55
fix: store load time early (#3910)
luhc228 Dec 11, 2020
f2922bc
refactor: add server bundle for ssr (#3909)
ClarkXia Dec 14, 2020
c15f7b3
fix: resolve path of build-plugin-load-assets (#3891)
ClarkXia Dec 14, 2020
9f4b3a9
refactor: support generator api for plugins (#3899)
ClarkXia Dec 14, 2020
a3446fa
feat: support color names (#3914)
ClarkXia Dec 14, 2020
5bd7a57
chore: version
ClarkXia Dec 14, 2020
5876ae2
Merge branch 'master' into release-next
ClarkXia Dec 14, 2020
287ce77
Merge branch 'release-next' into chore-version
ClarkXia Dec 14, 2020
33066a2
fix: generator error message
ClarkXia Dec 14, 2020
c760f01
fix: generator debounce
ClarkXia Dec 14, 2020
ee0bc19
Merge pull request #3917 from alibaba/fix-generator
SoloJiang Dec 14, 2020
8665266
feat: define hydrate value when build (#3918)
SoloJiang Dec 14, 2020
861e49f
Merge branch 'release-next' into chore-version
ClarkXia Dec 14, 2020
15d1cbb
chore: build config add web (#3919)
SoloJiang Dec 14, 2020
c4ffeeb
Merge branch 'release-next' into chore-version
ClarkXia Dec 14, 2020
a339b5c
chore: version
ClarkXia Dec 14, 2020
b3a5882
chore: version
ClarkXia Dec 14, 2020
3ccd40a
chore: version
ClarkXia Dec 14, 2020
a239124
chore: version
ClarkXia Dec 14, 2020
236b034
fix: babel-loader dep
SoloJiang Dec 14, 2020
a88ede6
Merge pull request #3915 from alibaba/chore-version
SoloJiang Dec 14, 2020
a7016aa
Merge pull request #3924 from alibaba/hotfix/babel-loader
SoloJiang Dec 14, 2020
6f4ffce
chore: version (#3925)
ClarkXia Dec 14, 2020
ecc3561
feat: support colorNames (#3916)
ClarkXia Dec 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/guide/advance/fusion.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $ npm install build-plugin-fusion --save-dev
* `usePx2Vw` 配合 postcss 插件,将 css 样式单位 px 转化为 vw ,默认为 false 不开启, true 为开启
* `px2vwOptions` 传递参数给postcss插件,默认为`{ viewportWidth: 750 }` 根据用户设置项将进行合并
* `componentOptions` 值为对象,修改业务组件的引入路径,推荐用在 PC 跨 H5 的项目中,给业务组件指定 H5 的渲染组件
* `enableColorNames` 默认为 `false`,如果开启默认将提取 `transparent`、`red`、`blue` 等色值名称

## 基础用法

Expand Down
10 changes: 0 additions & 10 deletions examples/basic-mpa/src/pages/Home/app.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/build-app-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder/app-helpers",
"version": "1.0.2",
"version": "2.0.0",
"description": "build helpers for app framework",
"author": "[email protected]",
"homepage": "",
Expand Down
52 changes: 40 additions & 12 deletions packages/build-app-helpers/src/getMpaEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,58 @@ interface IOptions {
target: string;
appJsonPath: string;
}

interface IEntry {
entryPath: string;
entryName: string;
pageName: string;
source?: string;
}

// Get entries when exist app.json
export default function (api, options?: IOptions) {
export default function (api, options?: IOptions): IEntry[] {
const { target, appJsonPath } = options || {};
if (appJsonPath) {
return getEntriesByJson(target, appJsonPath);
return getEntriesByJson(api, target, appJsonPath);
}
return getEntriesByDir(api);
}

function getEntriesByJson(target, appJsonPath) {
function getEntriesByJson(api, target, appJsonPath): IEntry[] {
const {
context: { rootDir },
} = api;
const routes = getRoutesByAppJson(target, { appJsonPath });
return routes.map((route) => {
const dir = path.dirname(route.source);
const pageName = path.parse(dir).name;
let pageName;
let entryName;
if (route.name) {
entryName = route.name;
pageName = route.name;
} else {
const dir = path.dirname(route.source);
pageName = path.parse(dir).name;
entryName = pageName.toLocaleLowerCase();
}
return {
path: route.path,
entryName: pageName.toLowerCase(),
entryPath: getPageEntryByAppJson(rootDir, route.source),
entryName,
pageName,
entryPath: route.source.replace(/\/?pages/, ''),
source: route.source
};
});
}

function getEntriesByDir(api: any) {
function getPageEntryByAppJson(rootDir, source) {
const absolutePath = path.resolve(rootDir, 'src', source);
const targetExt = ['ts', 'tsx', 'js', 'jsx'].find(ext => fs.existsSync(`${absolutePath}.${ext}`));
if (!targetExt) {
throw new Error(`Cannot find target file ${absolutePath}.`);
}
return `${source}.${targetExt}`;
}

function getEntriesByDir(api: any): IEntry[] {
const {
context: { rootDir },
} = api;
Expand All @@ -43,18 +71,18 @@ function getEntriesByDir(api: any) {

const entries = pages.map((pageName) => {
const entryName = pageName.toLocaleLowerCase();
const pageEntry = getPageEntry(pagesPath, pageName);
const pageEntry = getPageEntryByDir(pagesPath, pageName);
if (!pageEntry) return null;
return {
entryName,
pageName,
entryPath: `${pageName}/${pageEntry}`,
entryPath: `pages/${pageName}/${pageEntry}`,
};
}).filter(Boolean);
return entries;
}

function getPageEntry(pagesPath: string, pageName: string) {
function getPageEntryByDir(pagesPath: string, pageName: string) {
const pagePath = path.join(pagesPath, pageName);
const pageRootFiles = fs.readdirSync(pagePath);
const appRegexp = /^app\.(t|j)sx?$/;
Expand Down
1 change: 1 addition & 0 deletions packages/build-app-helpers/src/getRoutesByAppJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface IRoute {
targets?: string[];
source: string;
path: string;
name?: string;
}
interface IStaticConfig {
routes: IRoute[];
Expand Down
1 change: 0 additions & 1 deletion packages/build-app-helpers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ export { default as formatPath } from './formatPath';
export { default as validation } from './validation';
export { default as unionBy } from './unionBy';
export { default as injectTransformRuntime } from './injectTransformRuntime';

4 changes: 2 additions & 2 deletions packages/build-mpa-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder/mpa-config",
"version": "1.1.1",
"version": "2.0.0",
"description": "enable mpa project for framework",
"author": "[email protected]",
"homepage": "",
Expand All @@ -22,6 +22,6 @@
"dependencies": {
"fs-extra": "^8.1.0",
"loader-utils": "^2.0.0",
"@builder/app-helpers": "^1.0.2"
"@builder/app-helpers": "^2.0.0"
}
}
13 changes: 7 additions & 6 deletions packages/build-mpa-config/src/generateEntry.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import * as path from 'path';
import { formatPath } from '@builder/app-helpers';
import { ensureDirSync, writeFileSync } from 'fs-extra';

function generateEntry({ framework, type, targetDir, pageEntry, entryName }) {
// eslint-disable-next-line
const entryCode = require(`./template/${framework}`).default({ type, resourcePath: `${formatPath(pageEntry)}`});
function generateEntry(api, { framework, targetDir, pageEntry, entryName }) {
const { context: { userConfig: { web: webConfig = {} } } } = api;
const entryFolder = path.join(targetDir, 'mpaEntry');
ensureDirSync(entryFolder);
const entryPath = path.join(entryFolder, `${entryName}.tsx`);
writeFileSync(path.join(entryFolder, `${entryName}.tsx`), entryCode);
const templatePath = path.join(__dirname, `./template/${framework}.ts.ejs`);
api.applyMethod('addRenderFile', templatePath, entryPath, {
hydrate: Boolean(webConfig.ssr || webConfig.snapshot),
resourcePath: `${formatPath(path.extname(pageEntry) ? pageEntry.split('.').slice(0, -1).join('.') : pageEntry)}`
});
return entryPath;
}

Expand Down
22 changes: 9 additions & 13 deletions packages/build-mpa-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@ import generateEntry from './generateEntry';

interface IEntries {
entryName: string;
pageName: string;
entryPath: string;
}

interface IConfigOptions {
context: {
rootDir: string;
commandArgs: any;
};
type?: string;
framework: string;
entries?: IEntries[];
targetDir: string;
}
export const generateMPAEntries = (options: IConfigOptions) => {
const { context, type = 'web', framework = 'rax', targetDir = '' } = options;
export const generateMPAEntries = (api, options: IConfigOptions) => {
const { context } = api;
const { type = 'web', framework = 'rax', targetDir = '' } = options;
let { entries } = options;
const { rootDir, commandArgs } = context;
if (commandArgs.mpaEntry) {
Expand All @@ -32,14 +28,14 @@ export const generateMPAEntries = (options: IConfigOptions) => {
const parsedEntries = {};
entries.forEach((entry) => {
const { entryName, entryPath } = entry;
const pageEntry = path.join(rootDir, 'src/pages', entryPath);
const pageEntry = path.join(rootDir, 'src', entryPath);
const useOriginEntry = /app\.(t|j)sx?$/.test(entryPath) || type === 'node';
// icejs will config entry by api modifyUserConfig

let finalEntry = pageEntry;
if (!useOriginEntry) {
// generate mpa entries
finalEntry = generateEntry({ framework, targetDir, type, pageEntry, entryName });
finalEntry = generateEntry(api, { framework, targetDir, pageEntry, entryName });
}
parsedEntries[entryName] = {
...entry,
Expand All @@ -49,12 +45,12 @@ export const generateMPAEntries = (options: IConfigOptions) => {
return parsedEntries;
};

const setMPAConfig = (config, options: IConfigOptions) => {
const setMPAConfig = (api, config, options: IConfigOptions) => {
if (!options) {
throw new Error('There need pass options param to setMPAConfig method');
}
const { type = 'web' } = options;
const parsedEntries = generateMPAEntries(options);
const parsedEntries = generateMPAEntries(api, options);

// do not splitChunks when mpa
config.optimization.splitChunks({ cacheGroups: {} });
Expand All @@ -64,11 +60,11 @@ const setMPAConfig = (config, options: IConfigOptions) => {
const matchStrs = [];

Object.keys(parsedEntries).forEach((entryKey) => {
const { entryName, pageName, finalEntry } = parsedEntries[entryKey];
const { entryName, entryPath, finalEntry } = parsedEntries[entryKey];
config.entry(entryName).add(finalEntry);

// get page paths for rule match
const matchStr = `src/pages/${pageName}`;
const matchStr = `src/${entryPath}`;
matchStrs.push(formatPath(matchStr));
});

Expand Down
32 changes: 0 additions & 32 deletions packages/build-mpa-config/src/template/rax.ts

This file was deleted.

22 changes: 22 additions & 0 deletions packages/build-mpa-config/src/template/rax.ts.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { render, createElement } from 'rax';
import DriverUniversal from 'driver-universal';
import { isWeex, isKraken } from 'universal-env';
import Component from '<%- resourcePath %>';

const isSSR = window.__INITIAL_DATA__ && window.__INITIAL_DATA__.__SSR_ENABLED__;

if (isWeex || isKraken) {
render(<Component />, null, { driver: DriverUniversal });
} else {
const renderApp = async function() {
let comProps = {};
// process App.getInitialProps
if (isSSR && window.__INITIAL_DATA__.pageData !== null) {
comProps = window.__INITIAL_DATA__.pageData;
} else if (Component.getInitialProps) {
comProps = await Component.getInitialProps();
}
render(<Component {...comProps} />, document.getElementById('root'), { driver: DriverUniversal, hydrate: <%- hydrate %> });
}
renderApp();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export default ({ resourcePath }) => {
const source = `import React from 'react';
import React from 'react';
import ReactDOM from 'react-dom';
import Component from '${resourcePath}';
import Component from '<%- resourcePath %>';

function renderApp() {
const isSSR = window.__ICE_SSR_ENABLED__;
Expand All @@ -12,11 +11,9 @@ function renderApp() {
}
ReactDOM[isSSR ? 'hydrate' : 'render'](<Component {...comProps} />, document.getElementById('ice-container'));
}

if (!Component) {
console.warn('[icejs] You likely forget to export your component at ${resourcePath}');
} else {
renderApp();
}
`;
return source;
};
7 changes: 4 additions & 3 deletions packages/build-user-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder/user-config",
"version": "0.1.3",
"version": "0.1.4",
"description": "Includes methods which are releated to set base user config for framework",
"homepage": "",
"license": "MIT",
Expand Down Expand Up @@ -28,7 +28,8 @@
"webpack-bundle-analyzer": "^3.6.0",
"webpack-dev-mock": "^1.0.1",
"webpack-plugin-import": "^0.2.6",
"@builder/app-helpers": "^1.0.2"
"@builder/app-helpers": "^2.0.0",
"babel-loader": "^8.0.6"
},
"files": [
"lib"
Expand All @@ -43,4 +44,4 @@
"bugs": {
"url": "https://github.com/alibaba/ice/issues"
}
}
}
2 changes: 1 addition & 1 deletion packages/eslint-reporting-webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"plugin",
"webpack"
]
}
}
14 changes: 7 additions & 7 deletions packages/icejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ice.js",
"version": "1.12.0",
"version": "1.12.1",
"description": "command line interface and builtin plugin for icejs",
"author": "[email protected]",
"homepage": "",
Expand All @@ -22,17 +22,17 @@
},
"dependencies": {
"@alib/build-scripts": "^0.1.13",
"build-plugin-app-core": "0.1.27",
"build-plugin-app-core": "1.0.0",
"build-plugin-ice-auth": "1.7.2",
"build-plugin-ice-config": "1.7.1",
"build-plugin-ice-config": "1.7.2",
"build-plugin-ice-helpers": "1.7.1",
"build-plugin-ice-logger": "1.7.2",
"build-plugin-ice-mpa": "1.8.1",
"build-plugin-ice-mpa": "1.8.2",
"build-plugin-ice-request": "1.7.2",
"build-plugin-ice-router": "1.7.6",
"build-plugin-ice-ssr": "1.7.8",
"build-plugin-ice-store": "1.7.10",
"build-plugin-react-app": "1.7.12",
"build-plugin-ice-ssr": "1.7.9",
"build-plugin-ice-store": "1.7.11",
"build-plugin-react-app": "1.7.13",
"build-plugin-miniapp": "0.1.7",
"chalk": "^4.1.0",
"chokidar": "^3.3.1",
Expand Down
Loading