@scifeon/sdk 0.100.0 → 0.102.0
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/action-target.d.ts +6 -6
- package/dist/action-target.js +10 -10
- package/dist/app/app-generator.d.ts +34 -34
- package/dist/app/app-generator.js +460 -460
- package/dist/app/app-persist.d.ts +18 -18
- package/dist/app/app-persist.js +193 -193
- package/dist/app/app-validator.d.ts +8 -8
- package/dist/app/app-validator.js +145 -145
- package/dist/app/interfaces/app-json.interface.d.ts +4 -4
- package/dist/app/interfaces/app-json.interface.js +2 -2
- package/dist/app/interfaces/app-type.enum.d.ts +5 -5
- package/dist/app/interfaces/app-type.enum.js +9 -9
- package/dist/app/interfaces/contributions/contributions-json.interface.d.ts +55 -55
- package/dist/app/interfaces/contributions/contributions-json.interface.js +2 -2
- package/dist/app/interfaces/contributions/main-menu.interface.d.ts +12 -12
- package/dist/app/interfaces/contributions/main-menu.interface.js +2 -2
- package/dist/app/interfaces/contributions/menu-item.interface.d.ts +5 -5
- package/dist/app/interfaces/contributions/menu-item.interface.js +2 -2
- package/dist/app/interfaces/contributions/page-menu-item.interface.d.ts +10 -10
- package/dist/app/interfaces/contributions/page-menu-item.interface.js +2 -2
- package/dist/app/interfaces/contributions/page-menu.interface.d.ts +9 -9
- package/dist/app/interfaces/contributions/page-menu.interface.js +2 -2
- package/dist/app/interfaces/package-json.interface.d.ts +14 -14
- package/dist/app/interfaces/package-json.interface.js +2 -2
- package/dist/app/interfaces/webpack-config.interface.d.ts +5 -5
- package/dist/app/interfaces/webpack-config.interface.js +2 -2
- package/dist/cli/commands/app/build.d.ts +4 -4
- package/dist/cli/commands/app/build.js +43 -43
- package/dist/cli/commands/app/clean.d.ts +3 -3
- package/dist/cli/commands/app/clean.js +15 -15
- package/dist/cli/commands/app/debug.d.ts +3 -3
- package/dist/cli/commands/app/debug.js +22 -22
- package/dist/cli/commands/app/e2e-test.d.ts +3 -3
- package/dist/cli/commands/app/e2e-test.js +23 -23
- package/dist/cli/commands/app/new.d.ts +6 -6
- package/dist/cli/commands/app/new.js +190 -190
- package/dist/cli/commands/app/package.d.ts +3 -3
- package/dist/cli/commands/app/package.js +10 -10
- package/dist/cli/commands/app/post-process.d.ts +8 -8
- package/dist/cli/commands/app/post-process.js +122 -122
- package/dist/cli/commands/app/scaffold.d.ts +4 -4
- package/dist/cli/commands/app/scaffold.js +19 -19
- package/dist/cli/commands/app/unit-test.d.ts +3 -3
- package/dist/cli/commands/app/unit-test.js +11 -11
- package/dist/cli/commands/app/validate.d.ts +3 -3
- package/dist/cli/commands/app/validate.js +20 -20
- package/dist/cli/commands/app/version.d.ts +3 -3
- package/dist/cli/commands/app/version.js +17 -17
- package/dist/cli/commands/app/watch.d.ts +3 -3
- package/dist/cli/commands/app/watch.js +48 -48
- package/dist/cli/commands/scifeon/download.d.ts +3 -3
- package/dist/cli/commands/scifeon/download.js +48 -48
- package/dist/cli/commands/scifeon/run.d.ts +3 -3
- package/dist/cli/commands/scifeon/run.js +41 -41
- package/dist/cli/config.d.ts +11 -11
- package/dist/cli/config.js +23 -23
- package/dist/cli/index.d.ts +9 -9
- package/dist/cli/index.js +159 -159
- package/dist/cli/webpack-runner.d.ts +1 -1
- package/dist/cli/webpack-runner.js +26 -26
- package/dist/download-utils.d.ts +3 -3
- package/dist/download-utils.js +50 -50
- package/dist/file-utils.d.ts +5 -5
- package/dist/file-utils.js +41 -41
- package/dist/html-report.d.ts +15 -15
- package/dist/html-report.js +212 -212
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -23
- package/dist/logger.d.ts +14 -14
- package/dist/logger.js +52 -52
- package/dist/measurement-units.d.ts +5 -5
- package/dist/measurement-units.js +9 -9
- package/dist/page-types.d.ts +6 -6
- package/dist/page-types.js +10 -10
- package/dist/plugin-types.d.ts +43 -42
- package/dist/plugin-types.js +47 -46
- package/dist/unit-test-runner.d.ts +1 -1
- package/dist/unit-test-runner.js +82 -82
- package/dist/utils/test-helper.d.ts +4 -4
- package/dist/utils/test-helper.js +46 -46
- package/dist/webpack-app-config.d.ts +2 -2
- package/dist/webpack-app-config.js +248 -248
- package/dist/webpack-utils.d.ts +8 -8
- package/dist/webpack-utils.js +91 -91
- package/package.json +72 -72
- package/resources/new-app/README.md +12 -12
- package/resources/new-app/editor/.vscode/launch.json +40 -40
- package/resources/new-app/gitignore.txt +6 -6
- package/resources/new-app/typescript/src/index.html +14 -14
- package/resources/new-app/typescript/src/index.ts +32 -32
- package/resources/new-app/typescript/test/e2e/frontpage.test.ts +16 -16
- package/resources/new-app/typescript/test/e2e-config.ts +14 -14
- package/resources/new-app/typescript/test/unit/index.test.ts +7 -7
- package/resources/new-app/typescript/tsconfig.json +39 -39
- package/resources/scaffold-templates/scaffold-e2e-test.ts +19 -19
- package/resources/test/chai.js +10706 -10706
- package/resources/test/mocha.css +326 -326
- package/resources/test/mocha.js +16590 -16590
- package/resources/test/tests.html +26 -26
|
@@ -1,248 +1,248 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.webpackAppConfig = void 0;
|
|
4
|
-
const AdmZip = require("adm-zip");
|
|
5
|
-
const chokidar = require("chokidar");
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
8
|
-
const path = require("path");
|
|
9
|
-
const PostCompile = require("post-compile-webpack-plugin");
|
|
10
|
-
const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
|
|
11
|
-
const webpack = require("webpack");
|
|
12
|
-
const app_generator_1 = require("./app/app-generator");
|
|
13
|
-
const file_utils_1 = require("./file-utils");
|
|
14
|
-
const logger_1 = require("./logger");
|
|
15
|
-
const webpack_utils_1 = require("./webpack-utils");
|
|
16
|
-
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
|
17
|
-
const TerserJSPlugin = require("terser-webpack-plugin");
|
|
18
|
-
function webpackAppConfig(env, config, appType = "sdk") {
|
|
19
|
-
env = env || { debug: true };
|
|
20
|
-
const DEBUG = env.debug;
|
|
21
|
-
const SDK = env.sdk;
|
|
22
|
-
const WATCH = env.watch;
|
|
23
|
-
const PACKAGE = env.package || env.prod;
|
|
24
|
-
const TEST = env.test;
|
|
25
|
-
try {
|
|
26
|
-
if (appType === "sdk" && process.argv.indexOf("--generatedDir") > -1) {
|
|
27
|
-
const outDir = path.resolve(process.argv[process.argv.indexOf("--generatedDir") + 1]);
|
|
28
|
-
config.jsonDir = path.resolve(outDir, "sdkApps");
|
|
29
|
-
config.manifestDir = path.resolve(outDir, "manifest");
|
|
30
|
-
}
|
|
31
|
-
let plugins = [];
|
|
32
|
-
if (appType !== "sdk") {
|
|
33
|
-
plugins = config.manifests.reverse().map(p => new webpack.DllReferencePlugin({
|
|
34
|
-
manifest: require(path.resolve(config.manifestDir, "packages", p + ".bundle.manifest.json")),
|
|
35
|
-
}));
|
|
36
|
-
plugins.push(new webpack.DllReferencePlugin({ manifest: require(path.resolve(config.manifestDir, "vendor", "vendor.bundle.manifest.json")) }));
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
plugins = getReplaceModulesPlugins(config.manifestDir, config.manifests.reverse());
|
|
40
|
-
}
|
|
41
|
-
let entry = {};
|
|
42
|
-
let output = {};
|
|
43
|
-
if (!TEST) {
|
|
44
|
-
const aureliaPlugins = [];
|
|
45
|
-
plugins = plugins.concat([
|
|
46
|
-
...aureliaPlugins,
|
|
47
|
-
new MiniCssExtractPlugin({
|
|
48
|
-
filename: "[name].[contenthash].css",
|
|
49
|
-
chunkFilename: "[id].[contenthash].css",
|
|
50
|
-
}),
|
|
51
|
-
new webpack_utils_1.IgnoreNotFoundExportPlugin(),
|
|
52
|
-
]);
|
|
53
|
-
if (PACKAGE) {
|
|
54
|
-
plugins.push(webpack_utils_1.WebpackUtils.parseLogForAzureDevOps());
|
|
55
|
-
}
|
|
56
|
-
file_utils_1.FileUtils.createDirRecurSync(config.tempDir);
|
|
57
|
-
const appGenerator = new app_generator_1.AppGenerator(config, appType);
|
|
58
|
-
let app = appGenerator.generate();
|
|
59
|
-
appGenerator.save(true);
|
|
60
|
-
if (process.env.VisualStudioEdition || WATCH || env.watchFiles) {
|
|
61
|
-
const watch = [path.resolve(config.appPath, "src")];
|
|
62
|
-
if (fs.existsSync(path.resolve(config.appPath, "contributions.json"))) {
|
|
63
|
-
watch.push(path.resolve(config.appPath, "contributions.json"));
|
|
64
|
-
}
|
|
65
|
-
chokidar.watch(watch, { ignoreInitial: true, awaitWriteFinish: true })
|
|
66
|
-
.on("all", () => {
|
|
67
|
-
app = appGenerator.generate();
|
|
68
|
-
appGenerator.save();
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (WATCH) {
|
|
72
|
-
plugins = plugins.concat([
|
|
73
|
-
new webpack.HotModuleReplacementPlugin(),
|
|
74
|
-
]);
|
|
75
|
-
}
|
|
76
|
-
else if (PACKAGE) {
|
|
77
|
-
plugins = plugins.concat([
|
|
78
|
-
new PostCompile(() => {
|
|
79
|
-
const packageDir = config.packageDir || config.outputDir;
|
|
80
|
-
const filename = path.resolve(packageDir, app.namespace + "." + app.name + ".zip");
|
|
81
|
-
logger_1.LOGGER.msg(`Packaging into ${filename}...`);
|
|
82
|
-
const zip = new AdmZip();
|
|
83
|
-
zip.addLocalFolder(path.resolve(config.outputDir, app.namespace, app.name), app.namespace + "/" + app.name);
|
|
84
|
-
zip.writeZip(filename);
|
|
85
|
-
}),
|
|
86
|
-
]);
|
|
87
|
-
}
|
|
88
|
-
const publicPath = webpack_utils_1.WebpackUtils.getPublicPath(config.publicPath + app.namespace + "/" + app.name + "/", "apps", app.namespace + "/" + app.name + "/bundles");
|
|
89
|
-
entry = {
|
|
90
|
-
app: [path.resolve(config.tempDir, "gen-app.js")],
|
|
91
|
-
};
|
|
92
|
-
output = {
|
|
93
|
-
path: path.resolve(config.outputDir, app.namespace, app.name, "bundles"),
|
|
94
|
-
publicPath,
|
|
95
|
-
filename: "app.js",
|
|
96
|
-
library: app.namespace.replace(/\./g, "_") + "_" + app.name,
|
|
97
|
-
libraryTarget: "jsonp",
|
|
98
|
-
chunkFilename: WATCH || DEBUG ? "[id].js" : "[id].[contenthash].js",
|
|
99
|
-
devtoolModuleFilenameTemplate: "webpack:///[resource-path]?[loaders]",
|
|
100
|
-
crossOriginLoading: "anonymous",
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
entry = { test: [path.resolve(config.tempDir, "unit-tests.js")] };
|
|
105
|
-
output = {
|
|
106
|
-
path: config.tempDir,
|
|
107
|
-
filename: "test-bundle.js",
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
optimization: {
|
|
112
|
-
minimizer: DEBUG || SDK ? [] : [new TerserJSPlugin({
|
|
113
|
-
terserOptions: {
|
|
114
|
-
ecma: 6,
|
|
115
|
-
compress: {
|
|
116
|
-
pure_funcs: ["console.info", "console.debug", "console.warn", "console.log"],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
parallel: true,
|
|
120
|
-
cache: true,
|
|
121
|
-
sourceMap: true,
|
|
122
|
-
}), new OptimizeCSSAssetsPlugin({})],
|
|
123
|
-
},
|
|
124
|
-
mode: WATCH || DEBUG || SDK || TEST ? "development" : "production",
|
|
125
|
-
devtool: DEBUG || WATCH ? "cheap-module-source-map" : "nosources-source-map",
|
|
126
|
-
entry,
|
|
127
|
-
resolve: {
|
|
128
|
-
extensions: [".ts", ".js"],
|
|
129
|
-
modules: config.modulesFolders,
|
|
130
|
-
plugins: [new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({ configFile: webpack_utils_1.WebpackUtils.transformTsConfig(path.resolve(config.appPath, "tsconfig.json")) })],
|
|
131
|
-
},
|
|
132
|
-
output,
|
|
133
|
-
module: {
|
|
134
|
-
rules: [
|
|
135
|
-
{
|
|
136
|
-
test: /\.html$/i,
|
|
137
|
-
loader: "html-loader",
|
|
138
|
-
options: {
|
|
139
|
-
minimize: {
|
|
140
|
-
removeComments: false,
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
test: /\.ts$/i,
|
|
146
|
-
exclude: [
|
|
147
|
-
path.resolve(config.appPath, "test"),
|
|
148
|
-
],
|
|
149
|
-
loader: "ts-loader",
|
|
150
|
-
options: { transpileOnly: DEBUG || WATCH },
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
test: /\.(sa|sc|c)ss$/,
|
|
154
|
-
use: [
|
|
155
|
-
DEBUG ? "style-loader" : MiniCssExtractPlugin.loader,
|
|
156
|
-
{
|
|
157
|
-
loader: "css-loader",
|
|
158
|
-
options: {
|
|
159
|
-
sourceMap: true,
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
loader: "sass-loader",
|
|
164
|
-
options: {
|
|
165
|
-
sassOptions: {
|
|
166
|
-
includePaths: ["packages/ui/style", "runtime/scifeon/generated/style"],
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: "url-loader?limit=25000" },
|
|
173
|
-
{ test: /\.(eot|ttf|woff|woff2)$/, use: "url-loader?limit=100000" },
|
|
174
|
-
],
|
|
175
|
-
},
|
|
176
|
-
plugins,
|
|
177
|
-
resolveLoader: {
|
|
178
|
-
modules: [
|
|
179
|
-
"node_modules",
|
|
180
|
-
path.resolve(__dirname, "..", "node_modules"),
|
|
181
|
-
path.resolve(__dirname, "..", "..", "node_modules"),
|
|
182
|
-
path.resolve(__dirname, "..", "..", "..", "node_modules"),
|
|
183
|
-
path.resolve(__dirname, "..", "..", "..", "..", "node_modules"),
|
|
184
|
-
...config.modulesFolders,
|
|
185
|
-
],
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
catch (err) {
|
|
190
|
-
logger_1.LOGGER.error("ERROR: " + err.message);
|
|
191
|
-
logger_1.LOGGER.error(err.stack + err.stacktrace);
|
|
192
|
-
logger_1.LOGGER.error("An error occurred when creating Webpack config with this input:");
|
|
193
|
-
logger_1.LOGGER.error("CONFIG: " + JSON.stringify(config, null, 2));
|
|
194
|
-
logger_1.LOGGER.error("ENV: " + JSON.stringify(env, null, 2));
|
|
195
|
-
logger_1.LOGGER.error("APP_TYPE: " + appType);
|
|
196
|
-
return null;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
exports.webpackAppConfig = webpackAppConfig;
|
|
200
|
-
function getReplaceModulesPlugins(dist, libs) {
|
|
201
|
-
const scifeonLibs = [];
|
|
202
|
-
const vendor = {
|
|
203
|
-
scope: "vendor",
|
|
204
|
-
manifest: JSON.parse(fs.readFileSync(path.resolve(dist, "vendor", "vendor.bundle.manifest.json")).toString()),
|
|
205
|
-
};
|
|
206
|
-
for (const lib of libs.filter(l => l.startsWith("scifeon"))) {
|
|
207
|
-
scifeonLibs.push({
|
|
208
|
-
scope: lib.replace("-", "_"),
|
|
209
|
-
name: `@${lib.replace("-", "/")}`,
|
|
210
|
-
path: `${lib.replace("-", "_")}/packages/${lib.replace("scifeon-", "")}/index.ts`,
|
|
211
|
-
manifest: JSON.parse(fs.readFileSync(path.resolve(dist, "packages", lib + ".bundle.manifest.json")).toString()),
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
let plugins = [new webpack.NormalModuleReplacementPlugin(/.*/, function (resource) {
|
|
215
|
-
for (const dep of resource.dependencies) {
|
|
216
|
-
if (dep.constructor
|
|
217
|
-
&& (dep.constructor.name === "HarmonyImportSpecifierDependency" || dep.constructor.name === "HarmonyImportSideEffectDependency")
|
|
218
|
-
&& dep.request === dep.userRequest
|
|
219
|
-
&& !dep.request.startsWith(".")) {
|
|
220
|
-
const scifeonLib = scifeonLibs.find(sl => sl.name === dep.request);
|
|
221
|
-
if (scifeonLib) {
|
|
222
|
-
dep.request = scifeonLib.path;
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
const replaceMatch = (manifestContent, request, prefix) => {
|
|
226
|
-
const match = Object.keys(manifestContent).find(m => m.includes(`/${request}/`)
|
|
227
|
-
|| m.includes(`${request}.js`)
|
|
228
|
-
|| m.includes(`${request}.ts`));
|
|
229
|
-
return match ? match.replace("./", prefix + "/") : null;
|
|
230
|
-
};
|
|
231
|
-
const match = replaceMatch(vendor.manifest.content, dep.request, vendor.scope);
|
|
232
|
-
if (match) {
|
|
233
|
-
dep.request = match;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
})];
|
|
239
|
-
plugins = plugins.concat(scifeonLibs.map(m => new webpack.DllReferencePlugin({
|
|
240
|
-
scope: m.scope,
|
|
241
|
-
manifest: m.manifest,
|
|
242
|
-
})));
|
|
243
|
-
plugins.push(new webpack.DllReferencePlugin({
|
|
244
|
-
scope: vendor.scope,
|
|
245
|
-
manifest: vendor.manifest,
|
|
246
|
-
}));
|
|
247
|
-
return plugins;
|
|
248
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webpackAppConfig = void 0;
|
|
4
|
+
const AdmZip = require("adm-zip");
|
|
5
|
+
const chokidar = require("chokidar");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const PostCompile = require("post-compile-webpack-plugin");
|
|
10
|
+
const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
|
|
11
|
+
const webpack = require("webpack");
|
|
12
|
+
const app_generator_1 = require("./app/app-generator");
|
|
13
|
+
const file_utils_1 = require("./file-utils");
|
|
14
|
+
const logger_1 = require("./logger");
|
|
15
|
+
const webpack_utils_1 = require("./webpack-utils");
|
|
16
|
+
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
|
17
|
+
const TerserJSPlugin = require("terser-webpack-plugin");
|
|
18
|
+
function webpackAppConfig(env, config, appType = "sdk") {
|
|
19
|
+
env = env || { debug: true };
|
|
20
|
+
const DEBUG = env.debug;
|
|
21
|
+
const SDK = env.sdk;
|
|
22
|
+
const WATCH = env.watch;
|
|
23
|
+
const PACKAGE = env.package || env.prod;
|
|
24
|
+
const TEST = env.test;
|
|
25
|
+
try {
|
|
26
|
+
if (appType === "sdk" && process.argv.indexOf("--generatedDir") > -1) {
|
|
27
|
+
const outDir = path.resolve(process.argv[process.argv.indexOf("--generatedDir") + 1]);
|
|
28
|
+
config.jsonDir = path.resolve(outDir, "sdkApps");
|
|
29
|
+
config.manifestDir = path.resolve(outDir, "manifest");
|
|
30
|
+
}
|
|
31
|
+
let plugins = [];
|
|
32
|
+
if (appType !== "sdk") {
|
|
33
|
+
plugins = config.manifests.reverse().map(p => new webpack.DllReferencePlugin({
|
|
34
|
+
manifest: require(path.resolve(config.manifestDir, "packages", p + ".bundle.manifest.json")),
|
|
35
|
+
}));
|
|
36
|
+
plugins.push(new webpack.DllReferencePlugin({ manifest: require(path.resolve(config.manifestDir, "vendor", "vendor.bundle.manifest.json")) }));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
plugins = getReplaceModulesPlugins(config.manifestDir, config.manifests.reverse());
|
|
40
|
+
}
|
|
41
|
+
let entry = {};
|
|
42
|
+
let output = {};
|
|
43
|
+
if (!TEST) {
|
|
44
|
+
const aureliaPlugins = [];
|
|
45
|
+
plugins = plugins.concat([
|
|
46
|
+
...aureliaPlugins,
|
|
47
|
+
new MiniCssExtractPlugin({
|
|
48
|
+
filename: "[name].[contenthash].css",
|
|
49
|
+
chunkFilename: "[id].[contenthash].css",
|
|
50
|
+
}),
|
|
51
|
+
new webpack_utils_1.IgnoreNotFoundExportPlugin(),
|
|
52
|
+
]);
|
|
53
|
+
if (PACKAGE) {
|
|
54
|
+
plugins.push(webpack_utils_1.WebpackUtils.parseLogForAzureDevOps());
|
|
55
|
+
}
|
|
56
|
+
file_utils_1.FileUtils.createDirRecurSync(config.tempDir);
|
|
57
|
+
const appGenerator = new app_generator_1.AppGenerator(config, appType);
|
|
58
|
+
let app = appGenerator.generate();
|
|
59
|
+
appGenerator.save(true);
|
|
60
|
+
if (process.env.VisualStudioEdition || WATCH || env.watchFiles) {
|
|
61
|
+
const watch = [path.resolve(config.appPath, "src")];
|
|
62
|
+
if (fs.existsSync(path.resolve(config.appPath, "contributions.json"))) {
|
|
63
|
+
watch.push(path.resolve(config.appPath, "contributions.json"));
|
|
64
|
+
}
|
|
65
|
+
chokidar.watch(watch, { ignoreInitial: true, awaitWriteFinish: true })
|
|
66
|
+
.on("all", () => {
|
|
67
|
+
app = appGenerator.generate();
|
|
68
|
+
appGenerator.save();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (WATCH) {
|
|
72
|
+
plugins = plugins.concat([
|
|
73
|
+
new webpack.HotModuleReplacementPlugin(),
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
else if (PACKAGE) {
|
|
77
|
+
plugins = plugins.concat([
|
|
78
|
+
new PostCompile(() => {
|
|
79
|
+
const packageDir = config.packageDir || config.outputDir;
|
|
80
|
+
const filename = path.resolve(packageDir, app.namespace + "." + app.name + ".zip");
|
|
81
|
+
logger_1.LOGGER.msg(`Packaging into ${filename}...`);
|
|
82
|
+
const zip = new AdmZip();
|
|
83
|
+
zip.addLocalFolder(path.resolve(config.outputDir, app.namespace, app.name), app.namespace + "/" + app.name);
|
|
84
|
+
zip.writeZip(filename);
|
|
85
|
+
}),
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
const publicPath = webpack_utils_1.WebpackUtils.getPublicPath(config.publicPath + app.namespace + "/" + app.name + "/", "apps", app.namespace + "/" + app.name + "/bundles");
|
|
89
|
+
entry = {
|
|
90
|
+
app: [path.resolve(config.tempDir, "gen-app.js")],
|
|
91
|
+
};
|
|
92
|
+
output = {
|
|
93
|
+
path: path.resolve(config.outputDir, app.namespace, app.name, "bundles"),
|
|
94
|
+
publicPath,
|
|
95
|
+
filename: "app.js",
|
|
96
|
+
library: app.namespace.replace(/\./g, "_") + "_" + app.name,
|
|
97
|
+
libraryTarget: "jsonp",
|
|
98
|
+
chunkFilename: WATCH || DEBUG ? "[id].js" : "[id].[contenthash].js",
|
|
99
|
+
devtoolModuleFilenameTemplate: "webpack:///[resource-path]?[loaders]",
|
|
100
|
+
crossOriginLoading: "anonymous",
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
entry = { test: [path.resolve(config.tempDir, "unit-tests.js")] };
|
|
105
|
+
output = {
|
|
106
|
+
path: config.tempDir,
|
|
107
|
+
filename: "test-bundle.js",
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
optimization: {
|
|
112
|
+
minimizer: DEBUG || SDK ? [] : [new TerserJSPlugin({
|
|
113
|
+
terserOptions: {
|
|
114
|
+
ecma: 6,
|
|
115
|
+
compress: {
|
|
116
|
+
pure_funcs: ["console.info", "console.debug", "console.warn", "console.log"],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
parallel: true,
|
|
120
|
+
cache: true,
|
|
121
|
+
sourceMap: true,
|
|
122
|
+
}), new OptimizeCSSAssetsPlugin({})],
|
|
123
|
+
},
|
|
124
|
+
mode: WATCH || DEBUG || SDK || TEST ? "development" : "production",
|
|
125
|
+
devtool: DEBUG || WATCH ? "cheap-module-source-map" : "nosources-source-map",
|
|
126
|
+
entry,
|
|
127
|
+
resolve: {
|
|
128
|
+
extensions: [".ts", ".js"],
|
|
129
|
+
modules: config.modulesFolders,
|
|
130
|
+
plugins: [new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({ configFile: webpack_utils_1.WebpackUtils.transformTsConfig(path.resolve(config.appPath, "tsconfig.json")) })],
|
|
131
|
+
},
|
|
132
|
+
output,
|
|
133
|
+
module: {
|
|
134
|
+
rules: [
|
|
135
|
+
{
|
|
136
|
+
test: /\.html$/i,
|
|
137
|
+
loader: "html-loader",
|
|
138
|
+
options: {
|
|
139
|
+
minimize: {
|
|
140
|
+
removeComments: false,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
test: /\.ts$/i,
|
|
146
|
+
exclude: [
|
|
147
|
+
path.resolve(config.appPath, "test"),
|
|
148
|
+
],
|
|
149
|
+
loader: "ts-loader",
|
|
150
|
+
options: { transpileOnly: DEBUG || WATCH },
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
test: /\.(sa|sc|c)ss$/,
|
|
154
|
+
use: [
|
|
155
|
+
DEBUG ? "style-loader" : MiniCssExtractPlugin.loader,
|
|
156
|
+
{
|
|
157
|
+
loader: "css-loader",
|
|
158
|
+
options: {
|
|
159
|
+
sourceMap: true,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
loader: "sass-loader",
|
|
164
|
+
options: {
|
|
165
|
+
sassOptions: {
|
|
166
|
+
includePaths: ["packages/ui/style", "runtime/scifeon/generated/style"],
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: "url-loader?limit=25000" },
|
|
173
|
+
{ test: /\.(eot|ttf|woff|woff2)$/, use: "url-loader?limit=100000" },
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
plugins,
|
|
177
|
+
resolveLoader: {
|
|
178
|
+
modules: [
|
|
179
|
+
"node_modules",
|
|
180
|
+
path.resolve(__dirname, "..", "node_modules"),
|
|
181
|
+
path.resolve(__dirname, "..", "..", "node_modules"),
|
|
182
|
+
path.resolve(__dirname, "..", "..", "..", "node_modules"),
|
|
183
|
+
path.resolve(__dirname, "..", "..", "..", "..", "node_modules"),
|
|
184
|
+
...config.modulesFolders,
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
logger_1.LOGGER.error("ERROR: " + err.message);
|
|
191
|
+
logger_1.LOGGER.error(err.stack + err.stacktrace);
|
|
192
|
+
logger_1.LOGGER.error("An error occurred when creating Webpack config with this input:");
|
|
193
|
+
logger_1.LOGGER.error("CONFIG: " + JSON.stringify(config, null, 2));
|
|
194
|
+
logger_1.LOGGER.error("ENV: " + JSON.stringify(env, null, 2));
|
|
195
|
+
logger_1.LOGGER.error("APP_TYPE: " + appType);
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.webpackAppConfig = webpackAppConfig;
|
|
200
|
+
function getReplaceModulesPlugins(dist, libs) {
|
|
201
|
+
const scifeonLibs = [];
|
|
202
|
+
const vendor = {
|
|
203
|
+
scope: "vendor",
|
|
204
|
+
manifest: JSON.parse(fs.readFileSync(path.resolve(dist, "vendor", "vendor.bundle.manifest.json")).toString()),
|
|
205
|
+
};
|
|
206
|
+
for (const lib of libs.filter(l => l.startsWith("scifeon"))) {
|
|
207
|
+
scifeonLibs.push({
|
|
208
|
+
scope: lib.replace("-", "_"),
|
|
209
|
+
name: `@${lib.replace("-", "/")}`,
|
|
210
|
+
path: `${lib.replace("-", "_")}/packages/${lib.replace("scifeon-", "")}/index.ts`,
|
|
211
|
+
manifest: JSON.parse(fs.readFileSync(path.resolve(dist, "packages", lib + ".bundle.manifest.json")).toString()),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
let plugins = [new webpack.NormalModuleReplacementPlugin(/.*/, function (resource) {
|
|
215
|
+
for (const dep of resource.dependencies) {
|
|
216
|
+
if (dep.constructor
|
|
217
|
+
&& (dep.constructor.name === "HarmonyImportSpecifierDependency" || dep.constructor.name === "HarmonyImportSideEffectDependency")
|
|
218
|
+
&& dep.request === dep.userRequest
|
|
219
|
+
&& !dep.request.startsWith(".")) {
|
|
220
|
+
const scifeonLib = scifeonLibs.find(sl => sl.name === dep.request);
|
|
221
|
+
if (scifeonLib) {
|
|
222
|
+
dep.request = scifeonLib.path;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
const replaceMatch = (manifestContent, request, prefix) => {
|
|
226
|
+
const match = Object.keys(manifestContent).find(m => m.includes(`/${request}/`)
|
|
227
|
+
|| m.includes(`${request}.js`)
|
|
228
|
+
|| m.includes(`${request}.ts`));
|
|
229
|
+
return match ? match.replace("./", prefix + "/") : null;
|
|
230
|
+
};
|
|
231
|
+
const match = replaceMatch(vendor.manifest.content, dep.request, vendor.scope);
|
|
232
|
+
if (match) {
|
|
233
|
+
dep.request = match;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
})];
|
|
239
|
+
plugins = plugins.concat(scifeonLibs.map(m => new webpack.DllReferencePlugin({
|
|
240
|
+
scope: m.scope,
|
|
241
|
+
manifest: m.manifest,
|
|
242
|
+
})));
|
|
243
|
+
plugins.push(new webpack.DllReferencePlugin({
|
|
244
|
+
scope: vendor.scope,
|
|
245
|
+
manifest: vendor.manifest,
|
|
246
|
+
}));
|
|
247
|
+
return plugins;
|
|
248
|
+
}
|
package/dist/webpack-utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare class WebpackUtils {
|
|
2
|
-
static parseLogForAzureDevOps(): any;
|
|
3
|
-
static getPublicPath(fallback: string, prefix: string, postfix?: string): string;
|
|
4
|
-
static transformTsConfig(file: string): string;
|
|
5
|
-
}
|
|
6
|
-
export declare class IgnoreNotFoundExportPlugin {
|
|
7
|
-
apply(compiler: any): void;
|
|
8
|
-
}
|
|
1
|
+
export declare class WebpackUtils {
|
|
2
|
+
static parseLogForAzureDevOps(): any;
|
|
3
|
+
static getPublicPath(fallback: string, prefix: string, postfix?: string): string;
|
|
4
|
+
static transformTsConfig(file: string): string;
|
|
5
|
+
}
|
|
6
|
+
export declare class IgnoreNotFoundExportPlugin {
|
|
7
|
+
apply(compiler: any): void;
|
|
8
|
+
}
|