@l-comedy/core 0.1.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 (31) hide show
  1. package/bin/lcomedy.js +1 -0
  2. package/dist/index.d.ts +85 -0
  3. package/dist/index.js +34 -0
  4. package/dist/plugins/app-config/createLComedyPluginAppConfig.d.ts +8 -0
  5. package/dist/plugins/app-config/createLComedyPluginAppConfig.js +161 -0
  6. package/dist/plugins/app-config/index.d.ts +5 -0
  7. package/dist/plugins/app-config/index.js +159 -0
  8. package/dist/plugins/html/createHtmlFile.d.ts +8 -0
  9. package/dist/plugins/html/createHtmlFile.js +61 -0
  10. package/dist/plugins/html/createLComedyPluginHtml.d.ts +8 -0
  11. package/dist/plugins/html/createLComedyPluginHtml.js +147 -0
  12. package/dist/plugins/html/createTemplateParameters.d.ts +12 -0
  13. package/dist/plugins/html/createTemplateParameters.js +39 -0
  14. package/dist/plugins/html/index.d.ts +5 -0
  15. package/dist/plugins/html/index.js +145 -0
  16. package/dist/plugins/layout/createLComedyPluginLayout.d.ts +8 -0
  17. package/dist/plugins/layout/createLComedyPluginLayout.js +69 -0
  18. package/dist/plugins/layout/index.d.ts +5 -0
  19. package/dist/plugins/layout/index.js +67 -0
  20. package/dist/plugins/page-loading/createLComedyPluginPageLoading.d.ts +8 -0
  21. package/dist/plugins/page-loading/createLComedyPluginPageLoading.js +67 -0
  22. package/dist/plugins/page-loading/index.d.ts +5 -0
  23. package/dist/plugins/page-loading/index.js +65 -0
  24. package/dist/plugins/route/createLComedyPluginRoute.d.ts +8 -0
  25. package/dist/plugins/route/createLComedyPluginRoute.js +118 -0
  26. package/dist/plugins/route/index.d.ts +5 -0
  27. package/dist/plugins/route/index.js +116 -0
  28. package/dist/plugins/types.d-gldCJl0t.d.ts +83 -0
  29. package/dist/run.d.ts +2 -0
  30. package/dist/run.js +634 -0
  31. package/package.json +66 -0
package/bin/lcomedy.js ADDED
@@ -0,0 +1 @@
1
+ require('../dist/run.js')
@@ -0,0 +1,85 @@
1
+ import { Configuration } from '@rspack/core';
2
+ import { Options } from 'html-webpack-plugin';
3
+ import { Config } from '@jest/types';
4
+
5
+ interface TestConfig {
6
+ unit?: Config.InitialOptions;
7
+ components?: Config.InitialOptions;
8
+ common?: Config.InitialOptions;
9
+ }
10
+
11
+ interface UserConfig {
12
+ port?: number
13
+ html?: HtmlConfig
14
+ route?: {
15
+ basename?: string
16
+ routes?: RouteConfig[]
17
+ }
18
+ plugins?: Array<'route' | LComedyPlugin>
19
+ rspackConfig?: Configuration
20
+ sourceDir?: string
21
+ output?: string
22
+ publicDir?: string
23
+ test?: TestConfig
24
+ }
25
+
26
+ interface LComedyPlugin {
27
+ name: string
28
+ generateFiles?: (setupConfig: SetupConfigPlugin) => Promise<void> | viod
29
+ modifyEntry?: (
30
+ setupConfig: SetupConfigPlugin
31
+ ) => EntryModifier | Promise<EntryModifier>
32
+ rspackConfig?: (
33
+ rspackConfig: Configuration,
34
+ setupConfig: SetupConfig
35
+ ) => Configuration | Promise<Configuration>
36
+ runtimeExports?: string[]
37
+ }
38
+
39
+ interface RouteConfig {
40
+ path: string
41
+ index?: boolean
42
+ component: string
43
+ children?: RouteConfig[]
44
+ lazy?: boolean
45
+ }
46
+
47
+ interface HtmlConfig {
48
+ title?: string
49
+ rootId?: string
50
+ headTags?: string[]
51
+ bodyBeforeTags?: string[]
52
+ bodyAfterTags?: string[]
53
+ htmlWebpackOptions?: Options
54
+ htmlTemplateParametersData?: Record<string, any>
55
+ }
56
+
57
+ interface SetupConfig {
58
+ isProd: boolean
59
+ root: string
60
+ userConfig: UserConfig
61
+ plugins: LComedyPlugin[]
62
+ workDir: string
63
+ sourceDir: string
64
+ workPath: string
65
+ sourcePath: string
66
+ }
67
+
68
+ type SetupConfigPlugin = Omit<SetupConfig, 'plugins'>
69
+
70
+ interface EntryModifier {
71
+ imports?: string[]
72
+ reactImports?: string[]
73
+ beforeRender?: string
74
+ afterRender?: string
75
+ devNeedWatchAddPaths?: string[]
76
+ devNeedWatchChangePaths?: string[]
77
+ app?: (app: string) => string
78
+ appWrap?: (app: string) => string
79
+ render?: (render: string) => string
80
+ renderRun?: (renderRun: string) => string
81
+ }
82
+
83
+ declare function defineConfig(config: UserConfig): UserConfig;
84
+
85
+ export { defineConfig };
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ defineConfig: () => defineConfig
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/client/defineConfig.ts
28
+ function defineConfig(config) {
29
+ return config;
30
+ }
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ defineConfig
34
+ });
@@ -0,0 +1,8 @@
1
+ import { L as LComedyPlugin } from '../types.d-gldCJl0t.js';
2
+ import '@rspack/core';
3
+ import 'html-webpack-plugin';
4
+ import '@jest/types';
5
+
6
+ declare function createLComedyPluginAppConfig(): LComedyPlugin;
7
+
8
+ export { createLComedyPluginAppConfig };
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+
47
+ // src/plugins/app-config/createLComedyPluginAppConfig.ts
48
+ var createLComedyPluginAppConfig_exports = {};
49
+ __export(createLComedyPluginAppConfig_exports, {
50
+ createLComedyPluginAppConfig: () => createLComedyPluginAppConfig
51
+ });
52
+ module.exports = __toCommonJS(createLComedyPluginAppConfig_exports);
53
+ var import_path = __toESM(require("path"));
54
+ var import_core = require("@rspack/core");
55
+ function createLComedyPluginAppConfig() {
56
+ return {
57
+ name: "l-comedy-plugin-app-config",
58
+ rspackConfig(rspackConfig, setupConfig) {
59
+ var _a;
60
+ const publicDir = setupConfig.userConfig.publicDir || "public";
61
+ const newConfig = __spreadProps(__spreadValues({}, rspackConfig), {
62
+ entry: import_path.default.posix.join(setupConfig.workPath, "entry.tsx"),
63
+ output: {
64
+ publicPath: "/",
65
+ path: import_path.default.posix.join(
66
+ setupConfig.root,
67
+ setupConfig.userConfig.output || "dist"
68
+ ),
69
+ filename: setupConfig.isProd ? "static/js/[name].[contenthash:8].js" : "static/js/[name].js",
70
+ clean: true
71
+ },
72
+ module: __spreadProps(__spreadValues({}, rspackConfig.module), {
73
+ rules: [
74
+ ...((_a = rspackConfig.module) == null ? void 0 : _a.rules) || [],
75
+ {
76
+ test: /\.(ts|tsx)$/,
77
+ exclude: /node_modules/,
78
+ use: [
79
+ {
80
+ loader: require.resolve("ts-loader"),
81
+ options: {
82
+ transpileOnly: true,
83
+ compilerOptions: {
84
+ paths: {
85
+ "@/*": ["src/*"]
86
+ }
87
+ }
88
+ }
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ test: /\.(css|less)$/,
94
+ use: [
95
+ setupConfig.isProd ? import_core.CssExtractRspackPlugin.loader : require.resolve("style-loader"),
96
+ {
97
+ loader: require.resolve("css-loader"),
98
+ options: {
99
+ modules: {
100
+ mode: "local",
101
+ auto: true,
102
+ localIdentName: setupConfig.isProd ? "[local]--[hash:base64:8]" : "[path][name]__[local]--[hash:base64:5]",
103
+ exportLocalsConvention: "camelCaseOnly",
104
+ namedExport: false,
105
+ exportOnlyLocals: false
106
+ },
107
+ esModule: true
108
+ }
109
+ },
110
+ {
111
+ loader: require.resolve("postcss-loader")
112
+ },
113
+ {
114
+ loader: require.resolve("less-loader"),
115
+ options: {
116
+ lessOptions: {
117
+ javascriptEnabled: true
118
+ }
119
+ }
120
+ }
121
+ ]
122
+ }
123
+ ]
124
+ }),
125
+ plugins: [
126
+ ...rspackConfig.plugins || [],
127
+ ...setupConfig.isProd ? [
128
+ new import_core.CssExtractRspackPlugin({
129
+ filename: "static/css/[name].[contenthash:8].css",
130
+ chunkFilename: "static/css/[name].[contenthash:8].chunk.css"
131
+ }),
132
+ new import_core.CopyRspackPlugin({
133
+ patterns: [
134
+ {
135
+ from: publicDir,
136
+ to: "."
137
+ }
138
+ ]
139
+ })
140
+ ] : []
141
+ ]
142
+ });
143
+ if (!setupConfig.isProd) {
144
+ newConfig.devServer = __spreadProps(__spreadValues({}, rspackConfig.devServer), {
145
+ port: setupConfig.userConfig.port,
146
+ hot: true,
147
+ historyApiFallback: true,
148
+ static: {
149
+ publicPath: "/",
150
+ directory: publicDir
151
+ }
152
+ });
153
+ }
154
+ return newConfig;
155
+ }
156
+ };
157
+ }
158
+ // Annotate the CommonJS export names for ESM import in node:
159
+ 0 && (module.exports = {
160
+ createLComedyPluginAppConfig
161
+ });
@@ -0,0 +1,5 @@
1
+ export { createLComedyPluginAppConfig as default } from './createLComedyPluginAppConfig.js';
2
+ import '../types.d-gldCJl0t.js';
3
+ import '@rspack/core';
4
+ import 'html-webpack-plugin';
5
+ import '@jest/types';
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+
47
+ // src/plugins/app-config/index.ts
48
+ var app_config_exports = {};
49
+ __export(app_config_exports, {
50
+ default: () => createLComedyPluginAppConfig
51
+ });
52
+ module.exports = __toCommonJS(app_config_exports);
53
+
54
+ // src/plugins/app-config/createLComedyPluginAppConfig.ts
55
+ var import_path = __toESM(require("path"));
56
+ var import_core = require("@rspack/core");
57
+ function createLComedyPluginAppConfig() {
58
+ return {
59
+ name: "l-comedy-plugin-app-config",
60
+ rspackConfig(rspackConfig, setupConfig) {
61
+ var _a;
62
+ const publicDir = setupConfig.userConfig.publicDir || "public";
63
+ const newConfig = __spreadProps(__spreadValues({}, rspackConfig), {
64
+ entry: import_path.default.posix.join(setupConfig.workPath, "entry.tsx"),
65
+ output: {
66
+ publicPath: "/",
67
+ path: import_path.default.posix.join(
68
+ setupConfig.root,
69
+ setupConfig.userConfig.output || "dist"
70
+ ),
71
+ filename: setupConfig.isProd ? "static/js/[name].[contenthash:8].js" : "static/js/[name].js",
72
+ clean: true
73
+ },
74
+ module: __spreadProps(__spreadValues({}, rspackConfig.module), {
75
+ rules: [
76
+ ...((_a = rspackConfig.module) == null ? void 0 : _a.rules) || [],
77
+ {
78
+ test: /\.(ts|tsx)$/,
79
+ exclude: /node_modules/,
80
+ use: [
81
+ {
82
+ loader: require.resolve("ts-loader"),
83
+ options: {
84
+ transpileOnly: true,
85
+ compilerOptions: {
86
+ paths: {
87
+ "@/*": ["src/*"]
88
+ }
89
+ }
90
+ }
91
+ }
92
+ ]
93
+ },
94
+ {
95
+ test: /\.(css|less)$/,
96
+ use: [
97
+ setupConfig.isProd ? import_core.CssExtractRspackPlugin.loader : require.resolve("style-loader"),
98
+ {
99
+ loader: require.resolve("css-loader"),
100
+ options: {
101
+ modules: {
102
+ mode: "local",
103
+ auto: true,
104
+ localIdentName: setupConfig.isProd ? "[local]--[hash:base64:8]" : "[path][name]__[local]--[hash:base64:5]",
105
+ exportLocalsConvention: "camelCaseOnly",
106
+ namedExport: false,
107
+ exportOnlyLocals: false
108
+ },
109
+ esModule: true
110
+ }
111
+ },
112
+ {
113
+ loader: require.resolve("postcss-loader")
114
+ },
115
+ {
116
+ loader: require.resolve("less-loader"),
117
+ options: {
118
+ lessOptions: {
119
+ javascriptEnabled: true
120
+ }
121
+ }
122
+ }
123
+ ]
124
+ }
125
+ ]
126
+ }),
127
+ plugins: [
128
+ ...rspackConfig.plugins || [],
129
+ ...setupConfig.isProd ? [
130
+ new import_core.CssExtractRspackPlugin({
131
+ filename: "static/css/[name].[contenthash:8].css",
132
+ chunkFilename: "static/css/[name].[contenthash:8].chunk.css"
133
+ }),
134
+ new import_core.CopyRspackPlugin({
135
+ patterns: [
136
+ {
137
+ from: publicDir,
138
+ to: "."
139
+ }
140
+ ]
141
+ })
142
+ ] : []
143
+ ]
144
+ });
145
+ if (!setupConfig.isProd) {
146
+ newConfig.devServer = __spreadProps(__spreadValues({}, rspackConfig.devServer), {
147
+ port: setupConfig.userConfig.port,
148
+ hot: true,
149
+ historyApiFallback: true,
150
+ static: {
151
+ publicPath: "/",
152
+ directory: publicDir
153
+ }
154
+ });
155
+ }
156
+ return newConfig;
157
+ }
158
+ };
159
+ }
@@ -0,0 +1,8 @@
1
+ import { S as SetupConfigPlugin } from '../types.d-gldCJl0t.js';
2
+ import '@rspack/core';
3
+ import 'html-webpack-plugin';
4
+ import '@jest/types';
5
+
6
+ declare function createHtmlFile(setupConfig: SetupConfigPlugin): void;
7
+
8
+ export { createHtmlFile };
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/plugins/html/createHtmlFile.ts
31
+ var createHtmlFile_exports = {};
32
+ __export(createHtmlFile_exports, {
33
+ createHtmlFile: () => createHtmlFile
34
+ });
35
+ module.exports = __toCommonJS(createHtmlFile_exports);
36
+ var import_fs_extra = __toESM(require("fs-extra"));
37
+ var import_path = __toESM(require("path"));
38
+ function createHtmlFile(setupConfig) {
39
+ var _a, _b, _c;
40
+ const htmlConfig = setupConfig.userConfig.html || {};
41
+ import_fs_extra.default.outputFileSync(
42
+ import_path.default.posix.join(setupConfig.workDir, "index.html"),
43
+ `<!DOCTYPE html>
44
+ <html>
45
+ <head>
46
+ <meta charset="utf-8" />
47
+ <title><%= TITLE %></title>
48
+ ${((_a = htmlConfig.headTags) == null ? void 0 : _a.join("\n")) || ""}
49
+ </head>
50
+ <body>
51
+ ${((_b = htmlConfig.bodyBeforeTags) == null ? void 0 : _b.join("\n")) || ""}
52
+ <div id="<%= ROOT_ID %>"></div>
53
+ ${((_c = htmlConfig.bodyAfterTags) == null ? void 0 : _c.join("\n")) || ""}
54
+ </body>
55
+ </html>`
56
+ );
57
+ }
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ createHtmlFile
61
+ });
@@ -0,0 +1,8 @@
1
+ import { L as LComedyPlugin } from '../types.d-gldCJl0t.js';
2
+ import '@rspack/core';
3
+ import 'html-webpack-plugin';
4
+ import '@jest/types';
5
+
6
+ declare function createLComedyPluginHtml(): LComedyPlugin;
7
+
8
+ export { createLComedyPluginHtml };
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+ var __async = (__this, __arguments, generator) => {
47
+ return new Promise((resolve, reject) => {
48
+ var fulfilled = (value) => {
49
+ try {
50
+ step(generator.next(value));
51
+ } catch (e) {
52
+ reject(e);
53
+ }
54
+ };
55
+ var rejected = (value) => {
56
+ try {
57
+ step(generator.throw(value));
58
+ } catch (e) {
59
+ reject(e);
60
+ }
61
+ };
62
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
63
+ step((generator = generator.apply(__this, __arguments)).next());
64
+ });
65
+ };
66
+
67
+ // src/plugins/html/createLComedyPluginHtml.ts
68
+ var createLComedyPluginHtml_exports = {};
69
+ __export(createLComedyPluginHtml_exports, {
70
+ createLComedyPluginHtml: () => createLComedyPluginHtml
71
+ });
72
+ module.exports = __toCommonJS(createLComedyPluginHtml_exports);
73
+ var import_path2 = __toESM(require("path"));
74
+ var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
75
+
76
+ // src/plugins/html/createHtmlFile.ts
77
+ var import_fs_extra = __toESM(require("fs-extra"));
78
+ var import_path = __toESM(require("path"));
79
+ function createHtmlFile(setupConfig) {
80
+ var _a, _b, _c;
81
+ const htmlConfig = setupConfig.userConfig.html || {};
82
+ import_fs_extra.default.outputFileSync(
83
+ import_path.default.posix.join(setupConfig.workDir, "index.html"),
84
+ `<!DOCTYPE html>
85
+ <html>
86
+ <head>
87
+ <meta charset="utf-8" />
88
+ <title><%= TITLE %></title>
89
+ ${((_a = htmlConfig.headTags) == null ? void 0 : _a.join("\n")) || ""}
90
+ </head>
91
+ <body>
92
+ ${((_b = htmlConfig.bodyBeforeTags) == null ? void 0 : _b.join("\n")) || ""}
93
+ <div id="<%= ROOT_ID %>"></div>
94
+ ${((_c = htmlConfig.bodyAfterTags) == null ? void 0 : _c.join("\n")) || ""}
95
+ </body>
96
+ </html>`
97
+ );
98
+ }
99
+
100
+ // src/plugins/html/createTemplateParameters.ts
101
+ function createTemplateParameters(setupConfig) {
102
+ var _a, _b;
103
+ return {
104
+ BUILD_TIME: (/* @__PURE__ */ new Date()).toISOString(),
105
+ // BUILD_TIMESTAMP: Date.now(),
106
+ // IS_PROD: setupConfig.isProd,
107
+ TITLE: ((_a = setupConfig.userConfig.html) == null ? void 0 : _a.title) || "App",
108
+ ROOT_ID: ((_b = setupConfig.userConfig.html) == null ? void 0 : _b.rootId) || "root"
109
+ };
110
+ }
111
+
112
+ // src/plugins/html/createLComedyPluginHtml.ts
113
+ function createLComedyPluginHtml() {
114
+ return {
115
+ name: "l-comedy-plugin-html",
116
+ rspackConfig(rspackConfig, setupConfig) {
117
+ var _a2, _b;
118
+ return __spreadProps(__spreadValues({}, rspackConfig), {
119
+ plugins: [
120
+ ...rspackConfig.plugins || [],
121
+ new import_html_webpack_plugin.default(__spreadProps(__spreadValues({
122
+ template: import_path2.default.posix.join(setupConfig.workDir, "index.html"),
123
+ filename: "index.html",
124
+ minify: setupConfig.isProd ? {
125
+ collapseWhitespace: true,
126
+ removeComments: true,
127
+ removeRedundantAttributes: true
128
+ } : false,
129
+ cache: true,
130
+ inject: true
131
+ }, (_a2 = setupConfig.userConfig.html) == null ? void 0 : _a2.htmlWebpackOptions), {
132
+ templateParameters: __spreadValues(__spreadValues({}, (_b = setupConfig.userConfig.html) == null ? void 0 : _b.htmlTemplateParametersData), createTemplateParameters(setupConfig))
133
+ }))
134
+ ]
135
+ });
136
+ },
137
+ generateFiles(setupConfig) {
138
+ return __async(this, null, function* () {
139
+ createHtmlFile(setupConfig);
140
+ });
141
+ }
142
+ };
143
+ }
144
+ // Annotate the CommonJS export names for ESM import in node:
145
+ 0 && (module.exports = {
146
+ createLComedyPluginHtml
147
+ });