proteum 1.0.2 → 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 +101 -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 +13 -11
- package/cli/app/index.ts +74 -82
- package/cli/bin.js +1 -1
- package/cli/commands/build.ts +51 -14
- 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 +189 -64
- 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 +18 -0
- package/cli/commands/typecheck.ts +18 -0
- package/cli/compiler/client/identite.ts +80 -53
- package/cli/compiler/client/index.ts +139 -213
- 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 +11 -22
- package/cli/compiler/common/generatedRouteModules.ts +368 -0
- package/cli/compiler/common/index.ts +31 -65
- 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 +781 -230
- package/cli/compiler/server/index.ts +59 -75
- package/cli/compiler/writeIfChanged.ts +21 -0
- package/cli/index.ts +71 -72
- 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/doc/TODO.md +1 -1
- package/eslint.js +62 -0
- package/package.json +12 -47
- 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 +48 -59
- 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 +78 -73
- 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 -35
- 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 +13 -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 -170
- 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 -1130
- 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,72 +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
|
-
// Libs
|
|
6
|
-
import cli from '../..';
|
|
7
|
-
|
|
8
7
|
// Type
|
|
9
|
-
import type App from '../../app';
|
|
8
|
+
import type { App } from '../../app';
|
|
9
|
+
|
|
10
|
+
export default async (app: App, outputDir: string, enabled: boolean = true) => {
|
|
11
|
+
if (!enabled) return;
|
|
10
12
|
|
|
11
|
-
|
|
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');
|
|
12
17
|
|
|
13
|
-
const
|
|
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
|
+
)
|
|
24
|
+
return;
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
console.info(`Generating identity assets ...`);
|
|
27
|
+
fs.emptyDirSync(outputDir);
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
|
|
29
|
+
const response = await favicons(logoPath, options);
|
|
30
|
+
const generatedFiles = [...response.images.map((image) => image.name), ...response.files.map((file) => file.name)];
|
|
19
31
|
|
|
20
|
-
|
|
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
|
+
}),
|
|
21
38
|
|
|
22
|
-
|
|
39
|
+
// Enregistrement fichiers
|
|
40
|
+
...response.files.map((fichier) => {
|
|
41
|
+
let destfichier = outputDir + '/' + fichier.name;
|
|
42
|
+
return fs.writeFile(destfichier, fichier.contents);
|
|
43
|
+
}),
|
|
23
44
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
appDescription: identity.description,
|
|
28
|
-
developerName: identity.author.name,
|
|
29
|
-
developerURL: identity.author.url,
|
|
30
|
-
dir: "auto",
|
|
31
|
-
lang: identity.language,
|
|
32
|
-
background: "#fff",
|
|
33
|
-
theme_color: identity.maincolor,
|
|
34
|
-
appleStatusBarStyle: "default",
|
|
35
|
-
display: "standalone",
|
|
36
|
-
orientation: "any",
|
|
37
|
-
//scope: "/",
|
|
38
|
-
start_url: "/",
|
|
39
|
-
version: identity.web.version,
|
|
40
|
-
logging: false,
|
|
41
|
-
pixel_art: false,
|
|
42
|
-
icons: {
|
|
43
|
-
android: true,
|
|
44
|
-
appleIcon: true,
|
|
45
|
-
appleStartup: false,
|
|
46
|
-
coast: false,
|
|
47
|
-
favicons: true,
|
|
48
|
-
firefox: true,
|
|
49
|
-
windows: true,
|
|
50
|
-
yandex: false
|
|
51
|
-
}
|
|
45
|
+
fs.writeJSON(metadataPath, { cacheKey, files: generatedFiles }, { spaces: 2 }),
|
|
46
|
+
]);
|
|
47
|
+
};
|
|
52
48
|
|
|
53
|
-
|
|
49
|
+
function createIdentityAssetsOptions(app: App) {
|
|
50
|
+
const identity = app.identity;
|
|
54
51
|
|
|
55
|
-
|
|
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
|
+
}
|
|
56
81
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let destimg = dossierCache + '/' + image.name;
|
|
60
|
-
return fs.writeFile(destimg, image.contents);
|
|
61
|
-
}),
|
|
82
|
+
function readIdentityAssetsMetadata(metadataPath: string): null | { cacheKey: string; files: string[] } {
|
|
83
|
+
if (!fs.existsSync(metadataPath)) return null;
|
|
62
84
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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;
|
|
68
94
|
|
|
69
|
-
|
|
95
|
+
return metadata;
|
|
96
|
+
} catch {
|
|
97
|
+
return null;
|
|
70
98
|
}
|
|
71
|
-
|
|
72
99
|
}
|
|
@@ -3,26 +3,15 @@
|
|
|
3
3
|
----------------------------------*/
|
|
4
4
|
|
|
5
5
|
// Npm
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { rspack, type Configuration, type Module } from '@rspack/core';
|
|
8
8
|
|
|
9
9
|
// Plugins
|
|
10
|
-
const TerserPlugin = require('terser-webpack-plugin');
|
|
11
|
-
// Optimisations
|
|
12
|
-
const BrotliCompression = require("brotli-webpack-plugin");
|
|
13
|
-
import CompressionPlugin from "compression-webpack-plugin";
|
|
14
|
-
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
|
|
15
|
-
const imageminWebp = require('imagemin-webp');
|
|
16
|
-
const { extendDefaultPlugins } = require("svgo");
|
|
17
|
-
// Ressources
|
|
18
|
-
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
19
|
-
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
20
|
-
import WebpackAssetsManifest from 'webpack-assets-manifest';
|
|
21
|
-
// Dev
|
|
22
|
-
import PreactRefreshPlugin from '@prefresh/webpack';
|
|
23
10
|
|
|
24
11
|
// Core
|
|
25
|
-
import createCommonConfig, { TCompileMode, regex } from '../common';
|
|
12
|
+
import createCommonConfig, { TCompileMode, TCompileOutputTarget, regex } from '../common';
|
|
13
|
+
import { createClientBundleAnalysisPlugins } from '../common/bundleAnalysis';
|
|
14
|
+
import { toRspackAliases } from '../common/rspackAliases';
|
|
26
15
|
import identityAssets from './identite';
|
|
27
16
|
import cli from '../..';
|
|
28
17
|
|
|
@@ -30,19 +19,48 @@ import cli from '../..';
|
|
|
30
19
|
import type { App } from '../../app';
|
|
31
20
|
|
|
32
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
|
+
};
|
|
33
48
|
|
|
34
49
|
/*----------------------------------
|
|
35
50
|
- CONFIG
|
|
36
51
|
----------------------------------*/
|
|
37
|
-
export default function createCompiler(
|
|
38
|
-
|
|
52
|
+
export default function createCompiler(
|
|
53
|
+
app: App,
|
|
54
|
+
mode: TCompileMode,
|
|
55
|
+
outputTarget: TCompileOutputTarget = mode === 'dev' ? 'dev' : 'bin',
|
|
56
|
+
): Configuration {
|
|
39
57
|
console.info(`Creating compiler for client (${mode}).`);
|
|
40
58
|
const dev = mode === 'dev';
|
|
59
|
+
const outputPath = app.outputPath(outputTarget);
|
|
41
60
|
|
|
42
|
-
const commonConfig = createCommonConfig(app, 'client', mode);
|
|
61
|
+
const commonConfig = createCommonConfig(app, 'client', mode, outputTarget);
|
|
43
62
|
|
|
44
|
-
|
|
45
|
-
identityAssets(app);
|
|
63
|
+
identityAssets(app, path.join(outputPath, 'public', 'app'));
|
|
46
64
|
|
|
47
65
|
// Symlinks to public
|
|
48
66
|
/*const publicDirs = fs.readdirSync(app.paths.root + '/public');
|
|
@@ -52,53 +70,57 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
52
70
|
app.paths.public + '/' + publicDir
|
|
53
71
|
);*/
|
|
54
72
|
|
|
55
|
-
// Convert tsconfig
|
|
56
|
-
const { aliases } = app.aliases.client.forWebpack({
|
|
57
|
-
modulesPath: app.paths.root + '/node_modules'
|
|
58
|
-
});
|
|
73
|
+
// Convert tsconfig paths into bundler aliases.
|
|
74
|
+
const { aliases } = app.aliases.client.forWebpack({ modulesPath: app.paths.root + '/node_modules' });
|
|
59
75
|
|
|
60
76
|
// We're not supposed in any case to import server libs from client
|
|
61
|
-
delete aliases[
|
|
62
|
-
delete aliases[
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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 = {
|
|
67
87
|
...commonConfig,
|
|
68
88
|
|
|
69
89
|
name: 'client',
|
|
70
90
|
target: 'web',
|
|
71
91
|
entry: {
|
|
72
|
-
client:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// https://github.com/webpack-contrib/webpack-hot-middleware#config
|
|
76
|
-
cli.paths.core.root + '/node_modules' + '/webpack-hot-middleware/client?name=client&reload=true',
|
|
77
|
-
] : []),*/
|
|
78
|
-
cli.paths.core.root + '/client/index.ts'
|
|
79
|
-
]
|
|
92
|
+
client: dev
|
|
93
|
+
? [hmrClientEntry, cli.paths.core.root + '/client/index.ts']
|
|
94
|
+
: [cli.paths.core.root + '/client/index.ts'],
|
|
80
95
|
},
|
|
81
96
|
|
|
82
97
|
output: {
|
|
83
|
-
|
|
84
98
|
pathinfo: dev,
|
|
85
|
-
path:
|
|
99
|
+
path: outputPath + '/public',
|
|
86
100
|
filename: '[name].js', // Output client.js
|
|
87
101
|
assetModuleFilename: '[hash][ext]',
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
:
|
|
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',
|
|
92
116
|
},
|
|
93
117
|
|
|
94
118
|
resolve: {
|
|
95
|
-
|
|
96
119
|
...commonConfig.resolve,
|
|
97
120
|
|
|
98
|
-
alias:
|
|
121
|
+
alias: rspackAliases,
|
|
99
122
|
|
|
100
|
-
|
|
101
|
-
extensions: [".mjs", '.ts', '.tsx', ".jsx", ".js", ".json", ".sql"],
|
|
123
|
+
extensions: ['.mjs', '.ts', '.tsx', '.jsx', '.js', '.json', '.sql'],
|
|
102
124
|
},
|
|
103
125
|
|
|
104
126
|
module: {
|
|
@@ -107,9 +129,29 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
107
129
|
|
|
108
130
|
rules: [
|
|
109
131
|
{
|
|
110
|
-
test:
|
|
132
|
+
test: ssrScriptPattern,
|
|
111
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',
|
|
112
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: [
|
|
113
155
|
app.paths.root + '/client',
|
|
114
156
|
cli.paths.core.root + '/client',
|
|
115
157
|
|
|
@@ -117,9 +159,8 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
117
159
|
cli.paths.core.root + '/common',
|
|
118
160
|
|
|
119
161
|
app.paths.root + '/server/.generated/models.ts',
|
|
120
|
-
|
|
121
162
|
],
|
|
122
|
-
rules: require('../common/
|
|
163
|
+
rules: require('../common/scripts')({ app, side: 'client', dev }),
|
|
123
164
|
},
|
|
124
165
|
|
|
125
166
|
// Les pages étan tà la fois compilées dans le bundle client et serveur
|
|
@@ -128,10 +169,7 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
128
169
|
test: regex.style,
|
|
129
170
|
rules: require('../common/files/style')(app, dev, true),
|
|
130
171
|
|
|
131
|
-
//
|
|
132
|
-
// containing package claims to have no side effects.
|
|
133
|
-
// Remove this when webpack adds a warning or an error for this.
|
|
134
|
-
// See https://github.com/webpack/webpack/issues/6571
|
|
172
|
+
// CSS imports stay side-effectful even when a package marks itself otherwise.
|
|
135
173
|
sideEffects: true,
|
|
136
174
|
},
|
|
137
175
|
|
|
@@ -150,186 +188,74 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
150
188
|
},
|
|
151
189
|
|
|
152
190
|
plugins: [
|
|
153
|
-
|
|
154
191
|
...(commonConfig.plugins || []),
|
|
155
192
|
|
|
156
|
-
...(
|
|
157
|
-
new MiniCssExtractPlugin({})
|
|
158
|
-
]),
|
|
159
|
-
|
|
160
|
-
// Emit a file with assets cli.paths
|
|
161
|
-
// https://github.com/webdeveric/webpack-assets-manifest#options
|
|
162
|
-
new WebpackAssetsManifest({
|
|
163
|
-
output: app.paths.root + `/bin/asset-manifest.json`,
|
|
164
|
-
publicPath: true,
|
|
165
|
-
writeToDisk: true, // Force la copie du fichier sur e disque, au lieu d'en mémoire en mode dev
|
|
166
|
-
customize: ({ key, value }) => {
|
|
167
|
-
// You can prevent adding items to the manifest by returning false.
|
|
168
|
-
if (key.toLowerCase().endsWith('.map')) return false;
|
|
169
|
-
return { key, value };
|
|
170
|
-
},
|
|
171
|
-
done: (manifest, stats) => {
|
|
172
|
-
// Write chunk-manifest.json.json
|
|
173
|
-
const chunkFileName = app.paths.root + `/bin/chunk-manifest.json`;
|
|
174
|
-
try {
|
|
175
|
-
const fileFilter = file => !file.endsWith('.map');
|
|
176
|
-
const addPath = file => manifest.getPublicPath(file);
|
|
177
|
-
const chunkFiles = stats.compilation.chunkGroups.reduce((acc, c) => {
|
|
178
|
-
acc[c.name] = [
|
|
179
|
-
...(acc[c.name] || []),
|
|
180
|
-
...c.chunks.reduce(
|
|
181
|
-
(files, cc) => [
|
|
182
|
-
...files,
|
|
183
|
-
...[...cc.files].filter(fileFilter).map(addPath),
|
|
184
|
-
],
|
|
185
|
-
[],
|
|
186
|
-
),
|
|
187
|
-
];
|
|
188
|
-
return acc;
|
|
189
|
-
}, Object.create(null));
|
|
190
|
-
fs.writeFileSync(chunkFileName, JSON.stringify(chunkFiles, null, 4));
|
|
191
|
-
} catch (err) {
|
|
192
|
-
console.error(`ERROR: Cannot write ${chunkFileName}: `, err);
|
|
193
|
-
if (!dev) process.exit(1);
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
}),
|
|
197
|
-
|
|
198
|
-
...(dev ? [
|
|
199
|
-
|
|
200
|
-
// HMR pour preact
|
|
201
|
-
//new PreactRefreshPlugin(),
|
|
202
|
-
|
|
203
|
-
] : [
|
|
193
|
+
...(dev ? [] : [new rspack.CssExtractRspackPlugin({})]),
|
|
204
194
|
|
|
205
|
-
|
|
206
|
-
localesToKeep: ['fr'],
|
|
207
|
-
}),*/
|
|
208
|
-
|
|
209
|
-
/*new CompressionPlugin({
|
|
210
|
-
cache: true,
|
|
211
|
-
minRatio: 0.99
|
|
212
|
-
}),
|
|
213
|
-
|
|
214
|
-
new BrotliCompression({
|
|
215
|
-
algorithm: 'gzip',
|
|
216
|
-
test: /\.js$|\.css$|\.html$/,
|
|
217
|
-
threshold: 10240,
|
|
218
|
-
minRatio: 0.8,
|
|
219
|
-
})*/
|
|
220
|
-
|
|
221
|
-
/*new webpack.HashedModuleIdsPlugin({
|
|
222
|
-
hashFunction: 'sha256',
|
|
223
|
-
hashDigest: 'hex',
|
|
224
|
-
hashDigestLength: 20,
|
|
225
|
-
}),*/
|
|
226
|
-
|
|
227
|
-
/*new PurgecssPlugin({}),*/
|
|
228
|
-
]),
|
|
195
|
+
...createClientBundleAnalysisPlugins(app, outputTarget),
|
|
229
196
|
],
|
|
230
197
|
|
|
231
|
-
//
|
|
232
|
-
|
|
233
|
-
devtool: 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',
|
|
234
200
|
/*devServer: {
|
|
235
201
|
hot: true,
|
|
236
202
|
},*/
|
|
237
203
|
|
|
238
204
|
optimization: {
|
|
239
|
-
|
|
240
205
|
// Code splitting serveur = même que client
|
|
241
206
|
// La décomposition des chunks doit toujours être la même car le rendu des pages dépend de cette organisation
|
|
242
207
|
|
|
243
|
-
|
|
208
|
+
runtimeChunk: { name: 'runtime' },
|
|
244
209
|
splitChunks: {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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,
|
|
251
216
|
cacheGroups: {
|
|
252
|
-
|
|
253
|
-
test:
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
priority: -10,
|
|
217
|
+
framework: {
|
|
218
|
+
test: isCoreSourceModule,
|
|
219
|
+
chunks: 'initial',
|
|
220
|
+
name: 'framework',
|
|
221
|
+
priority: 40,
|
|
258
222
|
reuseExistingChunk: true,
|
|
223
|
+
enforce: true,
|
|
259
224
|
},
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
225
|
+
initialVendors: {
|
|
226
|
+
test: isExternalVendorModule,
|
|
227
|
+
chunks: 'initial',
|
|
228
|
+
name: 'vendors',
|
|
229
|
+
priority: 30,
|
|
263
230
|
reuseExistingChunk: true,
|
|
231
|
+
enforce: true,
|
|
264
232
|
},
|
|
265
|
-
|
|
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
|
+
},
|
|
266
242
|
},
|
|
267
243
|
|
|
268
244
|
// Production
|
|
269
|
-
...(dev
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
// sections only apply transformations that are ecma 5 safe
|
|
282
|
-
// https://github.com/facebook/create-react-app/pull/4234
|
|
283
|
-
ecma: 8,
|
|
284
|
-
},
|
|
285
|
-
compress: {
|
|
286
|
-
ecma: 5,
|
|
287
|
-
warnings: false,
|
|
288
|
-
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
289
|
-
// https://github.com/facebook/create-react-app/issues/2376
|
|
290
|
-
// Pending further investigation:
|
|
291
|
-
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
292
|
-
comparisons: false,
|
|
293
|
-
// Disabled because of an issue with Terser breaking valid code:
|
|
294
|
-
// https://github.com/facebook/create-react-app/issues/5250
|
|
295
|
-
// Pending further investigation:
|
|
296
|
-
// https://github.com/terser-js/terser/issues/120
|
|
297
|
-
inline: 2,
|
|
298
|
-
},
|
|
299
|
-
mangle: {
|
|
300
|
-
safari10: true,
|
|
301
|
-
},
|
|
302
|
-
output: {
|
|
303
|
-
ecma: 5,
|
|
304
|
-
comments: false,
|
|
305
|
-
// Turned on because emoji and regex is not minified properly using default
|
|
306
|
-
// https://github.com/facebook/create-react-app/issues/2488
|
|
307
|
-
ascii_only: true,
|
|
308
|
-
},
|
|
309
|
-
}
|
|
310
|
-
}),
|
|
311
|
-
|
|
312
|
-
...(dev ? [] : [
|
|
313
|
-
new CssMinimizerPlugin()
|
|
314
|
-
]),
|
|
315
|
-
|
|
316
|
-
/*new ImageMinimizerPlugin({
|
|
317
|
-
// (optional) add generators; you can also just import &format=webp (see below)
|
|
318
|
-
generator: [
|
|
319
|
-
{
|
|
320
|
-
preset: "webp",
|
|
321
|
-
implementation: ImageMinimizerPlugin.imageminGenerate,
|
|
322
|
-
options: { plugins: ["imagemin-webp"] }
|
|
323
|
-
}
|
|
324
|
-
]
|
|
325
|
-
})*/
|
|
326
|
-
],
|
|
327
|
-
nodeEnv: 'production',
|
|
328
|
-
sideEffects: true,
|
|
329
|
-
}),
|
|
330
|
-
|
|
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
|
+
}),
|
|
331
257
|
},
|
|
332
258
|
};
|
|
333
259
|
|
|
334
260
|
return config;
|
|
335
|
-
}
|
|
261
|
+
}
|