frosty 0.0.67 → 0.0.69
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/README.md +50 -0
- package/dist/_native.d.ts +3 -3
- package/dist/_native.mjs +2 -2
- package/dist/dom.d.ts +3 -3
- package/dist/dom.mjs +3 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/internals/{common-jmXMOod4.d.ts → common-B0Nya-9e.d.ts} +3 -3
- package/dist/internals/{common-jmXMOod4.d.ts.map → common-B0Nya-9e.d.ts.map} +1 -1
- package/dist/internals/{common-uTufm_t7.mjs → common-Ca5Ux3vo.mjs} +3 -3
- package/dist/internals/{common-uTufm_t7.mjs.map → common-Ca5Ux3vo.mjs.map} +1 -1
- package/dist/internals/{common-C5xm7xDw.d.ts → common-lfYTb1eV.d.ts} +3 -3
- package/dist/internals/{common-C5xm7xDw.d.ts.map → common-lfYTb1eV.d.ts.map} +1 -1
- package/dist/internals/{fragment-BQXp1_iv.d.ts → fragment-CApRh6Hp.d.ts} +2 -2
- package/dist/internals/{fragment-BQXp1_iv.d.ts.map → fragment-CApRh6Hp.d.ts.map} +1 -1
- package/dist/internals/{renderer-DgKjFDB-.mjs → renderer-CEj3F2CM.mjs} +2 -2
- package/dist/internals/{renderer-DgKjFDB-.mjs.map → renderer-CEj3F2CM.mjs.map} +1 -1
- package/dist/internals/{renderer-D4aiCZGU.d.ts → renderer-DBPR_8BN.d.ts} +2 -2
- package/dist/internals/{renderer-D4aiCZGU.d.ts.map → renderer-DBPR_8BN.d.ts.map} +1 -1
- package/dist/internals/{state-j1YggBhW.mjs → state-C4Wldkq7.mjs} +2 -2
- package/dist/internals/{state-j1YggBhW.mjs.map → state-C4Wldkq7.mjs.map} +1 -1
- package/dist/internals/{sync-D_pTd9lu.mjs → sync-Ciycjqeo.mjs} +3 -3
- package/dist/internals/{sync-D_pTd9lu.mjs.map → sync-Ciycjqeo.mjs.map} +1 -1
- package/dist/internals/{utils-B_4b5vas.d.ts → utils-CyrF9IfR.d.ts} +2 -2
- package/dist/internals/{utils-B_4b5vas.d.ts.map → utils-CyrF9IfR.d.ts.map} +1 -1
- package/dist/jsx-dev-runtime.d.ts +7 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +14 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-dev-runtime.mjs +4 -0
- package/dist/jsx-dev-runtime.mjs.map +1 -0
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/jsx-runtime.mjs.map +1 -1
- package/dist/server-dom.d.ts +3 -3
- package/dist/server-dom.mjs +3 -3
- package/dist/web.d.ts +3 -3
- package/dist/web.mjs +5 -5
- package/package.json +3 -2
- package/packages/frosty-cli/package.json +5 -1
- package/packages/frosty-cli/scripts/bin/run.sh +81 -42
- package/packages/frosty-cli/src/server/env.js +26 -0
- package/packages/frosty-cli/src/server/index.js +7 -11
- package/packages/frosty-cli/src/server/render.js +9 -10
- package/packages/frosty-cli/src/server/route.ts +1 -7
- package/packages/frosty-cli/{webpack.js → webpack.mjs} +95 -51
|
@@ -1,49 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
//
|
|
2
|
+
// webpack.mjs
|
|
3
|
+
//
|
|
4
|
+
// The MIT License
|
|
5
|
+
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
// in the Software without restriction, including without limitation the rights
|
|
10
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
// furnished to do so, subject to the following conditions:
|
|
13
|
+
//
|
|
14
|
+
// The above copyright notice and this permission notice shall be included in
|
|
15
|
+
// all copies or substantial portions of the Software.
|
|
16
|
+
//
|
|
17
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
// THE SOFTWARE.
|
|
24
|
+
//
|
|
2
25
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const CopyPlugin = require('copy-webpack-plugin');
|
|
26
|
+
import _ from 'lodash';
|
|
27
|
+
import os from 'os';
|
|
28
|
+
import fs from 'fs';
|
|
29
|
+
import path from 'path';
|
|
30
|
+
import crypto from 'crypto';
|
|
31
|
+
import webpack from 'webpack';
|
|
32
|
+
import Dotenv from 'dotenv-webpack';
|
|
33
|
+
import TerserPlugin from 'terser-webpack-plugin';
|
|
34
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
13
35
|
|
|
14
|
-
const
|
|
15
|
-
try {
|
|
16
|
-
return require(path.resolve(process.cwd(), 'server.config.js'));
|
|
17
|
-
} catch {
|
|
18
|
-
return {};
|
|
19
|
-
}
|
|
20
|
-
})();
|
|
36
|
+
const { dirname: __dirname } = import.meta;
|
|
21
37
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
const { rollupConfig: { input } } = require(path.resolve(__dirname, '../../rollup.config.mjs'));
|
|
30
|
-
const resolved = {};
|
|
31
|
-
for (const [k, v] of _.entries(input)) {
|
|
32
|
-
if (k === 'index') continue;
|
|
33
|
-
resolved[`frosty/${k}`] = path.resolve(__dirname, '../..', v);
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
...resolved,
|
|
37
|
-
frosty: path.resolve(__dirname, '../../src/index'),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
})();
|
|
38
|
+
export default async (env, argv) => {
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
CONFIG_FILE = 'server.config.js',
|
|
42
|
+
INPUT_FILE,
|
|
43
|
+
PORT = 8080,
|
|
44
|
+
} = env;
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
const serverConfig = await (async () => {
|
|
47
|
+
try {
|
|
48
|
+
return await import(path.resolve(process.cwd(), CONFIG_FILE));
|
|
49
|
+
} catch {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
})();
|
|
43
53
|
|
|
44
54
|
const config = _.isFunction(serverConfig) ? serverConfig(env, argv) : serverConfig;
|
|
45
55
|
const IS_PRODUCTION = argv.mode !== 'development';
|
|
46
56
|
|
|
57
|
+
const {
|
|
58
|
+
SRCROOT = config.src,
|
|
59
|
+
OUTPUT_DIR = config.output || path.resolve(__dirname, 'dist'),
|
|
60
|
+
} = env;
|
|
61
|
+
|
|
62
|
+
const frostyDeps = await (async () => {
|
|
63
|
+
try {
|
|
64
|
+
const resolved = import.meta.resolve('frosty');
|
|
65
|
+
return {
|
|
66
|
+
frosty: path.dirname(resolved.replace('file://', '')),
|
|
67
|
+
};
|
|
68
|
+
} catch {
|
|
69
|
+
const { rollupConfig: { input } } = await import(path.resolve(__dirname, '../../rollup.config.mjs'));
|
|
70
|
+
const resolved = {};
|
|
71
|
+
for (const [k, v] of _.entries(input)) {
|
|
72
|
+
if (k === 'index') continue;
|
|
73
|
+
resolved[`frosty/${k}`] = path.resolve(__dirname, '../..', v);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
...resolved,
|
|
77
|
+
frosty: path.resolve(__dirname, '../../src/index'),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
})();
|
|
81
|
+
|
|
47
82
|
const babelLoaderConfiguration = ({ server }) => ({
|
|
48
83
|
test: /\.(ts|tsx|m?js)?$/i,
|
|
49
84
|
use: {
|
|
@@ -83,9 +118,9 @@ module.exports = (env, argv) => {
|
|
|
83
118
|
test: /\.(css|sass|scss)$/,
|
|
84
119
|
use: [
|
|
85
120
|
!server && MiniCssExtractPlugin.loader,
|
|
86
|
-
'css-loader',
|
|
121
|
+
path.resolve(__dirname, 'node_modules/css-loader'),
|
|
87
122
|
{
|
|
88
|
-
loader: 'postcss-loader',
|
|
123
|
+
loader: path.resolve(__dirname, 'node_modules/postcss-loader'),
|
|
89
124
|
options: {
|
|
90
125
|
postcssOptions: {
|
|
91
126
|
plugins: [
|
|
@@ -94,14 +129,14 @@ module.exports = (env, argv) => {
|
|
|
94
129
|
}
|
|
95
130
|
}
|
|
96
131
|
},
|
|
97
|
-
'sass-loader',
|
|
132
|
+
path.resolve(__dirname, 'node_modules/sass-loader'),
|
|
98
133
|
].filter(Boolean),
|
|
99
134
|
});
|
|
100
135
|
|
|
101
136
|
const imageLoaderConfiguration = ({ server }) => ({
|
|
102
137
|
test: /\.(gif|jpe?g|a?png|svg)$/i,
|
|
103
138
|
use: {
|
|
104
|
-
loader: 'file-loader',
|
|
139
|
+
loader: path.resolve(__dirname, 'node_modules/file-loader'),
|
|
105
140
|
options: {
|
|
106
141
|
name: '[name].[contenthash].[ext]',
|
|
107
142
|
publicPath: '/images',
|
|
@@ -114,7 +149,7 @@ module.exports = (env, argv) => {
|
|
|
114
149
|
const fontLoaderConfiguration = ({ server }) => ({
|
|
115
150
|
test: /\.ttf$/i,
|
|
116
151
|
use: {
|
|
117
|
-
loader: 'file-loader',
|
|
152
|
+
loader: path.resolve(__dirname, 'node_modules/file-loader'),
|
|
118
153
|
options: {
|
|
119
154
|
name: '[name].[contenthash].[ext]',
|
|
120
155
|
publicPath: '/fonts',
|
|
@@ -151,6 +186,9 @@ module.exports = (env, argv) => {
|
|
|
151
186
|
resolve: {
|
|
152
187
|
...config.options?.resolve ?? {},
|
|
153
188
|
alias: {
|
|
189
|
+
...SRCROOT ? {
|
|
190
|
+
'~': path.resolve(process.cwd(), SRCROOT),
|
|
191
|
+
} : {},
|
|
154
192
|
...frostyDeps,
|
|
155
193
|
...config.options?.resolve?.alias ?? {},
|
|
156
194
|
},
|
|
@@ -174,10 +212,11 @@ module.exports = (env, argv) => {
|
|
|
174
212
|
const random = crypto.randomUUID();
|
|
175
213
|
const tempDir = fs.mkdtempSync(`${os.tmpdir()}${path.sep}`);
|
|
176
214
|
const applications = path.resolve(tempDir, `applications-${random}.js`);
|
|
215
|
+
const inputs = INPUT_FILE ? { main: { entry: path.join(process.cwd(), INPUT_FILE), uri: '/' } } : config.client;
|
|
177
216
|
|
|
178
217
|
fs.writeFileSync(applications, `
|
|
179
|
-
${_.map(
|
|
180
|
-
export { ${_.keys(
|
|
218
|
+
${_.map(inputs, ({ entry }, name) => `import * as ${name} from '${path.resolve(process.cwd(), entry)}';`).join('\n')}
|
|
219
|
+
export { ${_.keys(inputs).join(',')} };
|
|
181
220
|
`);
|
|
182
221
|
|
|
183
222
|
const moduleSuffixes = {
|
|
@@ -186,18 +225,18 @@ module.exports = (env, argv) => {
|
|
|
186
225
|
};
|
|
187
226
|
|
|
188
227
|
return [
|
|
189
|
-
..._.map(
|
|
228
|
+
..._.map(inputs, ({ entry }, name) => ({
|
|
190
229
|
...webpackConfiguration,
|
|
191
230
|
optimization: webpackOptimization({ server: false }),
|
|
192
231
|
plugins: webpackPlugins,
|
|
193
232
|
entry: {
|
|
194
233
|
[`${name}_bundle`]: [
|
|
195
234
|
'core-js/stable',
|
|
196
|
-
path.resolve(__dirname, './client/index.js'),
|
|
235
|
+
path.resolve(__dirname, './src/client/index.js'),
|
|
197
236
|
],
|
|
198
237
|
},
|
|
199
238
|
output: {
|
|
200
|
-
path:
|
|
239
|
+
path: path.join(OUTPUT_DIR, 'public'),
|
|
201
240
|
},
|
|
202
241
|
resolve: {
|
|
203
242
|
...webpackConfiguration.resolve,
|
|
@@ -226,11 +265,16 @@ module.exports = (env, argv) => {
|
|
|
226
265
|
optimization: webpackOptimization({ server: false }),
|
|
227
266
|
plugins: _.compact([
|
|
228
267
|
...webpackPlugins,
|
|
268
|
+
new webpack.EnvironmentPlugin({ PORT }),
|
|
269
|
+
new webpack.DefinePlugin({
|
|
270
|
+
__applications__: JSON.stringify(_.mapValues(inputs, x => ({
|
|
271
|
+
path: x.uri,
|
|
272
|
+
basename: x.basename,
|
|
273
|
+
}))),
|
|
274
|
+
}),
|
|
229
275
|
...config.options?.server?.plugins ?? [],
|
|
230
|
-
config.serverAssets && new CopyPlugin({ patterns: config.serverAssets }),
|
|
231
276
|
]),
|
|
232
277
|
target: 'node',
|
|
233
|
-
plugins: webpackPlugins,
|
|
234
278
|
entry: {
|
|
235
279
|
server: [
|
|
236
280
|
'core-js/stable',
|
|
@@ -238,7 +282,7 @@ module.exports = (env, argv) => {
|
|
|
238
282
|
],
|
|
239
283
|
},
|
|
240
284
|
output: {
|
|
241
|
-
path:
|
|
285
|
+
path: OUTPUT_DIR,
|
|
242
286
|
},
|
|
243
287
|
resolve: {
|
|
244
288
|
...webpackConfiguration.resolve,
|