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(polyfills): ajout du replaceAll de manière globale #6311

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 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
4 changes: 2 additions & 2 deletions packages/code-du-travail-frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ scripts/logs/*
.env.*

## Panda
styled-system
styled-system-studio
src/styled-system
src/styled-system-studio
Empty file.
3 changes: 1 addition & 2 deletions packages/code-du-travail-frontend/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import "./globals.css";
import "../src/lib/polyfills";
import { Metadata } from "next/types";
import { SITE_URL } from "../src/config";
import { headers } from "next/headers";
import DefaultLayout from "../src/modules/config/DefaultLayout";
import { PolyfillComponent } from "../src/modules/utils";

export const metadata: Metadata = {
title: {
Expand Down Expand Up @@ -32,7 +32,6 @@ export default function RootLayout({
nonce={nonce}
defaultColorScheme={pathname.includes("/widgets") ? "light" : "system"}
>
<PolyfillComponent />
{children}
</DefaultLayout>
);
Expand Down
10 changes: 4 additions & 6 deletions packages/code-du-travail-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"lint": "yarn lint:css && next lint",
"precommit": "lint-staged",
"start": "next start",
"prebuild": "node -r @swc-node/register scripts/prebuild.ts && react-dsfr update-icons && panda codegen",
"prebuild": "tsup scripts/prebuild.ts && react-dsfr update-icons && panda codegen",
"build": "yarn prebuild && next build",
"build:analyze": "yarn prebuild && ANALYZE=true next build",
"pretest:api": "ELASTICSEARCH_URL=http://localhost:9200 NEXT_PUBLIC_ES_INDEX_PREFIX=cdtn_test NEXT_PUBLIC_APP_ENV=test NODE_ENV=test node -r @swc-node/register scripts/generate-data.ts",
"pretest:api": "ELASTICSEARCH_URL=http://localhost:9200 NEXT_PUBLIC_ES_INDEX_PREFIX=cdtn_test NEXT_PUBLIC_APP_ENV=test NODE_ENV=test tsup scripts/generate-data.ts",
"test": "yarn pretest:api && ELASTICSEARCH_URL=http://localhost:9200 NEXT_PUBLIC_ES_INDEX_PREFIX=cdtn_test NEXT_PUBLIC_APP_ENV=test NODE_ENV=test jest --silent",
"test:watch": "npm run test -- --watch",
"test:frontend": "NEXT_PUBLIC_APP_ENV=test NODE_ENV=test jest --silent --testPathIgnorePatterns='.*\\.es\\.test\\.ts$'",
Expand All @@ -31,7 +31,7 @@
"type-check:watch": "npm run type-check -- --watch",
"format": "prettier --write \"**/*.{js,ts,tsx,jsx,json,md}\"",
"format:check": "prettier --check \"**/*.{js,ts,tsx,jsx,json,md}\"",
"clean:redirects": "node -r @swc-node/register scripts/clean-redirects.ts"
"clean:redirects": "tsup scripts/clean-redirects.ts"
},
"dependencies": {
"@codegouvfr/react-dsfr": "^1.13.9",
Expand All @@ -50,7 +50,6 @@
"@socialgouv/matomo-next": "^1.6.1",
"@socialgouv/modeles-social": "workspace:^",
"@socialgouv/reference-article": "^1.0.1",
"core-js": "^3.39.0",
"cors": "^2.8.5",
"date-fns": "^2.22.1",
"debounce-promise": "^3.1.2",
Expand Down Expand Up @@ -87,8 +86,6 @@
},
"devDependencies": {
"@pandacss/dev": "^0.45.2",
"@swc-node/register": "^1.6.5",
"@swc/core": "^1.3.60",
"@testing-library/cypress": "^10.0.2",
"@testing-library/dom": "^8.11.3",
"@testing-library/jest-dom": "^5.16.5",
Expand Down Expand Up @@ -121,6 +118,7 @@
"stylelint-processor-styled-components": "^1.10.0",
"supertest": "^6.3.3",
"testing-library-selector": "0.3.1",
"tsup": "^8.3.5",
"typescript": "^5.5.4",
"xml2js": "^0.6.2"
}
Expand Down
3 changes: 2 additions & 1 deletion packages/code-du-travail-frontend/panda.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default defineConfig({
},
},
},
outdir: "styled-system",
outdir: "src/styled-system",
outExtension: "js",
importMap: "@styled-system",
});
8 changes: 8 additions & 0 deletions packages/code-du-travail-frontend/src/lib/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if (!("replaceAll" in String.prototype)) {
(String.prototype as any).replaceAll = function (
searchValue: string,
replaceValue: string
) {
return this.split(searchValue).join(replaceValue);
};
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import parse, { domToReact } from "html-react-parser";
import { ReactHTMLElement } from "react";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on ne s'en servait pas


export const ContentParser = ({
children,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import { fr } from "@codegouvfr/react-dsfr";
import { css } from "@styled-system/css";
import React from "react";
import { css } from "../../../styled-system/css";

export const ListWithArrow = ({ items }: { items: JSX.Element[] }) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Button from "@codegouvfr/react-dsfr/Button";
import { usePathname } from "next/navigation";
import { SITE_URL } from "../../config";
import { fr } from "@codegouvfr/react-dsfr";
import { css } from "../../../styled-system/css";
import { css } from "@styled-system/css";
import { useCommonTracking } from "./tracking";

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fr } from "@codegouvfr/react-dsfr";
import Link from "next/link";
import { css } from "../../../styled-system/css";
import { css } from "@styled-system/css";

type Props = {
letters: string[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fr } from "@codegouvfr/react-dsfr";
import Link from "next/link";
import { css } from "../../../styled-system/css";
import { css } from "@styled-system/css";
import Image from "next/image";
import { Highlight } from "@codegouvfr/react-dsfr/Highlight";
import AgreementSearch from "./AgreementSearch.svg";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fr } from "@codegouvfr/react-dsfr";
import { css } from "../../../../styled-system/css";
import { css } from "@styled-system/css";
import { Button } from "@codegouvfr/react-dsfr/Button";

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from "react";
import * as Sentry from "@sentry/nextjs";
import { fr } from "@codegouvfr/react-dsfr";
import { Button } from "@codegouvfr/react-dsfr/Button";
import { css } from "../../../../styled-system/css";
import { css } from "@styled-system/css";
import { useCombobox } from "downshift";
import { fetchSuggestResults } from "../../layout/header/fetchSuggestResults";
import { SUGGEST_MAX_RESULTS } from "../../../config";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fr } from "@codegouvfr/react-dsfr";
import { css } from "../../../../styled-system/css";
import { css } from "@styled-system/css";

type Props = {
sectionId: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { fr } from "@codegouvfr/react-dsfr";
import { css } from "../../../styled-system/css";
import { css } from "@styled-system/css";
import Image from "next/image";
import { HomeSearch } from "./Components";
import { useRouter } from "next/navigation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useCombobox } from "downshift";
import { fetchSuggestResults } from "./fetchSuggestResults";
import { SUGGEST_MAX_RESULTS } from "../../../config";
import { fr } from "@codegouvfr/react-dsfr";
import { css } from "../../../../styled-system/css";
import { css } from "@styled-system/css";
import { useLayoutTracking } from "../tracking";

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useNeedMoreInfoEvents } from "./tracking";
import servicesDeRenseignement from "../../../data/services-de-renseignement.json";
import { Button } from "@codegouvfr/react-dsfr/Button";
import { fr } from "@codegouvfr/react-dsfr";
import { css } from "../../../../styled-system/css";
import { css } from "@styled-system/css";

type ServiceRenseignement = {
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { fr } from "@codegouvfr/react-dsfr";
import { Button } from "@codegouvfr/react-dsfr/Button";
import { css } from "../../../../styled-system/css";
import { css } from "@styled-system/css";
import { createModal } from "@codegouvfr/react-dsfr/Modal";
import { PopupContent } from "./PopupContent";
import { useIsModalOpen } from "@codegouvfr/react-dsfr/Modal/useIsModalOpen";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { fr } from "@codegouvfr/react-dsfr";
import { Button } from "@codegouvfr/react-dsfr/Button";
import { useState } from "react";
import { css } from "../../../../styled-system/css";
import { css } from "@styled-system/css";
import { useModeleEvents } from "../tracking";

export const CopyButton = ({ slug }: { slug: string }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fr } from "@codegouvfr/react-dsfr";
import Html from "../../common/Html";
import { css } from "../../../../styled-system/css";
import { css } from "@styled-system/css";
import { getDisclaimer } from "../helpers";
import { Alert } from "@codegouvfr/react-dsfr/Alert";
import { DownloadTile } from "./DownloadTile";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fr } from "@codegouvfr/react-dsfr";
import { CallOut } from "@codegouvfr/react-dsfr/CallOut";
import { css } from "../../../styled-system/css";
import { css } from "@styled-system/css";

type StatsProps = {
title: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fr } from "@codegouvfr/react-dsfr";
import { Tile } from "@codegouvfr/react-dsfr/Tile";
import { css } from "../../../styled-system/css";
import { css } from "@styled-system/css";

type Props = {
title: string;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./sort";
export * from "./events";
export * from "./PolyfillComponent";
6 changes: 5 additions & 1 deletion packages/code-du-travail-frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
{
"name": "next"
}
]
],
"baseUrl": ".",
"paths": {
"@styled-system/*": ["./src/styled-system/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules", "cypress"]
Expand Down
Loading
Loading