chore: remove friendly-errors-webpack-plugin

This commit is contained in:
chenjiahan
2021-04-13 20:18:43 +08:00
committed by neverland
parent 0e80000339
commit e38c5d27e0
9 changed files with 26 additions and 76 deletions

View File

@@ -11,11 +11,11 @@ import {
ES_DIR,
SRC_DIR,
LIB_DIR,
STYPE_DEPS_JSON_FILE,
STYLE_DEPS_JSON_FILE,
} from '../common/constant';
function getDeps(component: string): string[] {
const styleDepsJson = require(STYPE_DEPS_JSON_FILE);
const styleDepsJson = require(STYLE_DEPS_JSON_FILE);
if (styleDepsJson.map[component]) {
const deps = styleDepsJson.map[component].slice(0);
@@ -57,7 +57,7 @@ function genEntry(params: {
}) {
const { ext, filename, component, baseFile } = params;
const deps = getDeps(component);
const depsPath = deps.map(dep => getRelativePath(component, dep, ext));
const depsPath = deps.map((dep) => getRelativePath(component, dep, ext));
OUTPUT_CONFIG.forEach(({ dir, template }) => {
const outputDir = join(dir, component, 'style');
@@ -81,13 +81,13 @@ export function genComponentStyle(
options: { cache: boolean } = { cache: true }
) {
if (!options.cache) {
delete require.cache[STYPE_DEPS_JSON_FILE];
delete require.cache[STYLE_DEPS_JSON_FILE];
}
const components = getComponents();
const baseFile = getCssBaseFile();
components.forEach(component => {
components.forEach((component) => {
genEntry({
baseFile,
component,

View File

@@ -2,7 +2,7 @@ import { join } from 'path';
import { existsSync } from 'fs-extra';
import { smartOutputFile, normalizePath } from '../common';
import { CSS_LANG, getCssBaseFile } from '../common/css';
import { SRC_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant';
import { SRC_DIR, STYLE_DEPS_JSON_FILE } from '../common/constant';
type Options = {
outputPath: string;
@@ -10,7 +10,7 @@ type Options = {
};
export function genPackageStyle(options: Options) {
const styleDepsJson = require(STYPE_DEPS_JSON_FILE);
const styleDepsJson = require(STYLE_DEPS_JSON_FILE);
const ext = '.' + CSS_LANG;
let content = '';

View File

@@ -3,7 +3,7 @@ import { CSS_LANG } from '../common/css';
import { existsSync } from 'fs-extra';
import { getDeps, clearDepsCache, fillExt } from './get-deps';
import { getComponents, smartOutputFile } from '../common';
import { SRC_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant';
import { SRC_DIR, STYLE_DEPS_JSON_FILE } from '../common/constant';
function matchPath(path: string, component: string): boolean {
const p = relative(SRC_DIR, path);
@@ -28,15 +28,15 @@ function analyzeComponentDeps(components: string[], component: string) {
function search(filePath: string) {
record.add(filePath);
getDeps(filePath).forEach(key => {
getDeps(filePath).forEach((key) => {
if (record.has(key)) {
return;
}
search(key);
components
.filter(item => matchPath(key, item))
.forEach(item => {
.filter((item) => matchPath(key, item))
.forEach((item) => {
if (!checkList.includes(item) && item !== component) {
checkList.push(item);
}
@@ -80,7 +80,7 @@ function getSequence(components: string[], depsMap: DepsMap) {
return;
}
const maxIndex = Math.max(...deps.map(dep => sequence.indexOf(dep)));
const maxIndex = Math.max(...deps.map((dep) => sequence.indexOf(dep)));
sequence.splice(maxIndex + 1, 0, item);
}
@@ -93,25 +93,25 @@ function getSequence(components: string[], depsMap: DepsMap) {
export async function genStyleDepsMap() {
const components = getComponents();
return new Promise<void>(resolve => {
return new Promise<void>((resolve) => {
clearDepsCache();
const map = {} as DepsMap;
components.forEach(component => {
components.forEach((component) => {
map[component] = analyzeComponentDeps(components, component);
});
const sequence = getSequence(components, map);
Object.keys(map).forEach(key => {
Object.keys(map).forEach((key) => {
map[key] = map[key].sort(
(a, b) => sequence.indexOf(a) - sequence.indexOf(b)
);
});
smartOutputFile(
STYPE_DEPS_JSON_FILE,
STYLE_DEPS_JSON_FILE,
JSON.stringify({ map, sequence }, null, 2)
);