⬆ Vite 2.9

pull/2082/head
Maxime Quandalle 2022-04-03 17:40:00 +02:00 committed by Maxime Quandalle
parent dbad75b0dd
commit eb204584fe
9 changed files with 267 additions and 25 deletions

View File

@ -191,12 +191,6 @@ yarn preview:mon-entreprise
yarn preview:infrance
```
### Worker en développement
Nous utilisons [vite](https://vitejs.dev/) pour le serveur de développement et comme bundler. Aucun bundling n'est fait en développement, ce qui accélère considérablement le temps de rechargement de l'app à chaque modification. Pour cela, la syntaxe ESModule est utilisée partout, y compris dans les worker. Malheureusement, tous les navigateurs ne [supportent pas encore cette fonctionalité](https://caniuse.com/mdn-api_worker_worker_ecmascript_modules) (en particulier [Firefox](https://bugzilla.mozilla.org/show_bug.cgi?id=1247687)).
Par conséquent, les workers ne fonctionnent pas en mode développement sous firefox. Ce n'est pas critique mais il faut le savoir.
### Tests
Pour tester les règles, il est recommandé de:

View File

@ -10,6 +10,7 @@
},
"type": "module",
"private": true,
"main": "./source/entry-fr.tsx",
"engines": {
"node": ">=12.16.1"
},
@ -139,7 +140,7 @@
"ts-morph": "^13.0.3",
"ts-node": "^10.5.0",
"typescript": "^4.3.2",
"vite": "^2.8.6",
"vite": "^2.9.1",
"vite-plugin-shim-react-pdf": "^1.0.4",
"vitest": "^0.2.5",
"xml2js": "^0.4.23",

View File

@ -2,8 +2,8 @@ import ReactDOMServer from 'react-dom/server'
import { SSRProvider } from '@react-aria/ssr'
import { StaticRouter } from 'react-router-dom'
import i18next from './locales/i18n'
import { AppFr } from './entry.fr'
import { AppEn } from './entry.en'
import { AppFr } from './entry-fr'
import { AppEn } from './entry-en'
import { ServerStyleSheet, StyleSheetManager } from 'styled-components'
import { FilledContext, HelmetProvider } from 'react-helmet-async'

View File

@ -1,10 +0,0 @@
<!--
Ideally this file wouldn't be needed, but ViteJS used it when the dev server is
started to pre-bundle the dependencies and speed it the server start.
https://vitejs.dev/guide/dep-pre-bundling.html
TODO: There might be a way to do it using the plugin API, which we could use in
our custom plugin. This should be doable with
https://vitejs.dev/config/#optimizedeps-entries but I couldn't make it work.
-->
<script type="module" src="/source/entry.fr.tsx"></script>

View File

@ -189,13 +189,15 @@
document.documentElement,
...document.querySelectorAll('[data-js-color-element]'),
].forEach((element) => {
element.style.setProperty('--COLOR_HUE', iframeColor ? iframeColor[0] : '220deg')
element.style.setProperty(
'--COLOR_HUE',
iframeColor ? iframeColor[0] : '220deg'
)
element.style.setProperty(
'--COLOR_SATURATION',
iframeColor ? iframeColor[1] + '%' : '100%'
)
})
} catch (e) {
console.error(e)
}

View File

@ -71,7 +71,7 @@ export default defineConfig(({ command }) => ({
sites: {
'mon-entreprise': {
lang: 'fr',
entry: '/source/entry.fr.tsx',
entry: '/source/entry-fr.tsx',
title:
"mon-entreprise.urssaf.fr : L'assistant officiel du créateur d'entreprise",
description:
@ -80,7 +80,7 @@ export default defineConfig(({ command }) => ({
},
infrance: {
lang: 'en',
entry: '/source/entry.en.tsx',
entry: '/source/entry-en.tsx',
title:
'My company in France: A step-by-step guide to start a business in France',
description:
@ -106,6 +106,10 @@ export default defineConfig(({ command }) => ({
},
},
optimizeDeps: {
// TODO: for some reason (ViteJS bug?) we need to define a entry file in the
// "main" field of package.json. Ideally this shouldn't be required. It's
// not possible to write comments in package.json here it is.
entries: ['./source/entry-fr.tsx', './source/entry-en.tsx'],
exclude: ['publicodes-react', 'publicodes'],
// Optimize cjs deps from publicodes
include: ['publicodes > moo', 'publicodes > nearley', 'yaml'],

255
yarn.lock
View File

@ -9850,6 +9850,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-android-64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-android-64@npm:0.14.30"
conditions: os=android & cpu=x64
languageName: node
linkType: hard
"esbuild-android-arm64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-android-arm64@npm:0.13.8"
@ -9864,6 +9871,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-android-arm64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-android-arm64@npm:0.14.30"
conditions: os=android & cpu=arm64
languageName: node
linkType: hard
"esbuild-darwin-64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-darwin-64@npm:0.13.8"
@ -9878,6 +9892,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-darwin-64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-darwin-64@npm:0.14.30"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"esbuild-darwin-arm64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-darwin-arm64@npm:0.13.8"
@ -9892,6 +9913,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-darwin-arm64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-darwin-arm64@npm:0.14.30"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"esbuild-freebsd-64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-freebsd-64@npm:0.13.8"
@ -9906,6 +9934,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-freebsd-64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-freebsd-64@npm:0.14.30"
conditions: os=freebsd & cpu=x64
languageName: node
linkType: hard
"esbuild-freebsd-arm64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-freebsd-arm64@npm:0.13.8"
@ -9920,6 +9955,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-freebsd-arm64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-freebsd-arm64@npm:0.14.30"
conditions: os=freebsd & cpu=arm64
languageName: node
linkType: hard
"esbuild-linux-32@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-linux-32@npm:0.13.8"
@ -9934,6 +9976,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-32@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-linux-32@npm:0.14.30"
conditions: os=linux & cpu=ia32
languageName: node
linkType: hard
"esbuild-linux-64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-linux-64@npm:0.13.8"
@ -9948,6 +9997,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-linux-64@npm:0.14.30"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard
"esbuild-linux-arm64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-linux-arm64@npm:0.13.8"
@ -9962,6 +10018,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-arm64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-linux-arm64@npm:0.14.30"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard
"esbuild-linux-arm@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-linux-arm@npm:0.13.8"
@ -9976,6 +10039,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-arm@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-linux-arm@npm:0.14.30"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard
"esbuild-linux-mips64le@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-linux-mips64le@npm:0.13.8"
@ -9990,6 +10060,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-mips64le@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-linux-mips64le@npm:0.14.30"
conditions: os=linux & cpu=mips64el
languageName: node
linkType: hard
"esbuild-linux-ppc64le@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-linux-ppc64le@npm:0.13.8"
@ -10004,6 +10081,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-ppc64le@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-linux-ppc64le@npm:0.14.30"
conditions: os=linux & cpu=ppc64
languageName: node
linkType: hard
"esbuild-linux-riscv64@npm:0.14.24":
version: 0.14.24
resolution: "esbuild-linux-riscv64@npm:0.14.24"
@ -10011,6 +10095,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-riscv64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-linux-riscv64@npm:0.14.30"
conditions: os=linux & cpu=riscv64
languageName: node
linkType: hard
"esbuild-linux-s390x@npm:0.14.24":
version: 0.14.24
resolution: "esbuild-linux-s390x@npm:0.14.24"
@ -10018,6 +10109,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-linux-s390x@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-linux-s390x@npm:0.14.30"
conditions: os=linux & cpu=s390x
languageName: node
linkType: hard
"esbuild-netbsd-64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-netbsd-64@npm:0.13.8"
@ -10032,6 +10130,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-netbsd-64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-netbsd-64@npm:0.14.30"
conditions: os=netbsd & cpu=x64
languageName: node
linkType: hard
"esbuild-openbsd-64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-openbsd-64@npm:0.13.8"
@ -10046,6 +10151,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-openbsd-64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-openbsd-64@npm:0.14.30"
conditions: os=openbsd & cpu=x64
languageName: node
linkType: hard
"esbuild-sunos-64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-sunos-64@npm:0.13.8"
@ -10060,6 +10172,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-sunos-64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-sunos-64@npm:0.14.30"
conditions: os=sunos & cpu=x64
languageName: node
linkType: hard
"esbuild-windows-32@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-windows-32@npm:0.13.8"
@ -10074,6 +10193,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-windows-32@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-windows-32@npm:0.14.30"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard
"esbuild-windows-64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-windows-64@npm:0.13.8"
@ -10088,6 +10214,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-windows-64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-windows-64@npm:0.14.30"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"esbuild-windows-arm64@npm:0.13.8":
version: 0.13.8
resolution: "esbuild-windows-arm64@npm:0.13.8"
@ -10102,6 +10235,13 @@ __metadata:
languageName: node
linkType: hard
"esbuild-windows-arm64@npm:0.14.30":
version: 0.14.30
resolution: "esbuild-windows-arm64@npm:0.14.30"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"esbuild@npm:0.13.8":
version: 0.13.8
resolution: "esbuild@npm:0.13.8"
@ -10235,6 +10375,77 @@ __metadata:
languageName: node
linkType: hard
"esbuild@npm:^0.14.27":
version: 0.14.30
resolution: "esbuild@npm:0.14.30"
dependencies:
esbuild-android-64: 0.14.30
esbuild-android-arm64: 0.14.30
esbuild-darwin-64: 0.14.30
esbuild-darwin-arm64: 0.14.30
esbuild-freebsd-64: 0.14.30
esbuild-freebsd-arm64: 0.14.30
esbuild-linux-32: 0.14.30
esbuild-linux-64: 0.14.30
esbuild-linux-arm: 0.14.30
esbuild-linux-arm64: 0.14.30
esbuild-linux-mips64le: 0.14.30
esbuild-linux-ppc64le: 0.14.30
esbuild-linux-riscv64: 0.14.30
esbuild-linux-s390x: 0.14.30
esbuild-netbsd-64: 0.14.30
esbuild-openbsd-64: 0.14.30
esbuild-sunos-64: 0.14.30
esbuild-windows-32: 0.14.30
esbuild-windows-64: 0.14.30
esbuild-windows-arm64: 0.14.30
dependenciesMeta:
esbuild-android-64:
optional: true
esbuild-android-arm64:
optional: true
esbuild-darwin-64:
optional: true
esbuild-darwin-arm64:
optional: true
esbuild-freebsd-64:
optional: true
esbuild-freebsd-arm64:
optional: true
esbuild-linux-32:
optional: true
esbuild-linux-64:
optional: true
esbuild-linux-arm:
optional: true
esbuild-linux-arm64:
optional: true
esbuild-linux-mips64le:
optional: true
esbuild-linux-ppc64le:
optional: true
esbuild-linux-riscv64:
optional: true
esbuild-linux-s390x:
optional: true
esbuild-netbsd-64:
optional: true
esbuild-openbsd-64:
optional: true
esbuild-sunos-64:
optional: true
esbuild-windows-32:
optional: true
esbuild-windows-64:
optional: true
esbuild-windows-arm64:
optional: true
bin:
esbuild: bin/esbuild
checksum: 896e81540f9e94ff6edf65bbda70cca078f1fb6b9390c3387cc73796310a9ceae6db4ff24253099739210398efc7ed307f02daf120656f53b569bd23020b0f8b
languageName: node
linkType: hard
"escalade@npm:^3.1.1":
version: 3.1.1
resolution: "escalade@npm:3.1.1"
@ -15731,6 +15942,17 @@ __metadata:
languageName: node
linkType: hard
"postcss@npm:^8.4.12":
version: 8.4.12
resolution: "postcss@npm:8.4.12"
dependencies:
nanoid: ^3.3.1
picocolors: ^1.0.0
source-map-js: ^1.0.2
checksum: 248e3d0f9bbb8efaafcfda7f91627a29bdc9a19f456896886330beb28c5abea0e14c7901b35191928602e2eccbed496b1e94097d27a0b2a980854cd00c7a835f
languageName: node
linkType: hard
"postcss@npm:^8.4.6":
version: 8.4.7
resolution: "postcss@npm:8.4.7"
@ -17792,7 +18014,7 @@ __metadata:
ts-morph: ^13.0.3
ts-node: ^10.5.0
typescript: ^4.3.2
vite: ^2.8.6
vite: ^2.9.1
vite-plugin-shim-react-pdf: ^1.0.4
vitest: ^0.2.5
whatwg-fetch: ^3.0.0
@ -19745,7 +19967,7 @@ __metadata:
languageName: node
linkType: hard
"vite@npm:>=2.7.13, vite@npm:^2.8.6":
"vite@npm:>=2.7.13":
version: 2.8.6
resolution: "vite@npm:2.8.6"
dependencies:
@ -19774,6 +19996,35 @@ __metadata:
languageName: node
linkType: hard
"vite@npm:^2.9.1":
version: 2.9.1
resolution: "vite@npm:2.9.1"
dependencies:
esbuild: ^0.14.27
fsevents: ~2.3.2
postcss: ^8.4.12
resolve: ^1.22.0
rollup: ^2.59.0
peerDependencies:
less: "*"
sass: "*"
stylus: "*"
dependenciesMeta:
fsevents:
optional: true
peerDependenciesMeta:
less:
optional: true
sass:
optional: true
stylus:
optional: true
bin:
vite: bin/vite.js
checksum: 0f0ac9337fa5c17faa4a59831a2df17475563b23a6162e86b2b60b19835ca1277f3249ea7a6608880354b39caf05779e9bad1e3b1f5b27010deced224aae47ea
languageName: node
linkType: hard
"vitest@npm:^0.2.5":
version: 0.2.8
resolution: "vitest@npm:0.2.8"