!617 npm资源拷贝

Merge pull request !617 from 卡哥/master
This commit is contained in:
openharmony_ci
2022-05-09 03:44:05 +00:00
committed by Gitee
2 changed files with 20 additions and 10 deletions
+18 -9
View File
@@ -38,7 +38,11 @@ import {
circularFile,
mkDir
} from './utils';
import { MODULE_SHARE_PATH, BUILD_SHARE_PATH } from './pre_define';
import {
MODULE_ETS_PATH,
MODULE_SHARE_PATH,
BUILD_SHARE_PATH
} from './pre_define';
import {
createLanguageService,
appComponentCollection,
@@ -74,7 +78,7 @@ export class ResultStates {
private yellow: string = '\u001b[33m';
private blue: string = '\u001b[34m';
private reset: string = '\u001b[39m';
private modulePaths: Set<string> = new Set([]);
private moduleSharePaths: Set<string> = new Set([]);
public apply(compiler: Compiler): void {
compiler.hooks.compilation.tap('SourcemapFixer', compilation => {
@@ -89,18 +93,23 @@ export class ResultStates {
);
compilation.hooks.buildModule.tap('findModule', (module) => {
if (/node_modules/.test(module.context)) {
const modulePath: string =
path.resolve(module.resourceResolveData.descriptionFileRoot, MODULE_SHARE_PATH);
if (fs.existsSync(modulePath)) {
this.modulePaths.add(modulePath);
}
if (module.context.indexOf(projectConfig.projectPath) >= 0) {
return;
}
const modulePath: string = path.join(module.context);
const srcIndex: number = modulePath.lastIndexOf(MODULE_ETS_PATH);
if (srcIndex < 0) {
return;
}
const moduleSharePath: string = path.resolve(modulePath.substring(0, srcIndex), MODULE_SHARE_PATH);
if (fs.existsSync(moduleSharePath)) {
this.moduleSharePaths.add(moduleSharePath);
}
});
});
compiler.hooks.afterCompile.tap('copyFindModule', () => {
this.modulePaths.forEach(modulePath => {
this.moduleSharePaths.forEach(modulePath => {
circularFile(modulePath, path.resolve(projectConfig.buildPath, BUILD_SHARE_PATH));
});
});
+2 -1
View File
@@ -190,8 +190,9 @@ export const BUILDER_ATTR_BIND: string = 'bind';
export const GEOMETRY_VIEW: string = 'GeometryView';
export const MODULE_SHARE_PATH: string = 'src' + path.sep + 'ets' + path.sep + 'share';
export const MODULE_SHARE_PATH: string = 'src' + path.sep + 'main' + path.sep + 'ets' + path.sep + 'share';
export const BUILD_SHARE_PATH: string = '../share';
export const MODULE_ETS_PATH: string = 'src' + path.sep + 'main' + path.sep + 'ets';
export const THIS: string = 'this';
export const STYLES: string = 'Styles';