@simplysm/sd-cli 12.5.6 → 12.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-tools/SdCliIndexFileGenerator.js +4 -7
- package/dist/build-tools/SdCliIndexFileGenerator.js.map +1 -1
- package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +2 -2
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js +22 -13
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +1 -1
- package/dist/build-tools/SdLinter.js +2 -1
- package/dist/build-tools/SdLinter.js.map +1 -1
- package/dist/build-tools/SdNgBundler.d.ts +0 -1
- package/dist/build-tools/SdNgBundler.js +4 -2
- package/dist/build-tools/SdNgBundler.js.map +1 -1
- package/dist/build-tools/SdReactBundler.d.ts +24 -0
- package/dist/build-tools/SdReactBundler.js +251 -0
- package/dist/build-tools/SdReactBundler.js.map +1 -0
- package/dist/build-tools/SdReactBundlerContext.d.ts +14 -0
- package/dist/build-tools/SdReactBundlerContext.js +59 -0
- package/dist/build-tools/SdReactBundlerContext.js.map +1 -0
- package/dist/build-tools/SdTsCompiler.js +32 -29
- package/dist/build-tools/SdTsCompiler.js.map +1 -1
- package/dist/build-tools/SdTsLibBundler.js +4 -3
- package/dist/build-tools/SdTsLibBundler.js.map +1 -1
- package/dist/builders/SdCliClientBuilder.js +53 -32
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.js +8 -11
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/bundle-plugins/sdNgPlugin.js +21 -11
- package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
- package/dist/bundle-plugins/sdReactPlugin.d.ts +15 -0
- package/dist/bundle-plugins/sdReactPlugin.js +111 -0
- package/dist/bundle-plugins/sdReactPlugin.js.map +1 -0
- package/dist/commons.d.ts +1 -2
- package/dist/entry/SdCliProject.js +1 -0
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +12 -5
- package/src/build-tools/SdCliIndexFileGenerator.ts +10 -12
- package/src/build-tools/SdCliNgRoutesFileGenerator.ts +33 -22
- package/src/build-tools/SdLinter.ts +2 -1
- package/src/build-tools/SdNgBundler.ts +4 -3
- package/src/build-tools/SdReactBundler.ts +325 -0
- package/src/build-tools/SdReactBundlerContext.ts +71 -0
- package/src/build-tools/SdTsCompiler.ts +146 -129
- package/src/build-tools/SdTsLibBundler.ts +9 -13
- package/src/builders/SdCliClientBuilder.ts +108 -69
- package/src/builders/SdCliTsLibBuilder.ts +35 -32
- package/src/bundle-plugins/sdNgPlugin.ts +59 -56
- package/src/bundle-plugins/sdReactPlugin.ts +157 -0
- package/src/commons.ts +1 -2
- package/src/entry/SdCliProject.ts +1 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import esbuild from "esbuild";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { ISdTsCompilerResult, SdTsCompiler } from "../build-tools/SdTsCompiler";
|
|
5
|
+
import { convertTypeScriptDiagnostic } from "@angular/build/src/tools/esbuild/angular/diagnostics";
|
|
6
|
+
import postcss from "postcss";
|
|
7
|
+
import { FsUtil } from "@simplysm/sd-core-node";
|
|
8
|
+
import postcssUrl from "postcss-url";
|
|
9
|
+
import postcssHas from "css-has-pseudo";
|
|
10
|
+
import autoprefixer from "autoprefixer";
|
|
11
|
+
|
|
12
|
+
export function sdReactPlugin(conf: {
|
|
13
|
+
pkgPath: string;
|
|
14
|
+
dev: boolean;
|
|
15
|
+
modifiedFileSet: Set<string>;
|
|
16
|
+
result: IReactPluginResultCache;
|
|
17
|
+
}): esbuild.Plugin {
|
|
18
|
+
return {
|
|
19
|
+
name: "sd-ng-compiler",
|
|
20
|
+
setup: (build: esbuild.PluginBuild) => {
|
|
21
|
+
const compiler = new SdTsCompiler(conf.pkgPath, { declaration: false }, conf.dev);
|
|
22
|
+
|
|
23
|
+
let buildResult: ISdTsCompilerResult;
|
|
24
|
+
const outputContentsCacheMap = new Map<string, string | Uint8Array | undefined>();
|
|
25
|
+
|
|
26
|
+
//---------------------------
|
|
27
|
+
|
|
28
|
+
build.onStart(async () => {
|
|
29
|
+
compiler.invalidate(conf.modifiedFileSet);
|
|
30
|
+
for (const modifiedFile of conf.modifiedFileSet) {
|
|
31
|
+
outputContentsCacheMap.delete(modifiedFile);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
buildResult = await compiler.buildAsync();
|
|
35
|
+
|
|
36
|
+
conf.result.watchFileSet = buildResult.watchFileSet;
|
|
37
|
+
conf.result.affectedFileSet = buildResult.affectedFileSet;
|
|
38
|
+
conf.result.program = buildResult.program;
|
|
39
|
+
|
|
40
|
+
//-- return err/warn
|
|
41
|
+
return {
|
|
42
|
+
errors: [
|
|
43
|
+
...buildResult.typescriptDiagnostics
|
|
44
|
+
.filter((item) => item.category === ts.DiagnosticCategory.Error)
|
|
45
|
+
.map((item) => convertTypeScriptDiagnostic(ts, item)),
|
|
46
|
+
...Array.from(buildResult.stylesheetBundlingResultMap.values()).flatMap((item) => item.errors),
|
|
47
|
+
].filterExists(),
|
|
48
|
+
warnings: [
|
|
49
|
+
...buildResult.typescriptDiagnostics
|
|
50
|
+
.filter((item) => item.category !== ts.DiagnosticCategory.Error)
|
|
51
|
+
.map((item) => convertTypeScriptDiagnostic(ts, item)),
|
|
52
|
+
// ...Array.from(buildResult.stylesheetResultMap.values()).flatMap(item => item.warnings)
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
build.onLoad({ filter: /\.tsx?$/ }, (args) => {
|
|
58
|
+
const output = outputContentsCacheMap.get(path.normalize(args.path));
|
|
59
|
+
if (output != null) {
|
|
60
|
+
return { contents: output, loader: "js" };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const emittedJsFile = buildResult.emittedFilesCacheMap.get(path.normalize(args.path))?.last();
|
|
64
|
+
if (!emittedJsFile) {
|
|
65
|
+
throw new Error(`ts 빌더 결과 emit 파일이 존재하지 않습니다. ${args.path}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const contents = emittedJsFile.text;
|
|
69
|
+
|
|
70
|
+
outputContentsCacheMap.set(path.normalize(args.path), contents);
|
|
71
|
+
|
|
72
|
+
return { contents, loader: "js" };
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
build.onLoad({ filter: /\.[cm]?jsx?$/ }, (args) => {
|
|
76
|
+
conf.result.watchFileSet!.add(path.normalize(args.path));
|
|
77
|
+
return null;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
build.onLoad({ filter: /\.css$/ }, async (args) => {
|
|
81
|
+
conf.result.watchFileSet!.add(path.normalize(args.path));
|
|
82
|
+
const output = outputContentsCacheMap.get(path.normalize(args.path));
|
|
83
|
+
if (output != null) {
|
|
84
|
+
return {
|
|
85
|
+
contents: output,
|
|
86
|
+
loader: "file",
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const css = await FsUtil.readFileAsync(path.normalize(args.path));
|
|
91
|
+
const result = await postcss()
|
|
92
|
+
.use(
|
|
93
|
+
autoprefixer({
|
|
94
|
+
overrideBrowserslist: ["Chrome > 78"]
|
|
95
|
+
})
|
|
96
|
+
)
|
|
97
|
+
.use(
|
|
98
|
+
postcssUrl({
|
|
99
|
+
url: "copy",
|
|
100
|
+
}),
|
|
101
|
+
)
|
|
102
|
+
.use(
|
|
103
|
+
postcssHas()
|
|
104
|
+
)
|
|
105
|
+
.process(css, {
|
|
106
|
+
from: path.normalize(args.path),
|
|
107
|
+
to: path.resolve(conf.pkgPath, "dist", "media", path.basename(args.path)),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
outputContentsCacheMap.set(path.normalize(args.path), result.css);
|
|
111
|
+
|
|
112
|
+
return { contents: result.css, loader: "file" };
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
build.onLoad(
|
|
116
|
+
{
|
|
117
|
+
filter: new RegExp(
|
|
118
|
+
"(" +
|
|
119
|
+
Object.keys(build.initialOptions.loader!)
|
|
120
|
+
.map((item) => "\\" + item)
|
|
121
|
+
.join("|") +
|
|
122
|
+
")$",
|
|
123
|
+
),
|
|
124
|
+
},
|
|
125
|
+
(args) => {
|
|
126
|
+
conf.result.watchFileSet!.add(path.normalize(args.path));
|
|
127
|
+
return null;
|
|
128
|
+
},
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
build.onEnd((result) => {
|
|
132
|
+
for (const { outputFiles, metafile } of buildResult.stylesheetBundlingResultMap.values()) {
|
|
133
|
+
result.outputFiles = result.outputFiles ?? [];
|
|
134
|
+
result.outputFiles.push(...outputFiles);
|
|
135
|
+
|
|
136
|
+
if (result.metafile && metafile) {
|
|
137
|
+
result.metafile.inputs = { ...result.metafile.inputs, ...metafile.inputs };
|
|
138
|
+
result.metafile.outputs = { ...result.metafile.outputs, ...metafile.outputs };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
conf.result.outputFiles = result.outputFiles;
|
|
143
|
+
conf.result.metafile = result.metafile;
|
|
144
|
+
|
|
145
|
+
conf.modifiedFileSet.clear();
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface IReactPluginResultCache {
|
|
152
|
+
watchFileSet?: Set<string>;
|
|
153
|
+
affectedFileSet?: Set<string>;
|
|
154
|
+
program?: ts.Program;
|
|
155
|
+
outputFiles?: esbuild.OutputFile[];
|
|
156
|
+
metafile?: esbuild.Metafile;
|
|
157
|
+
}
|
package/src/commons.ts
CHANGED
|
@@ -92,6 +92,7 @@ export interface ISdCliClientPackageConfig {
|
|
|
92
92
|
publish?: ISdCliLocalDirectoryPublishConfig | ISdCliFtpPublishConfig;
|
|
93
93
|
env?: Record<string, string>;
|
|
94
94
|
configs?: Record<string, any>;
|
|
95
|
+
noLazyRoute?: boolean;
|
|
95
96
|
|
|
96
97
|
builder?: {
|
|
97
98
|
web?: ISdCliClientBuilderWebConfig;
|
|
@@ -122,14 +123,12 @@ export interface ISdCliClientBuilderElectronConfig {
|
|
|
122
123
|
// devServerPort?: number;
|
|
123
124
|
reinstallDependencies?: string[];
|
|
124
125
|
env?: Record<string, string>;
|
|
125
|
-
browserslist?: string[];
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
export interface ISdCliClientBuilderWebConfig {
|
|
129
129
|
// devServerHost?: string;
|
|
130
130
|
// devServerPort?: number;
|
|
131
131
|
env?: Record<string, string>;
|
|
132
|
-
browserslist?: string[];
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
export interface ISdCliClientBuilderCordovaConfig {
|
|
@@ -381,6 +381,7 @@ export class SdCliProject {
|
|
|
381
381
|
if (projConf.postPublish && projConf.postPublish.length > 0) {
|
|
382
382
|
logger.debug("배포후 작업...");
|
|
383
383
|
for (const postPublishItem of projConf.postPublish) {
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
384
385
|
if (postPublishItem.type === "script") {
|
|
385
386
|
const script = postPublishItem.script.replace(/%([^%]*)%/g, (item) => {
|
|
386
387
|
const envName = item.replace(/%/g, "");
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ export * from "./build-tools/SdCliNgRoutesFileGenerator";
|
|
|
4
4
|
export * from "./build-tools/SdLinter";
|
|
5
5
|
export * from "./build-tools/SdNgBundler";
|
|
6
6
|
export * from "./build-tools/SdNgBundlerContext";
|
|
7
|
+
export * from "./build-tools/SdReactBundler";
|
|
8
|
+
export * from "./build-tools/SdReactBundlerContext";
|
|
7
9
|
export * from "./build-tools/SdServerBundler";
|
|
8
10
|
export * from "./build-tools/SdTsCompiler";
|
|
9
11
|
export * from "./build-tools/SdTsLibBundler";
|
|
@@ -12,6 +14,7 @@ export * from "./builders/SdCliJsLibLinter";
|
|
|
12
14
|
export * from "./builders/SdCliServerBuilder";
|
|
13
15
|
export * from "./builders/SdCliTsLibBuilder";
|
|
14
16
|
export * from "./bundle-plugins/sdNgPlugin";
|
|
17
|
+
export * from "./bundle-plugins/sdReactPlugin";
|
|
15
18
|
export * from "./bundle-plugins/sdServerPlugin";
|
|
16
19
|
export * from "./commons";
|
|
17
20
|
export * from "./entry/SdCliElectron";
|