@scifeon/sdk 0.99.0 → 0.101.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.
Files changed (102) hide show
  1. package/dist/{sdk/src/action-target.d.ts → action-target.d.ts} +6 -6
  2. package/dist/{sdk/src/action-target.js → action-target.js} +10 -10
  3. package/dist/{sdk/src/app → app}/app-generator.d.ts +34 -34
  4. package/dist/{sdk/src/app → app}/app-generator.js +460 -460
  5. package/dist/{sdk/src/app → app}/app-persist.d.ts +18 -18
  6. package/dist/{sdk/src/app → app}/app-persist.js +193 -193
  7. package/dist/{sdk/src/app → app}/app-validator.d.ts +8 -8
  8. package/dist/{sdk/src/app → app}/app-validator.js +145 -145
  9. package/dist/{sdk/src/app → app}/interfaces/app-json.interface.d.ts +4 -4
  10. package/dist/{sdk/src/app → app}/interfaces/app-json.interface.js +2 -2
  11. package/dist/{sdk/src/app → app}/interfaces/app-type.enum.d.ts +5 -5
  12. package/dist/{sdk/src/app → app}/interfaces/app-type.enum.js +9 -9
  13. package/dist/{sdk/src/app → app}/interfaces/contributions/contributions-json.interface.d.ts +55 -55
  14. package/dist/{sdk/src/app → app}/interfaces/contributions/contributions-json.interface.js +2 -2
  15. package/dist/{sdk/src/app → app}/interfaces/contributions/main-menu.interface.d.ts +12 -12
  16. package/dist/{sdk/src/app → app}/interfaces/contributions/main-menu.interface.js +2 -2
  17. package/dist/{sdk/src/app → app}/interfaces/contributions/menu-item.interface.d.ts +5 -5
  18. package/dist/{sdk/src/app → app}/interfaces/contributions/menu-item.interface.js +2 -2
  19. package/dist/{sdk/src/app → app}/interfaces/contributions/page-menu-item.interface.d.ts +10 -10
  20. package/dist/{sdk/src/app → app}/interfaces/contributions/page-menu-item.interface.js +2 -2
  21. package/dist/{sdk/src/app → app}/interfaces/contributions/page-menu.interface.d.ts +9 -9
  22. package/dist/{sdk/src/app → app}/interfaces/contributions/page-menu.interface.js +2 -2
  23. package/dist/{sdk/src/app → app}/interfaces/package-json.interface.d.ts +14 -14
  24. package/dist/{sdk/src/app → app}/interfaces/package-json.interface.js +2 -2
  25. package/dist/{sdk/src/app → app}/interfaces/webpack-config.interface.d.ts +5 -5
  26. package/dist/{sdk/src/app → app}/interfaces/webpack-config.interface.js +2 -2
  27. package/dist/{sdk/src/cli → cli}/commands/app/build.d.ts +4 -4
  28. package/dist/{sdk/src/cli → cli}/commands/app/build.js +43 -43
  29. package/dist/{sdk/src/cli → cli}/commands/app/clean.d.ts +3 -3
  30. package/dist/{sdk/src/cli → cli}/commands/app/clean.js +15 -15
  31. package/dist/{sdk/src/cli → cli}/commands/app/debug.d.ts +3 -3
  32. package/dist/{sdk/src/cli → cli}/commands/app/debug.js +22 -22
  33. package/dist/{sdk/src/cli → cli}/commands/app/e2e-test.d.ts +3 -3
  34. package/dist/{sdk/src/cli → cli}/commands/app/e2e-test.js +23 -23
  35. package/dist/{sdk/src/cli → cli}/commands/app/new.d.ts +6 -6
  36. package/dist/{sdk/src/cli → cli}/commands/app/new.js +190 -190
  37. package/dist/{sdk/src/cli → cli}/commands/app/package.d.ts +3 -3
  38. package/dist/{sdk/src/cli → cli}/commands/app/package.js +10 -10
  39. package/dist/{sdk/src/cli → cli}/commands/app/post-process.d.ts +8 -8
  40. package/dist/{sdk/src/cli → cli}/commands/app/post-process.js +122 -122
  41. package/dist/{sdk/src/cli → cli}/commands/app/scaffold.d.ts +4 -4
  42. package/dist/{sdk/src/cli → cli}/commands/app/scaffold.js +19 -19
  43. package/dist/{sdk/src/cli → cli}/commands/app/unit-test.d.ts +3 -3
  44. package/dist/{sdk/src/cli → cli}/commands/app/unit-test.js +11 -11
  45. package/dist/{sdk/src/cli → cli}/commands/app/validate.d.ts +3 -3
  46. package/dist/{sdk/src/cli → cli}/commands/app/validate.js +20 -20
  47. package/dist/{sdk/src/cli → cli}/commands/app/version.d.ts +3 -3
  48. package/dist/{sdk/src/cli → cli}/commands/app/version.js +17 -17
  49. package/dist/{sdk/src/cli → cli}/commands/app/watch.d.ts +3 -3
  50. package/dist/{sdk/src/cli → cli}/commands/app/watch.js +48 -48
  51. package/dist/{sdk/src/cli → cli}/commands/scifeon/download.d.ts +3 -3
  52. package/dist/{sdk/src/cli → cli}/commands/scifeon/download.js +48 -48
  53. package/dist/{sdk/src/cli → cli}/commands/scifeon/run.d.ts +3 -3
  54. package/dist/{sdk/src/cli → cli}/commands/scifeon/run.js +41 -41
  55. package/dist/{sdk/src/cli → cli}/config.d.ts +11 -11
  56. package/dist/{sdk/src/cli → cli}/config.js +23 -23
  57. package/dist/{sdk/src/cli → cli}/index.d.ts +9 -9
  58. package/dist/{sdk/src/cli → cli}/index.js +159 -159
  59. package/dist/{sdk/src/cli → cli}/webpack-runner.d.ts +1 -1
  60. package/dist/{sdk/src/cli → cli}/webpack-runner.js +26 -26
  61. package/dist/{sdk/src/download-utils.d.ts → download-utils.d.ts} +3 -3
  62. package/dist/{sdk/src/download-utils.js → download-utils.js} +50 -50
  63. package/dist/{sdk/src/file-utils.d.ts → file-utils.d.ts} +5 -5
  64. package/dist/{sdk/src/file-utils.js → file-utils.js} +41 -41
  65. package/dist/{sdk/src/html-report.d.ts → html-report.d.ts} +15 -15
  66. package/dist/{sdk/src/html-report.js → html-report.js} +212 -212
  67. package/dist/{sdk/src/index.d.ts → index.d.ts} +2 -2
  68. package/dist/{sdk/src/index.js → index.js} +23 -23
  69. package/dist/{sdk/src/logger.d.ts → logger.d.ts} +14 -14
  70. package/dist/{sdk/src/logger.js → logger.js} +52 -52
  71. package/dist/{sdk/src/measurement-units.d.ts → measurement-units.d.ts} +5 -5
  72. package/dist/{sdk/src/measurement-units.js → measurement-units.js} +9 -9
  73. package/dist/{sdk/src/page-types.d.ts → page-types.d.ts} +6 -6
  74. package/dist/{sdk/src/page-types.js → page-types.js} +10 -10
  75. package/dist/{sdk/src/plugin-types.d.ts → plugin-types.d.ts} +43 -42
  76. package/dist/{sdk/src/plugin-types.js → plugin-types.js} +47 -46
  77. package/dist/{sdk/src/unit-test-runner.d.ts → unit-test-runner.d.ts} +1 -1
  78. package/dist/{sdk/src/unit-test-runner.js → unit-test-runner.js} +82 -82
  79. package/dist/utils/test-helper.d.ts +4 -0
  80. package/dist/{sdk/src/utils → utils}/test-helper.js +46 -46
  81. package/dist/{sdk/src/webpack-app-config.d.ts → webpack-app-config.d.ts} +2 -2
  82. package/dist/{sdk/src/webpack-app-config.js → webpack-app-config.js} +248 -248
  83. package/dist/{sdk/src/webpack-utils.d.ts → webpack-utils.d.ts} +8 -8
  84. package/dist/{sdk/src/webpack-utils.js → webpack-utils.js} +91 -91
  85. package/package.json +72 -72
  86. package/resources/new-app/README.md +12 -12
  87. package/resources/new-app/editor/.vscode/launch.json +40 -40
  88. package/resources/new-app/gitignore.txt +6 -6
  89. package/resources/new-app/typescript/src/index.html +14 -14
  90. package/resources/new-app/typescript/src/index.ts +32 -32
  91. package/resources/new-app/typescript/test/e2e/frontpage.test.ts +16 -16
  92. package/resources/new-app/typescript/test/e2e-config.ts +14 -14
  93. package/resources/new-app/typescript/test/unit/index.test.ts +7 -7
  94. package/resources/new-app/typescript/tsconfig.json +39 -39
  95. package/resources/scaffold-templates/scaffold-e2e-test.ts +19 -19
  96. package/resources/test/chai.js +10706 -10706
  97. package/resources/test/mocha.css +326 -326
  98. package/resources/test/mocha.js +16590 -16590
  99. package/resources/test/tests.html +26 -26
  100. package/dist/plugins/src/xlsx-types.d.ts +0 -281
  101. package/dist/plugins/src/xlsx-types.js +0 -2
  102. package/dist/sdk/src/utils/test-helper.d.ts +0 -5
@@ -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
+ }
@@ -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
+ }