proteum 1.0.3 → 2.0.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/AGENTS.md +92 -0
- package/agents/codex/AGENTS.md +95 -0
- package/agents/codex/CODING_STYLE.md +71 -0
- package/agents/codex/agents.md.zip +0 -0
- package/agents/codex/client/AGENTS.md +102 -0
- package/agents/codex/client/pages/AGENTS.md +35 -0
- package/agents/codex/server/routes/AGENTS.md +12 -0
- package/agents/codex/server/services/AGENTS.md +137 -0
- package/agents/codex/tests/AGENTS.md +8 -0
- package/cli/app/config.ts +12 -17
- package/cli/app/index.ts +59 -99
- package/cli/bin.js +1 -1
- package/cli/commands/build.ts +23 -12
- package/cli/commands/check.ts +19 -0
- package/cli/commands/deploy/app.ts +4 -8
- package/cli/commands/deploy/web.ts +16 -20
- package/cli/commands/dev.ts +185 -75
- package/cli/commands/devEvents.ts +106 -0
- package/cli/commands/init.ts +63 -57
- package/cli/commands/lint.ts +21 -0
- package/cli/commands/refresh.ts +6 -6
- package/cli/commands/typecheck.ts +18 -0
- package/cli/compiler/client/identite.ts +79 -49
- package/cli/compiler/client/index.ts +132 -214
- package/cli/compiler/common/bundleAnalysis.ts +94 -0
- package/cli/compiler/common/clientManifest.ts +67 -0
- package/cli/compiler/common/controllers.ts +288 -0
- package/cli/compiler/common/files/autres.ts +7 -18
- package/cli/compiler/common/files/images.ts +40 -37
- package/cli/compiler/common/files/style.ts +12 -25
- package/cli/compiler/common/generatedRouteModules.ts +368 -0
- package/cli/compiler/common/index.ts +29 -68
- package/cli/compiler/common/loaders/forbid-ssr-import.js +13 -0
- package/cli/compiler/common/rspackAliases.ts +13 -0
- package/cli/compiler/common/scripts.ts +37 -0
- package/cli/compiler/index.ts +764 -234
- package/cli/compiler/server/index.ts +52 -77
- package/cli/compiler/writeIfChanged.ts +21 -0
- package/cli/index.ts +65 -90
- package/cli/paths.ts +51 -57
- package/cli/print.ts +17 -11
- package/cli/tsconfig.json +5 -4
- package/cli/utils/agents.ts +100 -0
- package/cli/utils/check.ts +71 -0
- package/cli/utils/index.ts +1 -3
- package/cli/utils/keyboard.ts +8 -25
- package/cli/utils/runProcess.ts +30 -0
- package/client/app/component.tsx +29 -29
- package/client/app/index.ts +36 -57
- package/client/app/service.ts +7 -12
- package/client/app.tsconfig.json +2 -2
- package/client/components/Dialog/Manager.ssr.tsx +40 -0
- package/client/components/Dialog/Manager.tsx +119 -150
- package/client/components/Dialog/status.tsx +3 -3
- package/client/components/index.ts +1 -1
- package/client/components/types.d.ts +1 -3
- package/client/dev/hmr.ts +65 -0
- package/client/global.d.ts +2 -2
- package/client/hooks.ts +6 -9
- package/client/index.ts +2 -1
- package/client/islands/index.ts +7 -0
- package/client/islands/useDeferredModule.ts +199 -0
- package/client/pages/_layout/index.tsx +4 -12
- package/client/pages/useHeader.tsx +14 -21
- package/client/router.ts +27 -0
- package/client/services/router/components/Link.tsx +34 -27
- package/client/services/router/components/Page.tsx +6 -14
- package/client/services/router/components/router.ssr.tsx +36 -0
- package/client/services/router/components/router.tsx +63 -83
- package/client/services/router/index.tsx +185 -220
- package/client/services/router/request/api.ts +97 -119
- package/client/services/router/request/history.ts +2 -2
- package/client/services/router/request/index.ts +13 -12
- package/client/services/router/request/multipart.ts +72 -62
- package/client/services/router/response/index.tsx +68 -61
- package/client/services/router/response/page.ts +28 -32
- package/client/utils/dom.ts +17 -33
- package/common/app/index.ts +3 -3
- package/common/data/chaines/index.ts +22 -23
- package/common/data/dates.ts +35 -70
- package/common/data/markdown.ts +42 -39
- package/common/dev/serverHotReload.ts +26 -0
- package/common/errors/index.tsx +110 -142
- package/common/router/contracts.ts +29 -0
- package/common/router/index.ts +89 -108
- package/common/router/layouts.ts +34 -47
- package/common/router/pageSetup.ts +50 -0
- package/common/router/register.ts +53 -24
- package/common/router/request/api.ts +30 -36
- package/common/router/request/index.ts +2 -8
- package/common/router/response/index.ts +8 -15
- package/common/router/response/page.ts +70 -58
- package/common/utils.ts +1 -1
- package/eslint.js +62 -0
- package/package.json +12 -45
- package/prettier.config.cjs +9 -0
- package/scripts/cleanup-generated-controllers.ts +62 -0
- package/scripts/fix-reference-app-typing.ts +490 -0
- package/scripts/refactor-client-app-imports.ts +244 -0
- package/scripts/refactor-client-pages.ts +587 -0
- package/scripts/refactor-server-controllers.ts +470 -0
- package/scripts/refactor-server-runtime-aliases.ts +360 -0
- package/scripts/restore-client-app-import-files.ts +41 -0
- package/scripts/restore-files-from-git-head.ts +20 -0
- package/scripts/update-codex-agents.ts +35 -0
- package/server/app/commands.ts +35 -64
- package/server/app/container/config.ts +39 -69
- package/server/app/container/console/index.ts +202 -248
- package/server/app/container/index.ts +33 -71
- package/server/app/controller/index.ts +61 -0
- package/server/app/index.ts +39 -105
- package/server/app/service/container.ts +41 -42
- package/server/app/service/index.ts +120 -147
- package/server/context.ts +1 -1
- package/server/index.ts +25 -1
- package/server/services/auth/index.ts +75 -115
- package/server/services/auth/router/index.ts +31 -32
- package/server/services/auth/router/request.ts +14 -16
- package/server/services/cron/CronTask.ts +13 -26
- package/server/services/cron/index.ts +14 -36
- package/server/services/disks/driver.ts +40 -58
- package/server/services/disks/drivers/local/index.ts +79 -90
- package/server/services/disks/drivers/s3/index.ts +116 -163
- package/server/services/disks/index.ts +23 -38
- package/server/services/email/index.ts +45 -104
- package/server/services/email/utils.ts +14 -27
- package/server/services/fetch/index.ts +53 -85
- package/server/services/prisma/Facet.ts +39 -91
- package/server/services/prisma/index.ts +74 -110
- package/server/services/router/generatedRuntime.ts +29 -0
- package/server/services/router/http/index.ts +77 -72
- package/server/services/router/http/multipart.ts +19 -42
- package/server/services/router/index.ts +378 -365
- package/server/services/router/request/api.ts +26 -25
- package/server/services/router/request/index.ts +44 -51
- package/server/services/router/request/service.ts +7 -11
- package/server/services/router/request/validation/zod.ts +111 -148
- package/server/services/router/response/index.ts +110 -125
- package/server/services/router/response/mask/Filter.ts +31 -72
- package/server/services/router/response/mask/index.ts +8 -15
- package/server/services/router/response/mask/selecteurs.ts +11 -25
- package/server/services/router/response/page/clientManifest.ts +25 -0
- package/server/services/router/response/page/document.tsx +199 -127
- package/server/services/router/response/page/index.tsx +89 -94
- package/server/services/router/service.ts +13 -15
- package/server/services/schema/index.ts +17 -26
- package/server/services/schema/request.ts +19 -33
- package/server/services/schema/router/index.ts +8 -11
- package/server/services/security/encrypt/aes/index.ts +15 -35
- package/server/utils/slug.ts +29 -32
- package/skills/clean-project-code/SKILL.md +63 -0
- package/skills/clean-project-code/agents/openai.yaml +4 -0
- package/tsconfig.common.json +4 -3
- package/tsconfig.json +4 -1
- package/types/aliases.d.ts +17 -21
- package/types/controller-input.test.ts +48 -0
- package/types/express-extra.d.ts +6 -0
- package/types/global/constants.d.ts +1 -0
- package/types/global/express-extra.d.ts +6 -0
- package/types/global/modules.d.ts +13 -16
- package/types/global/utils.d.ts +17 -49
- package/types/global/vendors.d.ts +62 -0
- package/types/icons.d.ts +65 -1
- package/types/uuid.d.ts +3 -0
- package/types/vendors.d.ts +62 -0
- package/cli/compiler/common/babel/index.ts +0 -173
- package/cli/compiler/common/babel/plugins/index.ts +0 -0
- package/cli/compiler/common/babel/plugins/services.ts +0 -586
- package/cli/compiler/common/babel/routes/imports.ts +0 -127
- package/cli/compiler/common/babel/routes/routes.ts +0 -1170
- package/client/services/captcha/index.ts +0 -67
- package/client/services/socket/index.ts +0 -147
- package/common/data/rte/nodes.ts +0 -83
- package/common/data/stats.ts +0 -90
- package/common/utils/rte.ts +0 -183
- package/server/services/auth/old.ts +0 -277
- package/server/services/cache/commands.ts +0 -41
- package/server/services/cache/index.ts +0 -297
- package/server/services/cache/service.json +0 -6
- package/server/services/socket/index.ts +0 -162
- package/server/services/socket/scope.ts +0 -226
- package/server/services/socket/service.json +0 -6
- package/server/services_old/SocketClient.ts +0 -92
- package/server/services_old/Token.old.ts +0 -97
|
@@ -1,69 +1,99 @@
|
|
|
1
1
|
// Npm
|
|
2
|
+
import { createHash } from 'crypto';
|
|
3
|
+
import path from 'path';
|
|
2
4
|
import favicons from 'favicons';
|
|
3
5
|
import fs from 'fs-extra';
|
|
4
6
|
|
|
5
7
|
// Type
|
|
6
|
-
import type App from '../../app';
|
|
8
|
+
import type { App } from '../../app';
|
|
7
9
|
|
|
8
|
-
export default async (
|
|
10
|
+
export default async (app: App, outputDir: string, enabled: boolean = true) => {
|
|
11
|
+
if (!enabled) return;
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
const logoPath = path.join(app.paths.root, 'client', 'assets', 'identity', 'logo.svg');
|
|
14
|
+
const metadataPath = path.join(outputDir, '.proteum-identity-assets.json');
|
|
15
|
+
const options = createIdentityAssetsOptions(app);
|
|
16
|
+
const cacheKey = createHash('sha1').update(fs.readFileSync(logoPath)).update(JSON.stringify(options)).digest('hex');
|
|
17
|
+
|
|
18
|
+
const currentMetadata = readIdentityAssetsMetadata(metadataPath);
|
|
19
|
+
if (
|
|
20
|
+
currentMetadata?.cacheKey === cacheKey &&
|
|
21
|
+
currentMetadata.files.length > 0 &&
|
|
22
|
+
currentMetadata.files.every((file) => fs.existsSync(path.join(outputDir, file)))
|
|
23
|
+
)
|
|
11
24
|
return;
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
console.info(`Generating identity assets ...`);
|
|
27
|
+
fs.emptyDirSync(outputDir);
|
|
14
28
|
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
const response = await favicons(logoPath, options);
|
|
30
|
+
const generatedFiles = [...response.images.map((image) => image.name), ...response.files.map((file) => file.name)];
|
|
17
31
|
|
|
18
|
-
|
|
32
|
+
await Promise.all([
|
|
33
|
+
// Enregistrement images
|
|
34
|
+
...response.images.map((image) => {
|
|
35
|
+
let destimg = outputDir + '/' + image.name;
|
|
36
|
+
return fs.writeFile(destimg, image.contents);
|
|
37
|
+
}),
|
|
19
38
|
|
|
20
|
-
|
|
39
|
+
// Enregistrement fichiers
|
|
40
|
+
...response.files.map((fichier) => {
|
|
41
|
+
let destfichier = outputDir + '/' + fichier.name;
|
|
42
|
+
return fs.writeFile(destfichier, fichier.contents);
|
|
43
|
+
}),
|
|
21
44
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
appDescription: identity.description,
|
|
26
|
-
developerName: identity.author.name,
|
|
27
|
-
developerURL: identity.author.url,
|
|
28
|
-
dir: "auto",
|
|
29
|
-
lang: identity.language,
|
|
30
|
-
background: "#fff",
|
|
31
|
-
theme_color: identity.maincolor,
|
|
32
|
-
appleStatusBarStyle: "default",
|
|
33
|
-
display: "standalone",
|
|
34
|
-
orientation: "any",
|
|
35
|
-
//scope: "/",
|
|
36
|
-
start_url: "/",
|
|
37
|
-
version: identity.web.version,
|
|
38
|
-
logging: false,
|
|
39
|
-
pixel_art: false,
|
|
40
|
-
icons: {
|
|
41
|
-
android: true,
|
|
42
|
-
appleIcon: true,
|
|
43
|
-
appleStartup: false,
|
|
44
|
-
coast: false,
|
|
45
|
-
favicons: true,
|
|
46
|
-
windows: true,
|
|
47
|
-
yandex: false
|
|
48
|
-
}
|
|
45
|
+
fs.writeJSON(metadataPath, { cacheKey, files: generatedFiles }, { spaces: 2 }),
|
|
46
|
+
]);
|
|
47
|
+
};
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
function createIdentityAssetsOptions(app: App) {
|
|
50
|
+
const identity = app.identity;
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
return {
|
|
53
|
+
path: '/assets/img/identite/favicons/',
|
|
54
|
+
appName: identity.name,
|
|
55
|
+
appShortName: identity.name,
|
|
56
|
+
appDescription: identity.description,
|
|
57
|
+
developerName: identity.author.name,
|
|
58
|
+
developerURL: identity.author.url,
|
|
59
|
+
dir: 'auto',
|
|
60
|
+
lang: identity.language,
|
|
61
|
+
background: '#fff',
|
|
62
|
+
theme_color: identity.maincolor,
|
|
63
|
+
appleStatusBarStyle: 'default',
|
|
64
|
+
display: 'standalone',
|
|
65
|
+
orientation: 'any',
|
|
66
|
+
start_url: '/',
|
|
67
|
+
version: identity.web.version,
|
|
68
|
+
logging: false,
|
|
69
|
+
pixel_art: false,
|
|
70
|
+
icons: {
|
|
71
|
+
android: true,
|
|
72
|
+
appleIcon: true,
|
|
73
|
+
appleStartup: false,
|
|
74
|
+
coast: false,
|
|
75
|
+
favicons: true,
|
|
76
|
+
windows: true,
|
|
77
|
+
yandex: false,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
53
81
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
let destimg = outputDir + '/' + image.name;
|
|
57
|
-
return fs.writeFile(destimg, image.contents);
|
|
58
|
-
}),
|
|
82
|
+
function readIdentityAssetsMetadata(metadataPath: string): null | { cacheKey: string; files: string[] } {
|
|
83
|
+
if (!fs.existsSync(metadataPath)) return null;
|
|
59
84
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
85
|
+
try {
|
|
86
|
+
const metadata = fs.readJSONSync(metadataPath);
|
|
87
|
+
if (
|
|
88
|
+
!metadata ||
|
|
89
|
+
typeof metadata.cacheKey !== 'string' ||
|
|
90
|
+
!Array.isArray(metadata.files) ||
|
|
91
|
+
!metadata.files.every((file: unknown) => typeof file === 'string')
|
|
92
|
+
)
|
|
93
|
+
return null;
|
|
65
94
|
|
|
66
|
-
|
|
95
|
+
return metadata;
|
|
96
|
+
} catch {
|
|
97
|
+
return null;
|
|
67
98
|
}
|
|
68
|
-
|
|
69
99
|
}
|
|
@@ -3,27 +3,15 @@
|
|
|
3
3
|
----------------------------------*/
|
|
4
4
|
|
|
5
5
|
// Npm
|
|
6
|
-
import webpack from 'webpack';
|
|
7
|
-
import fs from 'fs-extra';
|
|
8
6
|
import path from 'path';
|
|
7
|
+
import { rspack, type Configuration, type Module } from '@rspack/core';
|
|
9
8
|
|
|
10
9
|
// Plugins
|
|
11
|
-
const TerserPlugin = require('terser-webpack-plugin');
|
|
12
|
-
// Optimisations
|
|
13
|
-
const BrotliCompression = require("brotli-webpack-plugin");
|
|
14
|
-
import CompressionPlugin from "compression-webpack-plugin";
|
|
15
|
-
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
|
|
16
|
-
const imageminWebp = require('imagemin-webp');
|
|
17
|
-
const { extendDefaultPlugins } = require("svgo");
|
|
18
|
-
// Ressources
|
|
19
|
-
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
20
|
-
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
21
|
-
import WebpackAssetsManifest from 'webpack-assets-manifest';
|
|
22
|
-
// Dev
|
|
23
|
-
import PreactRefreshPlugin from '@prefresh/webpack';
|
|
24
10
|
|
|
25
11
|
// Core
|
|
26
12
|
import createCommonConfig, { TCompileMode, TCompileOutputTarget, regex } from '../common';
|
|
13
|
+
import { createClientBundleAnalysisPlugins } from '../common/bundleAnalysis';
|
|
14
|
+
import { toRspackAliases } from '../common/rspackAliases';
|
|
27
15
|
import identityAssets from './identite';
|
|
28
16
|
import cli from '../..';
|
|
29
17
|
|
|
@@ -31,6 +19,32 @@ import cli from '../..';
|
|
|
31
19
|
import type { App } from '../../app';
|
|
32
20
|
|
|
33
21
|
const debug = false;
|
|
22
|
+
const ssrScriptPattern = /\.ssr\.(ts|tsx)$/;
|
|
23
|
+
const normalizedCoreRoot = cli.paths.core.root.replace(/\\/g, '/');
|
|
24
|
+
const hmrClientEntry = path.join(cli.paths.core.root, 'client', 'dev', 'hmr.ts');
|
|
25
|
+
|
|
26
|
+
const normalizeModulePath = (value?: string) => (value || '').replace(/\\/g, '/');
|
|
27
|
+
const resolveFromAppOrCore = (app: App, request: string) =>
|
|
28
|
+
require.resolve(request, { paths: [app.paths.root, cli.paths.core.root] });
|
|
29
|
+
|
|
30
|
+
const getModulePath = (module: Module) => {
|
|
31
|
+
const resource = typeof module.nameForCondition === 'function' ? module.nameForCondition() : undefined;
|
|
32
|
+
const fallbackModule = module as Module & { resource?: string; context?: string };
|
|
33
|
+
|
|
34
|
+
return normalizeModulePath(resource || fallbackModule.resource || fallbackModule.context);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const isExternalVendorModule = (module: Module) => {
|
|
38
|
+
const modulePath = getModulePath(module);
|
|
39
|
+
|
|
40
|
+
return modulePath.includes('/node_modules/') && !modulePath.includes('/node_modules/proteum/');
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const isCoreSourceModule = (module: Module) => {
|
|
44
|
+
const modulePath = getModulePath(module);
|
|
45
|
+
|
|
46
|
+
return modulePath.startsWith(normalizedCoreRoot + '/') || modulePath.includes('/node_modules/proteum/');
|
|
47
|
+
};
|
|
34
48
|
|
|
35
49
|
/*----------------------------------
|
|
36
50
|
- CONFIG
|
|
@@ -38,18 +52,15 @@ const debug = false;
|
|
|
38
52
|
export default function createCompiler(
|
|
39
53
|
app: App,
|
|
40
54
|
mode: TCompileMode,
|
|
41
|
-
outputTarget: TCompileOutputTarget = mode === 'dev' ? 'dev' : 'bin'
|
|
42
|
-
):
|
|
43
|
-
|
|
55
|
+
outputTarget: TCompileOutputTarget = mode === 'dev' ? 'dev' : 'bin',
|
|
56
|
+
): Configuration {
|
|
44
57
|
console.info(`Creating compiler for client (${mode}).`);
|
|
45
58
|
const dev = mode === 'dev';
|
|
46
|
-
const buildDev = dev && outputTarget === 'bin';
|
|
47
59
|
const outputPath = app.outputPath(outputTarget);
|
|
48
60
|
|
|
49
61
|
const commonConfig = createCommonConfig(app, 'client', mode, outputTarget);
|
|
50
62
|
|
|
51
|
-
|
|
52
|
-
identityAssets(app, path.join(outputPath, 'public', 'app'), !buildDev);
|
|
63
|
+
identityAssets(app, path.join(outputPath, 'public', 'app'));
|
|
53
64
|
|
|
54
65
|
// Symlinks to public
|
|
55
66
|
/*const publicDirs = fs.readdirSync(app.paths.root + '/public');
|
|
@@ -59,53 +70,57 @@ export default function createCompiler(
|
|
|
59
70
|
app.paths.public + '/' + publicDir
|
|
60
71
|
);*/
|
|
61
72
|
|
|
62
|
-
// Convert tsconfig
|
|
63
|
-
const { aliases } = app.aliases.client.forWebpack({
|
|
64
|
-
modulesPath: app.paths.root + '/node_modules'
|
|
65
|
-
});
|
|
73
|
+
// Convert tsconfig paths into bundler aliases.
|
|
74
|
+
const { aliases } = app.aliases.client.forWebpack({ modulesPath: app.paths.root + '/node_modules' });
|
|
66
75
|
|
|
67
76
|
// We're not supposed in any case to import server libs from client
|
|
68
|
-
delete aliases[
|
|
69
|
-
delete aliases[
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
delete aliases['@server'];
|
|
78
|
+
delete aliases['@/server'];
|
|
79
|
+
const rspackAliases = toRspackAliases(aliases);
|
|
80
|
+
rspackAliases['@/client/router$'] = cli.paths.core.root + '/client/router.ts';
|
|
81
|
+
rspackAliases['preact/jsx-runtime$'] = resolveFromAppOrCore(app, 'preact/jsx-runtime');
|
|
82
|
+
rspackAliases['react/jsx-runtime$'] = resolveFromAppOrCore(app, 'preact/jsx-runtime');
|
|
83
|
+
rspackAliases['react/jsx-dev-runtime$'] = resolveFromAppOrCore(app, 'preact/jsx-dev-runtime');
|
|
84
|
+
|
|
85
|
+
debug && console.log('client aliases', rspackAliases);
|
|
86
|
+
const config: Configuration = {
|
|
74
87
|
...commonConfig,
|
|
75
88
|
|
|
76
89
|
name: 'client',
|
|
77
90
|
target: 'web',
|
|
78
91
|
entry: {
|
|
79
|
-
client:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// https://github.com/webpack-contrib/webpack-hot-middleware#config
|
|
83
|
-
cli.paths.core.root + '/node_modules' + '/webpack-hot-middleware/client?name=client&reload=true',
|
|
84
|
-
] : []),*/
|
|
85
|
-
cli.paths.core.root + '/client/index.ts'
|
|
86
|
-
]
|
|
92
|
+
client: dev
|
|
93
|
+
? [hmrClientEntry, cli.paths.core.root + '/client/index.ts']
|
|
94
|
+
: [cli.paths.core.root + '/client/index.ts'],
|
|
87
95
|
},
|
|
88
96
|
|
|
89
97
|
output: {
|
|
90
|
-
|
|
91
98
|
pathinfo: dev,
|
|
92
99
|
path: outputPath + '/public',
|
|
93
100
|
filename: '[name].js', // Output client.js
|
|
94
101
|
assetModuleFilename: '[hash][ext]',
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
:
|
|
102
|
+
environment: {
|
|
103
|
+
arrowFunction: true,
|
|
104
|
+
asyncFunction: true,
|
|
105
|
+
bigIntLiteral: true,
|
|
106
|
+
const: true,
|
|
107
|
+
destructuring: true,
|
|
108
|
+
dynamicImport: true,
|
|
109
|
+
forOf: true,
|
|
110
|
+
optionalChaining: true,
|
|
111
|
+
templateLiteral: true,
|
|
112
|
+
},
|
|
113
|
+
cssFilename: '[name].css',
|
|
114
|
+
cssChunkFilename: '[name].css',
|
|
115
|
+
chunkFilename: dev ? '[name].js' : '[id].[contenthash:8].js',
|
|
99
116
|
},
|
|
100
117
|
|
|
101
118
|
resolve: {
|
|
102
|
-
|
|
103
119
|
...commonConfig.resolve,
|
|
104
120
|
|
|
105
|
-
alias:
|
|
121
|
+
alias: rspackAliases,
|
|
106
122
|
|
|
107
|
-
|
|
108
|
-
extensions: [".mjs", '.ts', '.tsx', ".jsx", ".js", ".json", ".sql"],
|
|
123
|
+
extensions: ['.mjs', '.ts', '.tsx', '.jsx', '.js', '.json', '.sql'],
|
|
109
124
|
},
|
|
110
125
|
|
|
111
126
|
module: {
|
|
@@ -114,9 +129,29 @@ export default function createCompiler(
|
|
|
114
129
|
|
|
115
130
|
rules: [
|
|
116
131
|
{
|
|
117
|
-
test:
|
|
132
|
+
test: ssrScriptPattern,
|
|
118
133
|
include: [
|
|
134
|
+
app.paths.root + '/client',
|
|
135
|
+
cli.paths.core.root + '/client',
|
|
136
|
+
|
|
137
|
+
app.paths.root + '/common',
|
|
138
|
+
cli.paths.core.root + '/common',
|
|
119
139
|
|
|
140
|
+
app.paths.root + '/server',
|
|
141
|
+
cli.paths.core.root + '/server',
|
|
142
|
+
],
|
|
143
|
+
loader: path.join(
|
|
144
|
+
cli.paths.core.root,
|
|
145
|
+
'cli',
|
|
146
|
+
'compiler',
|
|
147
|
+
'common',
|
|
148
|
+
'loaders',
|
|
149
|
+
'forbid-ssr-import.js',
|
|
150
|
+
),
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
test: regex.scripts,
|
|
154
|
+
include: [
|
|
120
155
|
app.paths.root + '/client',
|
|
121
156
|
cli.paths.core.root + '/client',
|
|
122
157
|
|
|
@@ -124,21 +159,17 @@ export default function createCompiler(
|
|
|
124
159
|
cli.paths.core.root + '/common',
|
|
125
160
|
|
|
126
161
|
app.paths.root + '/server/.generated/models.ts',
|
|
127
|
-
|
|
128
162
|
],
|
|
129
|
-
rules: require('../common/
|
|
163
|
+
rules: require('../common/scripts')({ app, side: 'client', dev }),
|
|
130
164
|
},
|
|
131
165
|
|
|
132
166
|
// Les pages étan tà la fois compilées dans le bundle client et serveur
|
|
133
167
|
// On ne compile les ressources (css) qu'une seule fois
|
|
134
168
|
{
|
|
135
169
|
test: regex.style,
|
|
136
|
-
rules: require('../common/files/style')(app, dev, true
|
|
170
|
+
rules: require('../common/files/style')(app, dev, true),
|
|
137
171
|
|
|
138
|
-
//
|
|
139
|
-
// containing package claims to have no side effects.
|
|
140
|
-
// Remove this when webpack adds a warning or an error for this.
|
|
141
|
-
// See https://github.com/webpack/webpack/issues/6571
|
|
172
|
+
// CSS imports stay side-effectful even when a package marks itself otherwise.
|
|
142
173
|
sideEffects: true,
|
|
143
174
|
},
|
|
144
175
|
|
|
@@ -157,187 +188,74 @@ export default function createCompiler(
|
|
|
157
188
|
},
|
|
158
189
|
|
|
159
190
|
plugins: [
|
|
160
|
-
|
|
161
191
|
...(commonConfig.plugins || []),
|
|
162
192
|
|
|
163
|
-
...(
|
|
164
|
-
new MiniCssExtractPlugin({})
|
|
165
|
-
]),
|
|
166
|
-
|
|
167
|
-
...(buildDev ? [] : [
|
|
168
|
-
// Emit runtime asset manifests only for runnable builds.
|
|
169
|
-
new WebpackAssetsManifest({
|
|
170
|
-
output: outputPath + `/asset-manifest.json`,
|
|
171
|
-
publicPath: true,
|
|
172
|
-
writeToDisk: true, // Force la copie du fichier sur e disque, au lieu d'en mémoire en mode dev
|
|
173
|
-
customize: ({ key, value }) => {
|
|
174
|
-
// You can prevent adding items to the manifest by returning false.
|
|
175
|
-
if (key.toLowerCase().endsWith('.map')) return false;
|
|
176
|
-
return { key, value };
|
|
177
|
-
},
|
|
178
|
-
done: (manifest, stats) => {
|
|
179
|
-
// Write chunk-manifest.json.json
|
|
180
|
-
const chunkFileName = outputPath + `/chunk-manifest.json`;
|
|
181
|
-
try {
|
|
182
|
-
const fileFilter = file => !file.endsWith('.map');
|
|
183
|
-
const addPath = file => manifest.getPublicPath(file);
|
|
184
|
-
const chunkFiles = stats.compilation.chunkGroups.reduce((acc, c) => {
|
|
185
|
-
acc[c.name] = [
|
|
186
|
-
...(acc[c.name] || []),
|
|
187
|
-
...c.chunks.reduce(
|
|
188
|
-
(files, cc) => [
|
|
189
|
-
...files,
|
|
190
|
-
...[...cc.files].filter(fileFilter).map(addPath),
|
|
191
|
-
],
|
|
192
|
-
[],
|
|
193
|
-
),
|
|
194
|
-
];
|
|
195
|
-
return acc;
|
|
196
|
-
}, Object.create(null));
|
|
197
|
-
fs.writeFileSync(chunkFileName, JSON.stringify(chunkFiles, null, 4));
|
|
198
|
-
} catch (err) {
|
|
199
|
-
console.error(`ERROR: Cannot write ${chunkFileName}: `, err);
|
|
200
|
-
if (!dev) process.exit(1);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
})
|
|
204
|
-
]),
|
|
205
|
-
|
|
206
|
-
...(dev ? [
|
|
207
|
-
|
|
208
|
-
// HMR pour preact
|
|
209
|
-
//new PreactRefreshPlugin(),
|
|
210
|
-
|
|
211
|
-
] : [
|
|
193
|
+
...(dev ? [] : [new rspack.CssExtractRspackPlugin({})]),
|
|
212
194
|
|
|
213
|
-
|
|
214
|
-
localesToKeep: ['fr'],
|
|
215
|
-
}),*/
|
|
216
|
-
|
|
217
|
-
/*new CompressionPlugin({
|
|
218
|
-
cache: true,
|
|
219
|
-
minRatio: 0.99
|
|
220
|
-
}),
|
|
221
|
-
|
|
222
|
-
new BrotliCompression({
|
|
223
|
-
algorithm: 'gzip',
|
|
224
|
-
test: /\.js$|\.css$|\.html$/,
|
|
225
|
-
threshold: 10240,
|
|
226
|
-
minRatio: 0.8,
|
|
227
|
-
})*/
|
|
228
|
-
|
|
229
|
-
/*new webpack.HashedModuleIdsPlugin({
|
|
230
|
-
hashFunction: 'sha256',
|
|
231
|
-
hashDigest: 'hex',
|
|
232
|
-
hashDigestLength: 20,
|
|
233
|
-
}),*/
|
|
234
|
-
|
|
235
|
-
/*new PurgecssPlugin({}),*/
|
|
236
|
-
]),
|
|
195
|
+
...createClientBundleAnalysisPlugins(app, outputTarget),
|
|
237
196
|
],
|
|
238
197
|
|
|
239
|
-
//
|
|
240
|
-
|
|
241
|
-
devtool: buildDev ? false : (dev ? 'cheap-module-source-map' : 'source-map'),
|
|
198
|
+
// Use the cheapest practical client source maps in dev for faster rebuilds.
|
|
199
|
+
devtool: dev ? 'eval-cheap-module-source-map' : 'source-map',
|
|
242
200
|
/*devServer: {
|
|
243
201
|
hot: true,
|
|
244
202
|
},*/
|
|
245
203
|
|
|
246
204
|
optimization: {
|
|
247
|
-
|
|
248
205
|
// Code splitting serveur = même que client
|
|
249
206
|
// La décomposition des chunks doit toujours être la même car le rendu des pages dépend de cette organisation
|
|
250
207
|
|
|
251
|
-
|
|
208
|
+
runtimeChunk: { name: 'runtime' },
|
|
252
209
|
splitChunks: {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
210
|
+
// Keep the initial shell lean while still preserving async route isolation.
|
|
211
|
+
chunks: 'all',
|
|
212
|
+
minSize: 20_000,
|
|
213
|
+
minRemainingSize: 0,
|
|
214
|
+
maxInitialRequests: 30,
|
|
215
|
+
maxAsyncRequests: 30,
|
|
259
216
|
cacheGroups: {
|
|
260
|
-
|
|
261
|
-
test:
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
priority: -10,
|
|
217
|
+
framework: {
|
|
218
|
+
test: isCoreSourceModule,
|
|
219
|
+
chunks: 'initial',
|
|
220
|
+
name: 'framework',
|
|
221
|
+
priority: 40,
|
|
266
222
|
reuseExistingChunk: true,
|
|
223
|
+
enforce: true,
|
|
267
224
|
},
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
225
|
+
initialVendors: {
|
|
226
|
+
test: isExternalVendorModule,
|
|
227
|
+
chunks: 'initial',
|
|
228
|
+
name: 'vendors',
|
|
229
|
+
priority: 30,
|
|
271
230
|
reuseExistingChunk: true,
|
|
231
|
+
enforce: true,
|
|
272
232
|
},
|
|
273
|
-
|
|
233
|
+
asyncVendors: {
|
|
234
|
+
test: isExternalVendorModule,
|
|
235
|
+
chunks: 'async',
|
|
236
|
+
priority: 20,
|
|
237
|
+
reuseExistingChunk: true,
|
|
238
|
+
},
|
|
239
|
+
default: { minChunks: 2, priority: 10, reuseExistingChunk: true },
|
|
240
|
+
defaultVendors: false,
|
|
241
|
+
},
|
|
274
242
|
},
|
|
275
243
|
|
|
276
244
|
// Production
|
|
277
|
-
...(dev
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
// sections only apply transformations that are ecma 5 safe
|
|
290
|
-
// https://github.com/facebook/create-react-app/pull/4234
|
|
291
|
-
ecma: 8,
|
|
292
|
-
},
|
|
293
|
-
compress: {
|
|
294
|
-
ecma: 5,
|
|
295
|
-
warnings: false,
|
|
296
|
-
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
297
|
-
// https://github.com/facebook/create-react-app/issues/2376
|
|
298
|
-
// Pending further investigation:
|
|
299
|
-
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
300
|
-
comparisons: false,
|
|
301
|
-
// Disabled because of an issue with Terser breaking valid code:
|
|
302
|
-
// https://github.com/facebook/create-react-app/issues/5250
|
|
303
|
-
// Pending further investigation:
|
|
304
|
-
// https://github.com/terser-js/terser/issues/120
|
|
305
|
-
inline: 2,
|
|
306
|
-
},
|
|
307
|
-
mangle: {
|
|
308
|
-
safari10: true,
|
|
309
|
-
},
|
|
310
|
-
output: {
|
|
311
|
-
ecma: 5,
|
|
312
|
-
comments: false,
|
|
313
|
-
// Turned on because emoji and regex is not minified properly using default
|
|
314
|
-
// https://github.com/facebook/create-react-app/issues/2488
|
|
315
|
-
ascii_only: true,
|
|
316
|
-
},
|
|
317
|
-
}
|
|
318
|
-
}),
|
|
319
|
-
|
|
320
|
-
...(dev ? [] : [
|
|
321
|
-
new CssMinimizerPlugin()
|
|
322
|
-
]),
|
|
323
|
-
|
|
324
|
-
/*new ImageMinimizerPlugin({
|
|
325
|
-
// (optional) add generators; you can also just import &format=webp (see below)
|
|
326
|
-
generator: [
|
|
327
|
-
{
|
|
328
|
-
preset: "webp",
|
|
329
|
-
implementation: ImageMinimizerPlugin.imageminGenerate,
|
|
330
|
-
options: { plugins: ["imagemin-webp"] }
|
|
331
|
-
}
|
|
332
|
-
]
|
|
333
|
-
})*/
|
|
334
|
-
],
|
|
335
|
-
nodeEnv: 'production',
|
|
336
|
-
sideEffects: true,
|
|
337
|
-
}),
|
|
338
|
-
|
|
245
|
+
...(dev
|
|
246
|
+
? {}
|
|
247
|
+
: {
|
|
248
|
+
minimize: true,
|
|
249
|
+
removeAvailableModules: true,
|
|
250
|
+
minimizer: [
|
|
251
|
+
new rspack.SwcJsMinimizerRspackPlugin({}),
|
|
252
|
+
new rspack.LightningCssMinimizerRspackPlugin({}),
|
|
253
|
+
],
|
|
254
|
+
nodeEnv: 'production',
|
|
255
|
+
sideEffects: true,
|
|
256
|
+
}),
|
|
339
257
|
},
|
|
340
258
|
};
|
|
341
259
|
|
|
342
260
|
return config;
|
|
343
|
-
}
|
|
261
|
+
}
|