Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prerendering #2848

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/install/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runs:
steps:
- uses: actions/setup-node@v3
with:
node-version: '21'
node-version: '18.18.2'
cache: 'yarn'
- run: yarn install --immutable
shell: bash
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ jobs:
- name: Build app SSR
run: |
yarn workspace site build:ssr
- name: Prerender common routes
run: |
yarn workspace site build:prerender --netlify-toml-path ./netlify.base.toml
- name: Replace site placeholders in netlify.toml redirection file
run: |
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
18.18
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@types/node": "^20.6.3",
"@types/swagger-ui-dist": "^3.30.1",
"chai-http": "^4.4.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"vitest": "^0.34.4",
"wait-on": "^7.0.1"
Expand Down
2 changes: 1 addition & 1 deletion api/source/test-e2e/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('e2e test mon-entreprise api', () => {
return res.text
})
).resolves.toMatchInlineSnapshot(
'"Expected property name or \'}\' in JSON at position 2 (line 1 column 3)"'
'"Unexpected token x in JSON at position 2"'
)
})
})
3 changes: 3 additions & 0 deletions api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
// remove this when vite support "NodeNext" : https://github.com/vitejs/vite/issues/10481 or https://github.com/vitejs/vite/issues/8993
"skipLibCheck": true
},
"ts-node": {
"esm": true
},
"include": ["source"],
"exclude": ["**/dist", "vitest.config.ts"]
}
1 change: 1 addition & 0 deletions modele-social/règles/entreprise/imposition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ entreprise . imposition . IS:

entreprise . imposition . IS . montant:
unité: €/an
applicable si: prorata temporis > 0
barème:
assiette: résultat imposable
multiplicateur: prorata temporis
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@
},
"packageManager": "[email protected]",
"engines": {
"node": "^21"
"node": "^18"
}
}
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@types/koa__router": "^12.0.1",
"@types/node": "^20.6.3",
"@types/safe-timers": "^1.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"engines": {
Expand Down
5 changes: 4 additions & 1 deletion server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
/* Advanced Options */
"forceConsistentCasingInFileNames": true
},

"ts-node": {
"esm": true,
"files": true
},
"include": ["source", "types/**/*.d.ts"],
"exclude": ["**/node_modules", "**/dist", "vitest.config.ts"]
}
2 changes: 1 addition & 1 deletion site/build/build-sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { writeFileSync } from 'node:fs'

import { absoluteSitePaths, generateSiteMap } from '../source/sitePaths.ts'
import { absoluteSitePaths, generateSiteMap } from '../source/sitePaths.js'

const basePathEn =
process.env.VITE_EN_BASE_URL ?? 'http://localhost:3000/infrance'
Expand Down
2 changes: 1 addition & 1 deletion site/build/prerender-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { fileURLToPath } from 'url'

// @ts-ignore
import { render } from '../dist/ssr/entry-server'
import { render } from '../dist/ssr/entry-server.js'

const dirname = path.dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -31,7 +31,7 @@
cache[site] ??= template

// TODO: Add CI test to enforce meta tags on SSR pages
const { html, styleTags, helmet } = (await render(url, lang)) as {

Check warning on line 34 in site/build/prerender-worker.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe call of an `any` typed value
html: string
styleTags: string
helmet?: { title: string; meta: string }
Expand Down
4 changes: 1 addition & 3 deletions site/build/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import { absoluteSitePaths } from '../source/sitePaths.js'
const filename = new URL('./prerender-worker.ts', import.meta.url).href
const pool = new Tinypool({
filename,
execArgv: ['--import', 'tsx/esm'],
execArgv: ['--loader', 'ts-node/esm'],
idleTimeout: 2000,
runtime: 'child_process',
})

const sitePathFr = absoluteSitePaths.fr
Expand Down Expand Up @@ -67,7 +66,6 @@ const redirects = await Promise.all(
urls.map(async (url) => {
const path = await (pool.run({
site,

url,
lang: site === 'mon-entreprise' ? 'fr' : 'en',
}) as Promise<string>)
Expand Down
15 changes: 9 additions & 6 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"start:netlify": "sed 's|:SITE_EN|/infrance|g' netlify.base.toml | sed 's|:SITE_FR|/mon-entreprise|g' | sed 's|:API_URL|http://localhost:3004|g' | sed 's|\\[\\[redirects\\]\\]|\\[\\[redirects\\]\\]\\n force = true|g' > netlify.toml && HMR_CLIENT_PORT=8888 netlify dev",
"build:iframe-script": "NODE_OPTIONS='--max-old-space-size=4096'; vite build --config build/vite-iframe-script.config.ts",
"build:simulator-data": "vite build --config build/vite-build-simulation-data.config.ts",
"build:prerender": "tsx build/prerender.ts",
"build:sitemap": "tsx build/build-sitemap.ts",
"build:prerender": "ts-node-esm build/prerender.ts",
"build:sitemap": "ts-node-esm build/build-sitemap.ts",
"build:ssr": "NODE_OPTIONS='--max-old-space-size=4096'; vite build --ssr ./source/entries/entry-server.tsx --outDir ./dist/ssr --emptyOutDir && echo '{\"type\": \"module\"}' > dist/package.json",
"build:yaml-to-dts": "tsx build/build-yaml-to-dts.ts",
"build:yaml-to-dts": "ts-node-esm build/build-yaml-to-dts.ts",
"algolia:clean": "node scripts/search/clean.js",
"algolia:update": "yarn build:simulator-data && tsx ./scripts/search/update-data.ts",
"algolia:update": "yarn build:simulator-data && ts-node-esm ./scripts/search/update-data.ts",
"i18n:rules:check": "node scripts/i18n/check-missing-rule-translation.js",
"i18n:rules:translate": "node scripts/i18n/translate-rules.js",
"i18n:ui:check": "i18next -c scripts/i18n/parser.config.js && node scripts/i18n/check-missing-UI-translation.js",
Expand Down Expand Up @@ -93,6 +93,7 @@
"redux": "^4.2.1",
"reselect": "^4.1.8",
"styled-components": "^6.0.8",
"stylis": "^4.3.0",
"whatwg-fetch": "^3.6.19"
},
"devDependencies": {
Expand Down Expand Up @@ -127,18 +128,20 @@
"cypress-wait-until": "^1.7.2",
"dotenv": "^16.3.1",
"i18next-parser": "^8.7.0",
"netlify-cli": "^17.10.1",
"serve-static": "^1.15.0",
"storybook": "^7.4.3",
"tinypool": "^0.8.1",
"tsx": "^4.6.2",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vite-plugin-pwa": "^0.16.5",
"vitest": "^0.34.4",
"workbox-expiration": "^7.0.0",
"workbox-navigation-preload": "^7.0.0",
"workbox-precaching": "^7.0.0",
"workbox-routing": "^7.0.0",
"workbox-strategies": "^7.0.0",
"workbox-window": "^7.0.0",
"xml2js": "^0.4.23",
"yaml": "^2.3.2"
}
Expand Down
10 changes: 5 additions & 5 deletions site/scripts/NAFAndGuichetData/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
"node": "^18"
},
"scripts": {
"extract-NAF-from-PDF": "tsx ./extract-NAF-data/convert-pdf.ts",
"extract-guichet": "tsx ./NomenclatureGuichet/extract.ts",
"fetch-nombre-etablissements": "tsx ./nombre-etablissements-par-code-ape/fetch-json.ts",
"merge-data": "tsx ./NAF-search/merge-data.ts",
"extract-NAF-from-PDF": "ts-node-esm ./extract-NAF-data/convert-pdf.ts",
"extract-guichet": "ts-node-esm ./NomenclatureGuichet/extract.ts",
"fetch-nombre-etablissements": "ts-node-esm ./nombre-etablissements-par-code-ape/fetch-json.ts",
"merge-data": "ts-node-esm ./NAF-search/merge-data.ts",
"build": "yarn extract-NAF-from-PDF && yarn extract-guichet && yarn fetch-nombre-etablissements && yarn merge-data"
},
"devDependencies": {
"csv": "^6.2.7",
"csv-parser": "^3.0.0",
"pdfdataextract": "^3.2.0",
"tsx": "^4.6.2"
"ts-node": "^10.9.1"
}
}
5 changes: 3 additions & 2 deletions site/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"allowJs": true,
"allowImportingTsExtensions": true,
"isolatedModules": true,
"paths": {
"@/*": ["*"]
Expand All @@ -26,7 +25,9 @@
"noEmit": true,
"strict": true
},

"ts-node": {
"transpileOnly": true
},
"include": [
"source",
"scripts",
Expand Down
Loading
Loading