@steambrew/ttc 1.0.0 → 1.0.1
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/Compiler.ts +42 -65
- package/Logger.ts +5 -5
- package/VersionMon.ts +5 -5
- package/dist/index.js +44 -60
- package/index.ts +6 -6
- package/package.json +1 -1
package/Compiler.ts
CHANGED
|
@@ -66,81 +66,59 @@ function InitializePlugins() {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
const ContructFunctions = (parts: any) => { return parts.join('\n'); }
|
|
70
|
+
|
|
69
71
|
function InsertMillennium(props: TranspilerProps)
|
|
70
72
|
{
|
|
71
|
-
const ContructFunctions = (parts: any) => { return parts.join('\n'); }
|
|
72
|
-
|
|
73
73
|
const generateBundle = (_: unknown, bundle: any) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (bundle[fileName].type != 'chunk') {
|
|
78
|
-
continue
|
|
79
|
-
}
|
|
74
|
+
for (const fileName in bundle) {
|
|
75
|
+
if (bundle[fileName].type != 'chunk') continue
|
|
76
|
+
|
|
80
77
|
Logger.Info("Injecting Millennium shims into module... " + chalk.green.bold("okay"))
|
|
81
78
|
|
|
82
79
|
bundle[fileName].code = ContructFunctions([
|
|
83
80
|
`const pluginName = "${props.strPluginInternalName}";`,
|
|
84
|
-
// insert the bootstrap function and call it
|
|
85
81
|
InitializePlugins.toString(), InitializePlugins.name + "()",
|
|
86
|
-
WrappedCallServerMethod,
|
|
87
|
-
WrappedCallable,
|
|
88
|
-
bundle[fileName].code,
|
|
82
|
+
WrappedCallServerMethod, WrappedCallable, bundle[fileName].code,
|
|
89
83
|
ExecutePluginModule.toString(), ExecutePluginModule.name + "()"
|
|
90
84
|
])
|
|
91
85
|
}
|
|
92
86
|
}
|
|
93
87
|
|
|
94
|
-
return {
|
|
95
|
-
name: 'add-plugin-main', generateBundle
|
|
96
|
-
};
|
|
88
|
+
return { name: String(), generateBundle };
|
|
97
89
|
}
|
|
98
90
|
|
|
99
91
|
function InsertWebkitMillennium(props: TranspilerProps)
|
|
100
92
|
{
|
|
101
|
-
const ContructFunctions = (parts: any) => { return parts.join('\n'); }
|
|
102
|
-
|
|
103
93
|
const generateBundle = (_: unknown, bundle: any) => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (bundle[fileName].type != 'chunk') {
|
|
108
|
-
continue
|
|
109
|
-
}
|
|
94
|
+
for (const fileName in bundle) {
|
|
95
|
+
if (bundle[fileName].type != 'chunk') continue
|
|
96
|
+
|
|
110
97
|
Logger.Info("Injecting Millennium shims into webkit module... " + chalk.green.bold("okay"))
|
|
111
98
|
|
|
112
99
|
bundle[fileName].code = ContructFunctions([
|
|
113
|
-
// define the plugin name at the top of the bundle, so it can be used in wrapped functions
|
|
114
100
|
`const pluginName = "${props.strPluginInternalName}";`,
|
|
115
|
-
// insert the bootstrap function and call it
|
|
116
101
|
InitializePlugins.toString(), InitializePlugins.name + "()",
|
|
117
|
-
// TODO
|
|
118
102
|
WrappedCallServerMethod, WrappedCallable, bundle[fileName].code,
|
|
119
103
|
ExecuteWebkitModule.toString(), ExecuteWebkitModule.name + "()"
|
|
120
104
|
])
|
|
121
105
|
}
|
|
122
106
|
}
|
|
123
107
|
|
|
124
|
-
return {
|
|
125
|
-
name: 'add-plugin-main', generateBundle
|
|
126
|
-
};
|
|
108
|
+
return { name: String(), generateBundle };
|
|
127
109
|
}
|
|
128
110
|
|
|
129
111
|
function GetPluginComponents(props: TranspilerProps) {
|
|
130
112
|
const pluginList = [
|
|
131
|
-
/**
|
|
132
|
-
* @brief resolve millennium, edit the exported bundle to work with millennium
|
|
133
|
-
*/
|
|
134
113
|
InsertMillennium(props),
|
|
135
114
|
typescript(), nodeResolve(), commonjs(), json(),
|
|
136
115
|
replace({
|
|
137
|
-
preventAssignment: true,
|
|
138
|
-
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
139
|
-
// replace callServerMethod with wrapped replacement function.
|
|
140
|
-
'Millennium.callServerMethod': `__call_server_method__`,
|
|
141
|
-
'client.callable': `__wrapped_callable__`,
|
|
142
116
|
delimiters: ['', ''],
|
|
143
|
-
|
|
117
|
+
preventAssignment: true,
|
|
118
|
+
'process.env.NODE_ENV' : JSON.stringify('production'),
|
|
119
|
+
'Millennium.callServerMethod' : `__call_server_method__`,
|
|
120
|
+
'client.callable' : `__wrapped_callable__`,
|
|
121
|
+
'client.pluginSelf' : 'window.PLUGIN_LIST[pluginName]',
|
|
144
122
|
'client.Millennium.exposeObj(': 'client.Millennium.exposeObj(exports, '
|
|
145
123
|
}),
|
|
146
124
|
]
|
|
@@ -155,28 +133,21 @@ function GetWebkitPluginComponents(props: TranspilerProps) {
|
|
|
155
133
|
const pluginList = [
|
|
156
134
|
InsertWebkitMillennium(props), typescript(), nodeResolve(), commonjs(), json(),
|
|
157
135
|
replace({
|
|
136
|
+
delimiters: ['', ''],
|
|
158
137
|
preventAssignment: true,
|
|
159
|
-
// replace callServerMethod with wrapped replacement function.
|
|
160
138
|
'Millennium.callServerMethod': `__call_server_method__`,
|
|
161
|
-
'
|
|
162
|
-
delimiters: ['', ''],
|
|
139
|
+
'webkit.callable': `__wrapped_callable__`,
|
|
163
140
|
}),
|
|
164
141
|
]
|
|
165
142
|
|
|
166
|
-
|
|
167
|
-
pluginList.push(terser())
|
|
168
|
-
}
|
|
143
|
+
props.bTersePlugin && pluginList.push(terser())
|
|
169
144
|
return pluginList
|
|
170
145
|
}
|
|
171
146
|
|
|
172
147
|
const GetFrontEndDirectory = () => {
|
|
173
148
|
const pluginJsonPath = './plugin.json';
|
|
174
|
-
|
|
175
149
|
try {
|
|
176
|
-
|
|
177
|
-
const frontendDirectory = pluginJson?.frontend;
|
|
178
|
-
|
|
179
|
-
return frontendDirectory ? frontendDirectory : "frontend";
|
|
150
|
+
return JSON.parse(fs.readFileSync(pluginJsonPath, 'utf8'))?.frontend ?? "frontend";
|
|
180
151
|
}
|
|
181
152
|
catch (error) {
|
|
182
153
|
return "frontend";
|
|
@@ -189,13 +160,20 @@ export const TranspilerPluginComponent = async (props: TranspilerProps) => {
|
|
|
189
160
|
input: `./${GetFrontEndDirectory()}/index.tsx`,
|
|
190
161
|
plugins: GetPluginComponents(props),
|
|
191
162
|
context: 'window',
|
|
192
|
-
external:
|
|
163
|
+
external: (id) => {
|
|
164
|
+
if (id === '@steambrew/webkit') {
|
|
165
|
+
Logger.Error('The @steambrew/webkit module should not be included in the frontend module, use @steambrew/client instead. Please remove it from the frontend module and try again.')
|
|
166
|
+
process.exit(1)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return id === '@steambrew/client' || id === 'react' || id === 'react-dom'
|
|
170
|
+
},
|
|
193
171
|
output: {
|
|
194
172
|
name: "millennium_main",
|
|
195
173
|
file: ".millennium/Dist/index.js",
|
|
196
174
|
globals: {
|
|
197
|
-
react: "window.SP_REACT",
|
|
198
|
-
"react-dom": "window.SP_REACTDOM",
|
|
175
|
+
"react" : "window.SP_REACT",
|
|
176
|
+
"react-dom" : "window.SP_REACTDOM",
|
|
199
177
|
"@steambrew/client": "window.MILLENNIUM_API"
|
|
200
178
|
},
|
|
201
179
|
exports: 'named',
|
|
@@ -207,34 +185,33 @@ export const TranspilerPluginComponent = async (props: TranspilerProps) => {
|
|
|
207
185
|
input: `./webkit/index.ts`,
|
|
208
186
|
plugins: GetWebkitPluginComponents(props),
|
|
209
187
|
context: 'window',
|
|
210
|
-
external:
|
|
188
|
+
external: (id) => {
|
|
189
|
+
if (id === '@steambrew/client') {
|
|
190
|
+
Logger.Error('The @steambrew/client module should not be included in the webkit module, use @steambrew/webkit instead. Please remove it from the webkit module and try again.')
|
|
191
|
+
process.exit(1)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return id === '@steambrew/webkit'
|
|
195
|
+
},
|
|
211
196
|
output: {
|
|
212
197
|
name: "millennium_main",
|
|
213
198
|
file: ".millennium/Dist/webkit.js",
|
|
214
199
|
exports: 'named',
|
|
215
200
|
format: 'iife',
|
|
216
201
|
globals: {
|
|
217
|
-
"@steambrew/
|
|
202
|
+
"@steambrew/webkit": "window.MILLENNIUM_API"
|
|
218
203
|
},
|
|
219
204
|
}
|
|
220
205
|
}
|
|
221
206
|
|
|
222
207
|
Logger.Info("Starting build; this may take a few moments...")
|
|
223
|
-
|
|
208
|
+
|
|
224
209
|
try {
|
|
225
|
-
|
|
226
|
-
const outputOptions = frontendRollupConfig.output as OutputOptions;
|
|
227
|
-
|
|
228
|
-
await bundle.write(outputOptions);
|
|
210
|
+
await (await rollup(frontendRollupConfig)).write(frontendRollupConfig.output as OutputOptions);
|
|
229
211
|
|
|
230
|
-
// check if the webkit file exists
|
|
231
212
|
if (fs.existsSync(`./webkit/index.ts`)) {
|
|
232
213
|
Logger.Info("Compiling webkit module...")
|
|
233
|
-
|
|
234
|
-
const bundle1 = await rollup(webkitRollupConfig);
|
|
235
|
-
const outputOptions1 = webkitRollupConfig.output as OutputOptions;
|
|
236
|
-
|
|
237
|
-
await bundle1.write(outputOptions1);
|
|
214
|
+
await (await rollup(webkitRollupConfig)).write(webkitRollupConfig.output as OutputOptions);
|
|
238
215
|
}
|
|
239
216
|
|
|
240
217
|
Logger.Info('Build succeeded!', Number((performance.now() - global.PerfStartTime).toFixed(3)), 'ms elapsed.')
|
package/Logger.ts
CHANGED
|
@@ -3,20 +3,20 @@ import chalk from 'chalk'
|
|
|
3
3
|
const Logger = {
|
|
4
4
|
|
|
5
5
|
Info: (...LogMessage: any) => {
|
|
6
|
-
console.log(chalk.magenta.bold("
|
|
6
|
+
console.log(chalk.magenta.bold("++"), ...LogMessage)
|
|
7
7
|
},
|
|
8
8
|
|
|
9
9
|
Warn: (...LogMessage: any) => {
|
|
10
|
-
console.log(chalk.yellow.bold("
|
|
10
|
+
console.log(chalk.yellow.bold("**"), ...LogMessage)
|
|
11
11
|
},
|
|
12
12
|
|
|
13
13
|
Error: (...LogMessage: any) => {
|
|
14
|
-
console.log(chalk.red.bold("
|
|
14
|
+
console.log(chalk.red.bold("!!"), ...LogMessage)
|
|
15
15
|
},
|
|
16
16
|
|
|
17
17
|
Tree: (strTitle: string, LogObject: any) => {
|
|
18
18
|
|
|
19
|
-
console.log(chalk.magenta.bold("
|
|
19
|
+
console.log(chalk.magenta.bold("++"), strTitle);
|
|
20
20
|
|
|
21
21
|
const isLocalPath = (strTestPath: string): boolean => {
|
|
22
22
|
// Regular expression to match common file path patterns
|
|
@@ -29,7 +29,7 @@ const Logger = {
|
|
|
29
29
|
|
|
30
30
|
for (const [index, [key, value]] of entries.entries()) {
|
|
31
31
|
|
|
32
|
-
const connector = index === totalEntries - 1 ? "
|
|
32
|
+
const connector = index === totalEntries - 1 ? " " : " "
|
|
33
33
|
let color = chalk.white
|
|
34
34
|
|
|
35
35
|
switch (typeof value) {
|
package/VersionMon.ts
CHANGED
|
@@ -6,21 +6,21 @@ import { Logger } from './Logger';
|
|
|
6
6
|
|
|
7
7
|
export const CheckForUpdates = async (): Promise<boolean> => {
|
|
8
8
|
return new Promise<boolean>(async (resolve) => {
|
|
9
|
-
const packageJsonPath = path.resolve(dirname(fileURLToPath(import.meta.url)), '
|
|
9
|
+
const packageJsonPath = path.resolve(dirname(fileURLToPath(import.meta.url)), '../package.json');
|
|
10
10
|
const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf8'));
|
|
11
11
|
|
|
12
|
-
fetch("https://registry.npmjs.org/
|
|
12
|
+
fetch("https://registry.npmjs.org/@steambrew/ttc").then(response => response.json()).then(json => {
|
|
13
13
|
|
|
14
14
|
if (json?.["dist-tags"]?.latest != packageJson.version) {
|
|
15
15
|
|
|
16
|
-
Logger.Tree(
|
|
17
|
-
cmd:
|
|
16
|
+
Logger.Tree(`@steambrew/ttc@${packageJson.version} requires update to ${json?.["dist-tags"]?.latest}`, {
|
|
17
|
+
cmd: `run "npm install @steambrew/ttc@${json?.["dist-tags"]?.latest}" to get latest updates!`
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
resolve(true)
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
|
-
Logger.Info(
|
|
23
|
+
Logger.Info(`@steambrew/ttc@${packageJson.version} is up-to-date!`)
|
|
24
24
|
resolve(false)
|
|
25
25
|
}
|
|
26
26
|
})
|
package/dist/index.js
CHANGED
|
@@ -15,16 +15,16 @@ import { performance as performance$1 } from 'perf_hooks';
|
|
|
15
15
|
|
|
16
16
|
const Logger = {
|
|
17
17
|
Info: (...LogMessage) => {
|
|
18
|
-
console.log(chalk.magenta.bold("
|
|
18
|
+
console.log(chalk.magenta.bold("++"), ...LogMessage);
|
|
19
19
|
},
|
|
20
20
|
Warn: (...LogMessage) => {
|
|
21
|
-
console.log(chalk.yellow.bold("
|
|
21
|
+
console.log(chalk.yellow.bold("**"), ...LogMessage);
|
|
22
22
|
},
|
|
23
23
|
Error: (...LogMessage) => {
|
|
24
|
-
console.log(chalk.red.bold("
|
|
24
|
+
console.log(chalk.red.bold("!!"), ...LogMessage);
|
|
25
25
|
},
|
|
26
26
|
Tree: (strTitle, LogObject) => {
|
|
27
|
-
console.log(chalk.magenta.bold("
|
|
27
|
+
console.log(chalk.magenta.bold("++"), strTitle);
|
|
28
28
|
const isLocalPath = (strTestPath) => {
|
|
29
29
|
// Regular expression to match common file path patterns
|
|
30
30
|
const filePathRegex = /^(\/|\.\/|\.\.\/|\w:\/)?([\w-.]+\/)*[\w-.]+\.\w+$/;
|
|
@@ -33,7 +33,7 @@ const Logger = {
|
|
|
33
33
|
const entries = Object.entries(LogObject);
|
|
34
34
|
const totalEntries = entries.length;
|
|
35
35
|
for (const [index, [key, value]] of entries.entries()) {
|
|
36
|
-
const connector = index === totalEntries - 1 ? "
|
|
36
|
+
const connector = index === totalEntries - 1 ? " " : " ";
|
|
37
37
|
let color = chalk.white;
|
|
38
38
|
switch (typeof value) {
|
|
39
39
|
case typeof String(): {
|
|
@@ -110,17 +110,17 @@ const ValidateParameters = (args) => {
|
|
|
110
110
|
|
|
111
111
|
const CheckForUpdates = async () => {
|
|
112
112
|
return new Promise(async (resolve) => {
|
|
113
|
-
const packageJsonPath = path.resolve(dirname(fileURLToPath(import.meta.url)), '
|
|
113
|
+
const packageJsonPath = path.resolve(dirname(fileURLToPath(import.meta.url)), '../package.json');
|
|
114
114
|
const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf8'));
|
|
115
|
-
fetch("https://registry.npmjs.org/
|
|
115
|
+
fetch("https://registry.npmjs.org/@steambrew/ttc").then(response => response.json()).then(json => {
|
|
116
116
|
if (json?.["dist-tags"]?.latest != packageJson.version) {
|
|
117
|
-
Logger.Tree(
|
|
118
|
-
cmd:
|
|
117
|
+
Logger.Tree(`@steambrew/ttc@${packageJson.version} requires update to ${json?.["dist-tags"]?.latest}`, {
|
|
118
|
+
cmd: `run "npm install @steambrew/ttc@${json?.["dist-tags"]?.latest}" to get latest updates!`
|
|
119
119
|
});
|
|
120
120
|
resolve(true);
|
|
121
121
|
}
|
|
122
122
|
else {
|
|
123
|
-
Logger.Info(
|
|
123
|
+
Logger.Info(`@steambrew/ttc@${packageJson.version} is up-to-date!`);
|
|
124
124
|
resolve(false);
|
|
125
125
|
}
|
|
126
126
|
});
|
|
@@ -201,66 +201,49 @@ function InitializePlugins() {
|
|
|
201
201
|
window.PLUGIN_LIST[pluginName] = {};
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
+
const ContructFunctions = (parts) => { return parts.join('\n'); };
|
|
204
205
|
function InsertMillennium(props) {
|
|
205
|
-
const ContructFunctions = (parts) => { return parts.join('\n'); };
|
|
206
206
|
const generateBundle = (_, bundle) => {
|
|
207
207
|
for (const fileName in bundle) {
|
|
208
|
-
if (bundle[fileName].type != 'chunk')
|
|
208
|
+
if (bundle[fileName].type != 'chunk')
|
|
209
209
|
continue;
|
|
210
|
-
}
|
|
211
210
|
Logger.Info("Injecting Millennium shims into module... " + chalk.green.bold("okay"));
|
|
212
211
|
bundle[fileName].code = ContructFunctions([
|
|
213
212
|
`const pluginName = "${props.strPluginInternalName}";`,
|
|
214
|
-
// insert the bootstrap function and call it
|
|
215
213
|
InitializePlugins.toString(), InitializePlugins.name + "()",
|
|
216
|
-
WrappedCallServerMethod,
|
|
217
|
-
WrappedCallable,
|
|
218
|
-
bundle[fileName].code,
|
|
214
|
+
WrappedCallServerMethod, WrappedCallable, bundle[fileName].code,
|
|
219
215
|
ExecutePluginModule.toString(), ExecutePluginModule.name + "()"
|
|
220
216
|
]);
|
|
221
217
|
}
|
|
222
218
|
};
|
|
223
|
-
return {
|
|
224
|
-
name: 'add-plugin-main', generateBundle
|
|
225
|
-
};
|
|
219
|
+
return { name: String(), generateBundle };
|
|
226
220
|
}
|
|
227
221
|
function InsertWebkitMillennium(props) {
|
|
228
|
-
const ContructFunctions = (parts) => { return parts.join('\n'); };
|
|
229
222
|
const generateBundle = (_, bundle) => {
|
|
230
223
|
for (const fileName in bundle) {
|
|
231
|
-
if (bundle[fileName].type != 'chunk')
|
|
224
|
+
if (bundle[fileName].type != 'chunk')
|
|
232
225
|
continue;
|
|
233
|
-
}
|
|
234
226
|
Logger.Info("Injecting Millennium shims into webkit module... " + chalk.green.bold("okay"));
|
|
235
227
|
bundle[fileName].code = ContructFunctions([
|
|
236
|
-
// define the plugin name at the top of the bundle, so it can be used in wrapped functions
|
|
237
228
|
`const pluginName = "${props.strPluginInternalName}";`,
|
|
238
|
-
// insert the bootstrap function and call it
|
|
239
229
|
InitializePlugins.toString(), InitializePlugins.name + "()",
|
|
240
|
-
// TODO
|
|
241
230
|
WrappedCallServerMethod, WrappedCallable, bundle[fileName].code,
|
|
242
231
|
ExecuteWebkitModule.toString(), ExecuteWebkitModule.name + "()"
|
|
243
232
|
]);
|
|
244
233
|
}
|
|
245
234
|
};
|
|
246
|
-
return {
|
|
247
|
-
name: 'add-plugin-main', generateBundle
|
|
248
|
-
};
|
|
235
|
+
return { name: String(), generateBundle };
|
|
249
236
|
}
|
|
250
237
|
function GetPluginComponents(props) {
|
|
251
238
|
const pluginList = [
|
|
252
|
-
/**
|
|
253
|
-
* @brief resolve millennium, edit the exported bundle to work with millennium
|
|
254
|
-
*/
|
|
255
239
|
InsertMillennium(props),
|
|
256
240
|
typescript(), nodeResolve(), commonjs(), json(),
|
|
257
241
|
replace({
|
|
242
|
+
delimiters: ['', ''],
|
|
258
243
|
preventAssignment: true,
|
|
259
244
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
260
|
-
// replace callServerMethod with wrapped replacement function.
|
|
261
245
|
'Millennium.callServerMethod': `__call_server_method__`,
|
|
262
246
|
'client.callable': `__wrapped_callable__`,
|
|
263
|
-
delimiters: ['', ''],
|
|
264
247
|
'client.pluginSelf': 'window.PLUGIN_LIST[pluginName]',
|
|
265
248
|
'client.Millennium.exposeObj(': 'client.Millennium.exposeObj(exports, '
|
|
266
249
|
}),
|
|
@@ -274,24 +257,19 @@ function GetWebkitPluginComponents(props) {
|
|
|
274
257
|
const pluginList = [
|
|
275
258
|
InsertWebkitMillennium(props), typescript(), nodeResolve(), commonjs(), json(),
|
|
276
259
|
replace({
|
|
260
|
+
delimiters: ['', ''],
|
|
277
261
|
preventAssignment: true,
|
|
278
|
-
// replace callServerMethod with wrapped replacement function.
|
|
279
262
|
'Millennium.callServerMethod': `__call_server_method__`,
|
|
280
|
-
'
|
|
281
|
-
delimiters: ['', ''],
|
|
263
|
+
'webkit.callable': `__wrapped_callable__`,
|
|
282
264
|
}),
|
|
283
265
|
];
|
|
284
|
-
|
|
285
|
-
pluginList.push(terser());
|
|
286
|
-
}
|
|
266
|
+
props.bTersePlugin && pluginList.push(terser());
|
|
287
267
|
return pluginList;
|
|
288
268
|
}
|
|
289
269
|
const GetFrontEndDirectory = () => {
|
|
290
270
|
const pluginJsonPath = './plugin.json';
|
|
291
271
|
try {
|
|
292
|
-
|
|
293
|
-
const frontendDirectory = pluginJson?.frontend;
|
|
294
|
-
return frontendDirectory ? frontendDirectory : "frontend";
|
|
272
|
+
return JSON.parse(fs.readFileSync(pluginJsonPath, 'utf8'))?.frontend ?? "frontend";
|
|
295
273
|
}
|
|
296
274
|
catch (error) {
|
|
297
275
|
return "frontend";
|
|
@@ -302,12 +280,18 @@ const TranspilerPluginComponent = async (props) => {
|
|
|
302
280
|
input: `./${GetFrontEndDirectory()}/index.tsx`,
|
|
303
281
|
plugins: GetPluginComponents(props),
|
|
304
282
|
context: 'window',
|
|
305
|
-
external:
|
|
283
|
+
external: (id) => {
|
|
284
|
+
if (id === '@steambrew/webkit') {
|
|
285
|
+
Logger.Error('The @steambrew/webkit module should not be included in the frontend module, use @steambrew/client instead. Please remove it from the frontend module and try again.');
|
|
286
|
+
process.exit(1);
|
|
287
|
+
}
|
|
288
|
+
return id === '@steambrew/client' || id === 'react' || id === 'react-dom';
|
|
289
|
+
},
|
|
306
290
|
output: {
|
|
307
291
|
name: "millennium_main",
|
|
308
292
|
file: ".millennium/Dist/index.js",
|
|
309
293
|
globals: {
|
|
310
|
-
react: "window.SP_REACT",
|
|
294
|
+
"react": "window.SP_REACT",
|
|
311
295
|
"react-dom": "window.SP_REACTDOM",
|
|
312
296
|
"@steambrew/client": "window.MILLENNIUM_API"
|
|
313
297
|
},
|
|
@@ -319,29 +303,29 @@ const TranspilerPluginComponent = async (props) => {
|
|
|
319
303
|
input: `./webkit/index.ts`,
|
|
320
304
|
plugins: GetWebkitPluginComponents(props),
|
|
321
305
|
context: 'window',
|
|
322
|
-
external:
|
|
306
|
+
external: (id) => {
|
|
307
|
+
if (id === '@steambrew/client') {
|
|
308
|
+
Logger.Error('The @steambrew/client module should not be included in the webkit module, use @steambrew/webkit instead. Please remove it from the webkit module and try again.');
|
|
309
|
+
process.exit(1);
|
|
310
|
+
}
|
|
311
|
+
return id === '@steambrew/webkit';
|
|
312
|
+
},
|
|
323
313
|
output: {
|
|
324
314
|
name: "millennium_main",
|
|
325
315
|
file: ".millennium/Dist/webkit.js",
|
|
326
316
|
exports: 'named',
|
|
327
317
|
format: 'iife',
|
|
328
318
|
globals: {
|
|
329
|
-
"@steambrew/
|
|
319
|
+
"@steambrew/webkit": "window.MILLENNIUM_API"
|
|
330
320
|
},
|
|
331
321
|
}
|
|
332
322
|
};
|
|
333
323
|
Logger.Info("Starting build; this may take a few moments...");
|
|
334
|
-
// Load the Rollup configuration file
|
|
335
324
|
try {
|
|
336
|
-
|
|
337
|
-
const outputOptions = frontendRollupConfig.output;
|
|
338
|
-
await bundle.write(outputOptions);
|
|
339
|
-
// check if the webkit file exists
|
|
325
|
+
await (await rollup(frontendRollupConfig)).write(frontendRollupConfig.output);
|
|
340
326
|
if (fs.existsSync(`./webkit/index.ts`)) {
|
|
341
327
|
Logger.Info("Compiling webkit module...");
|
|
342
|
-
|
|
343
|
-
const outputOptions1 = webkitRollupConfig.output;
|
|
344
|
-
await bundle1.write(outputOptions1);
|
|
328
|
+
await (await rollup(webkitRollupConfig)).write(webkitRollupConfig.output);
|
|
345
329
|
}
|
|
346
330
|
Logger.Info('Build succeeded!', Number((performance.now() - global.PerfStartTime).toFixed(3)), 'ms elapsed.');
|
|
347
331
|
}
|
|
@@ -361,11 +345,11 @@ const CheckModuleUpdates = async () => {
|
|
|
361
345
|
const StartCompilerModule = () => {
|
|
362
346
|
const parameters = ValidateParameters(process.argv.slice(2));
|
|
363
347
|
const bTersePlugin = parameters.type == BuildType.ProdBuild;
|
|
364
|
-
Logger.Tree("Transpiler config: ", {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
})
|
|
348
|
+
// Logger.Tree("Transpiler config: ", {
|
|
349
|
+
// target: parameters.targetPlugin,
|
|
350
|
+
// build: BuildType[parameters.type],
|
|
351
|
+
// minify: bTersePlugin
|
|
352
|
+
// })
|
|
369
353
|
ValidatePlugin(parameters.targetPlugin).then((json) => {
|
|
370
354
|
const props = {
|
|
371
355
|
bTersePlugin: bTersePlugin,
|
package/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { CheckForUpdates } from "./VersionMon"
|
|
|
10
10
|
import { ValidatePlugin } from './Linter'
|
|
11
11
|
import { TranspilerPluginComponent, TranspilerProps } from './Compiler'
|
|
12
12
|
import { performance } from 'perf_hooks';
|
|
13
|
-
import { Logger } from './Logger'
|
|
13
|
+
// import { Logger } from './Logger'
|
|
14
14
|
|
|
15
15
|
declare global {
|
|
16
16
|
var PerfStartTime: number;
|
|
@@ -25,11 +25,11 @@ const StartCompilerModule = () => {
|
|
|
25
25
|
const parameters = ValidateParameters( process.argv.slice(2) );
|
|
26
26
|
const bTersePlugin = parameters.type == BuildType.ProdBuild
|
|
27
27
|
|
|
28
|
-
Logger.Tree("Transpiler config: ", {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
28
|
+
// Logger.Tree("Transpiler config: ", {
|
|
29
|
+
// target: parameters.targetPlugin,
|
|
30
|
+
// build: BuildType[parameters.type],
|
|
31
|
+
// minify: bTersePlugin
|
|
32
|
+
// })
|
|
33
33
|
|
|
34
34
|
ValidatePlugin(parameters.targetPlugin).then((json: any) => {
|
|
35
35
|
|