mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
chore: remove friendly-errors-webpack-plugin
This commit is contained in:
@@ -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,
|
||||
|
@@ -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 = '';
|
||||
|
@@ -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)
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user