From 5c5a89a496eb81af144888907f86daf64b295417 Mon Sep 17 00:00:00 2001 From: Georgios Valotasios Date: Wed, 26 Jun 2024 21:53:40 +0200 Subject: [PATCH 1/3] fix: remove `ts-jest` --- package-lock.json | 102 +----------------- package.json | 1 - packages/frontend/jest.config.mjs | 6 -- .../jest.config.mjs | 6 -- .../jest.config.mjs | 6 -- 5 files changed, 3 insertions(+), 118 deletions(-) diff --git a/package-lock.json b/package-lock.json index f3a19c38..3d8829fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,6 @@ "npm-run-all": "^4.1.5", "prettier": "^3.3.2", "sharp": "^0.31.1", - "ts-jest": "^29.1.5", "typescript": "5.5" } }, @@ -18073,17 +18072,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/bs-logger": { - "version": "0.2.6", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-json-stable-stringify": "2.x" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/bser": { "version": "2.1.1", "dev": true, @@ -26210,11 +26198,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.memoize": { - "version": "4.1.2", - "dev": true, - "license": "MIT" - }, "node_modules/lodash.merge": { "version": "4.6.2", "dev": true, @@ -26300,7 +26283,9 @@ "node_modules/make-error": { "version": "1.3.6", "dev": true, - "license": "ISC" + "license": "ISC", + "optional": true, + "peer": true }, "node_modules/makeerror": { "version": "1.0.12", @@ -32365,87 +32350,6 @@ "node": ">=6.10" } }, - "node_modules/ts-jest": { - "version": "29.1.5", - "dev": true, - "license": "MIT", - "dependencies": { - "bs-logger": "0.x", - "fast-json-stable-stringify": "2.x", - "jest-util": "^29.0.0", - "json5": "^2.2.3", - "lodash.memoize": "4.x", - "make-error": "1.x", - "semver": "^7.5.3", - "yargs-parser": "^21.0.1" - }, - "bin": { - "ts-jest": "cli.js" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" - }, - "peerDependencies": { - "@babel/core": ">=7.0.0-beta.0 <8", - "@jest/transform": "^29.0.0", - "@jest/types": "^29.0.0", - "babel-jest": "^29.0.0", - "jest": "^29.0.0", - "typescript": ">=4.3 <6" - }, - "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, - "@jest/transform": { - "optional": true - }, - "@jest/types": { - "optional": true - }, - "babel-jest": { - "optional": true - }, - "esbuild": { - "optional": true - } - } - }, - "node_modules/ts-jest/node_modules/jest-util": { - "version": "29.7.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@jest/types": "^29.6.3", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/ts-jest/node_modules/semver": { - "version": "7.6.2", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/ts-jest/node_modules/yargs-parser": { - "version": "21.1.1", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, "node_modules/ts-node": { "version": "10.5.0", "dev": true, diff --git a/package.json b/package.json index 2cf38cc0..69c5b1f4 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,6 @@ "npm-run-all": "^4.1.5", "prettier": "^3.3.2", "sharp": "^0.31.1", - "ts-jest": "^29.1.5", "typescript": "5.5" }, "dependencies": { diff --git a/packages/frontend/jest.config.mjs b/packages/frontend/jest.config.mjs index 38f26f10..f6222dd2 100644 --- a/packages/frontend/jest.config.mjs +++ b/packages/frontend/jest.config.mjs @@ -1,13 +1,7 @@ /** @type {import('jest').Config} */ const config = { modulePathIgnorePatterns: ["dist"], - preset: "ts-jest", testEnvironment: "jsdom", - globals: { - "ts-jest": { - useESM: true, - }, - }, transform: { "^.+\\.(t|j)sx?$": "@swc/jest", }, diff --git a/packages/parcel-reporter-staticsite/jest.config.mjs b/packages/parcel-reporter-staticsite/jest.config.mjs index a18e32b4..c6314410 100644 --- a/packages/parcel-reporter-staticsite/jest.config.mjs +++ b/packages/parcel-reporter-staticsite/jest.config.mjs @@ -1,13 +1,7 @@ /** @type {import('jest').Config} */ const config = { modulePathIgnorePatterns: ["dist"], - preset: "ts-jest", testEnvironment: "jsdom", - globals: { - "ts-jest": { - useESM: true, - }, - }, transform: { "^.+\\.(t|j)sx?$": ["@swc/jest"], }, diff --git a/packages/parcel-transformer-staticsite/jest.config.mjs b/packages/parcel-transformer-staticsite/jest.config.mjs index 8b5fe717..89979d80 100644 --- a/packages/parcel-transformer-staticsite/jest.config.mjs +++ b/packages/parcel-transformer-staticsite/jest.config.mjs @@ -1,13 +1,7 @@ /** @type {import('jest').Config} */ const config = { modulePathIgnorePatterns: ["dist"], - preset: "ts-jest", testEnvironment: "jsdom", - globals: { - "ts-jest": { - useESM: true, - }, - }, transform: { "^.+\\.(t|j)sx?$": ["@swc/jest"], }, From 262955d163b30a1789b84a603727009b35a31210 Mon Sep 17 00:00:00 2001 From: Georgios Valotasios Date: Thu, 27 Jun 2024 22:56:42 +0200 Subject: [PATCH 2/3] feat: es6 modules --- packages/frontend/.storybook/preview.jsx | 2 +- packages/frontend/package.json | 4 ++++ packages/frontend/src/AsyncContext.spec.tsx | 9 +++++---- packages/frontend/src/AsyncContext.tsx | 2 +- packages/frontend/src/DateSpan.tsx | 6 +++--- packages/frontend/src/FetchTracker.tsx | 3 ++- packages/frontend/src/Footer.tsx | 7 ++++--- packages/frontend/src/Header.spec.tsx | 3 ++- packages/frontend/src/Header.tsx | 11 ++++++----- packages/frontend/src/Icon.spec.tsx | 3 ++- packages/frontend/src/Icon.tsx | 3 ++- packages/frontend/src/LoadingBar.tsx | 5 +++-- packages/frontend/src/Page.stories.tsx | 3 ++- packages/frontend/src/Page.tsx | 11 ++++++----- packages/frontend/src/PageRenderer.spec.tsx | 5 +++-- packages/frontend/src/PageRenderer.tsx | 10 +++++----- packages/frontend/src/PageWithItems.stories.tsx | 3 ++- packages/frontend/src/PageWithItems.tsx | 11 ++++++----- packages/frontend/src/PageWithMarkdown.spec.tsx | 3 ++- packages/frontend/src/PageWithMarkdown.stories.tsx | 5 +++-- packages/frontend/src/PageWithMarkdown.tsx | 5 +++-- packages/frontend/src/PrismCodeBlock.spec.tsx | 3 ++- packages/frontend/src/PrismCodeBlock.stories.tsx | 5 +++-- packages/frontend/src/PrismCodeBlock.tsx | 5 +++-- packages/frontend/src/index.ts | 14 +++++++------- packages/frontend/src/links.spec.tsx | 11 ++++++----- packages/frontend/src/links.stories.tsx | 7 ++++--- packages/frontend/src/links.tsx | 7 ++++--- packages/frontend/src/marked/CodeBlock.tsx | 2 +- packages/frontend/src/marked/CodeSpan.tsx | 2 +- packages/frontend/src/marked/Gist.spec.ts | 2 +- packages/frontend/src/marked/Gist.tsx | 6 +++--- packages/frontend/src/marked/Heading.tsx | 2 +- packages/frontend/src/marked/Html.spec.tsx | 2 +- packages/frontend/src/marked/Html.tsx | 4 ++-- packages/frontend/src/marked/List.tsx | 2 +- .../frontend/src/marked/MarkedContent.spec.tsx | 2 +- packages/frontend/src/marked/MarkedContent.tsx | 12 ++++++------ packages/frontend/src/marked/MarkedLink.tsx | 2 +- packages/frontend/src/md.spec.ts | 2 +- packages/frontend/src/prism.ts | 10 +++++----- packages/frontend/src/render.spec.ts | 2 +- packages/frontend/src/render.tsx | 13 +++++++------ packages/frontend/tsconfig.json | 9 ++++----- .../parcel-reporter-staticsite/jest.config.mjs | 3 +++ .../parcel-reporter-staticsite/src/AWSService.ts | 2 +- .../src/StaticSiteReporter.ts | 4 ++-- .../parcel-reporter-staticsite/src/utils.spec.ts | 2 +- packages/parcel-transformer-staticsite/htmlbody.js | 2 +- .../parcel-transformer-staticsite/jest.config.mjs | 5 ++++- packages/parcel-transformer-staticsite/md.js | 2 +- packages/parcel-transformer-staticsite/meta.js | 2 +- .../parcel-transformer-staticsite/package.json | 1 + .../src/StaticSiteTransformer.ts | 8 ++++---- .../src/date-sorter.spec.ts | 2 +- .../src/htmlbody-transformer.ts | 2 +- .../src/key-factory.spec.ts | 2 +- .../src/md-transformer.ts | 8 ++++---- .../src/robots-transformer.ts | 8 ++++---- .../src/robots.spec.ts | 2 +- .../src/sitemap-transformer.spec.ts | 2 +- .../src/sitemap-transformer.ts | 10 +++++----- .../src/{sitiemap.spec.ts => sitemap.spec.ts} | 4 +++- .../parcel-transformer-staticsite/src/sitemap.ts | 6 ++++-- .../parcel-transformer-staticsite/tsconfig.json | 2 +- packages/parcel-transformer-staticsite/txt.js | 2 +- 66 files changed, 179 insertions(+), 142 deletions(-) rename packages/parcel-transformer-staticsite/src/{sitiemap.spec.ts => sitemap.spec.ts} (95%) diff --git a/packages/frontend/.storybook/preview.jsx b/packages/frontend/.storybook/preview.jsx index 85e46f0b..20e3106c 100644 --- a/packages/frontend/.storybook/preview.jsx +++ b/packages/frontend/.storybook/preview.jsx @@ -1,7 +1,7 @@ import "../src/assets.css"; import "prismjs/themes/prism-okaidia.css"; import { domSheet } from "twind/sheets"; -import { setup } from "../src/twind"; +import { setup } from "../src/twind.js"; export const parameters = { actions: { argTypesRegex: "^on[A-Z].*" }, diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 408330b1..4b5ad410 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -7,6 +7,7 @@ }, "private": true, "main": "dist/index.js", + "type": "module", "types": "dist/index.d.ts", "scripts": { "clean": "rimraf dist node_modules", @@ -47,5 +48,8 @@ "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "babel-loader": "^8.2.3" + }, + "alias": { + "react/jsx-runtime": "react/jsx-runtime.js" } } diff --git a/packages/frontend/src/AsyncContext.spec.tsx b/packages/frontend/src/AsyncContext.spec.tsx index 9a765736..11e89011 100644 --- a/packages/frontend/src/AsyncContext.spec.tsx +++ b/packages/frontend/src/AsyncContext.spec.tsx @@ -1,6 +1,7 @@ +import React from "react"; import fetchMock from "jest-fetch-mock"; import { render, waitFor } from "@testing-library/react"; -import { useFetch } from "./AsyncContext"; +import { useFetch } from "./AsyncContext.js"; function UseFetchTester({ url }: { url: string }) { const { content, loading } = useFetch(url); @@ -10,7 +11,7 @@ function UseFetchTester({ url }: { url: string }) { describe("AsyncContext", () => { beforeEach(() => { - fetchMock.resetMocks(); + fetchMock.default.resetMocks(); }); describe("useFetch", () => { @@ -26,7 +27,7 @@ describe("AsyncContext", () => { it("it returns { loading: true } while response is not done", async () => { const url = "/url/to/be/fetched/2"; //eslint-disable-next-line - fetchMock.mockReturnValue(new Promise((_) => {})); + fetchMock.default.mockReturnValue(new Promise((_) => {})); const { container } = render(); @@ -38,7 +39,7 @@ describe("AsyncContext", () => { it("it returns { loading: false, content } when response is done", async () => { const url = "/url/to/be/fetched/3"; const content = "this is the content"; - fetchMock.mockOnce(content); + fetchMock.default.mockOnce(content); const { container } = render(); diff --git a/packages/frontend/src/AsyncContext.tsx b/packages/frontend/src/AsyncContext.tsx index 55101d0d..607ea52c 100644 --- a/packages/frontend/src/AsyncContext.tsx +++ b/packages/frontend/src/AsyncContext.tsx @@ -1,4 +1,4 @@ -import { +import React, { DependencyList, EffectCallback, PropsWithChildren, diff --git a/packages/frontend/src/DateSpan.tsx b/packages/frontend/src/DateSpan.tsx index 085bfbaa..6a26695a 100644 --- a/packages/frontend/src/DateSpan.tsx +++ b/packages/frontend/src/DateSpan.tsx @@ -1,6 +1,6 @@ -import { parseISO } from "date-fns/fp"; -import { format as fnsFormat } from "date-fns"; -import { tw } from "./twind"; +import React from "react"; +import { format as fnsFormat, parseISO } from "date-fns"; +import { tw } from "./twind.js"; export type DateSpanProps = { iso?: string; diff --git a/packages/frontend/src/FetchTracker.tsx b/packages/frontend/src/FetchTracker.tsx index 989e49e9..44089729 100644 --- a/packages/frontend/src/FetchTracker.tsx +++ b/packages/frontend/src/FetchTracker.tsx @@ -1,5 +1,6 @@ +import React from "react"; import { PropsWithChildren, useContext, useCallback, useState } from "react"; -import { AsyncContext } from "./AsyncContext"; +import { AsyncContext } from "./AsyncContext.js"; export function FetchTracker({ children }: PropsWithChildren) { const { diff --git a/packages/frontend/src/Footer.tsx b/packages/frontend/src/Footer.tsx index 36d67309..a4e73ccb 100644 --- a/packages/frontend/src/Footer.tsx +++ b/packages/frontend/src/Footer.tsx @@ -1,6 +1,7 @@ -import { Link } from "./links"; -import { tw } from "./twind"; -import { name } from "./title"; +import React from "react"; +import { Link } from "./links.js"; +import { tw } from "./twind.js"; +import { name } from "./title.js"; export interface FooterProps { pkgVersion?: string; diff --git a/packages/frontend/src/Header.spec.tsx b/packages/frontend/src/Header.spec.tsx index 39f2da47..551bbd79 100644 --- a/packages/frontend/src/Header.spec.tsx +++ b/packages/frontend/src/Header.spec.tsx @@ -1,5 +1,6 @@ +import React from "react"; import { render } from "@testing-library/react"; -import { Header } from "./Header"; +import { Header } from "./Header.js"; describe("Header", () => { it("should render html with h1 with the given title", () => { diff --git a/packages/frontend/src/Header.tsx b/packages/frontend/src/Header.tsx index 73076cdb..66440967 100644 --- a/packages/frontend/src/Header.tsx +++ b/packages/frontend/src/Header.tsx @@ -1,8 +1,9 @@ -import { DateSpan } from "./DateSpan"; -import { tw } from "./twind"; -import { Icon, IconProps } from "./Icon"; -import { createTitle } from "./title"; -import { Anchor, Link } from "./links"; +import React from "react"; +import { DateSpan } from "./DateSpan.js"; +import { tw } from "./twind.js"; +import { Icon, IconProps } from "./Icon.js"; +import { createTitle } from "./title.js"; +import { Anchor, Link } from "./links.js"; export interface HeaderProps { title?: string | null; diff --git a/packages/frontend/src/Icon.spec.tsx b/packages/frontend/src/Icon.spec.tsx index 2f1b972e..608c82bb 100644 --- a/packages/frontend/src/Icon.spec.tsx +++ b/packages/frontend/src/Icon.spec.tsx @@ -1,5 +1,6 @@ +import React from "react"; import { render } from "@testing-library/react"; -import { Icon } from "./Icon"; +import { Icon } from "./Icon.js"; describe("Icon", () => { it("should render an svg", () => { diff --git a/packages/frontend/src/Icon.tsx b/packages/frontend/src/Icon.tsx index e553df41..98e3ad40 100644 --- a/packages/frontend/src/Icon.tsx +++ b/packages/frontend/src/Icon.tsx @@ -1,4 +1,5 @@ -import { tw } from "./twind"; +import React from "react"; +import { tw } from "./twind.js"; function LinkedInIcon() { return ( diff --git a/packages/frontend/src/LoadingBar.tsx b/packages/frontend/src/LoadingBar.tsx index c909a1ac..1691d550 100644 --- a/packages/frontend/src/LoadingBar.tsx +++ b/packages/frontend/src/LoadingBar.tsx @@ -1,6 +1,7 @@ +import React from "react"; import { useMemo } from "react"; -import { useFetchCounter } from "./FetchTracker"; -import { tw, animation, keyframes } from "./twind"; +import { useFetchCounter } from "./FetchTracker.js"; +import { tw, animation, keyframes } from "./twind.js"; function creatingAnimation() { return animation( diff --git a/packages/frontend/src/Page.stories.tsx b/packages/frontend/src/Page.stories.tsx index a26cdd51..9b09039d 100644 --- a/packages/frontend/src/Page.stories.tsx +++ b/packages/frontend/src/Page.stories.tsx @@ -1,5 +1,6 @@ +import React from "react"; import { ComponentMeta, ComponentStory } from "@storybook/react"; -import { Page } from "./Page"; +import { Page } from "./Page.js"; export default { title: "Page", diff --git a/packages/frontend/src/Page.tsx b/packages/frontend/src/Page.tsx index 5f9b117d..6b3a894b 100644 --- a/packages/frontend/src/Page.tsx +++ b/packages/frontend/src/Page.tsx @@ -1,9 +1,10 @@ +import React from "react"; import { PropsWithChildren, StrictMode } from "react"; -import { tw } from "./twind"; -import { Footer, FooterProps } from "./Footer"; -import { Header, HeaderProps } from "./Header"; -import { LoadingBar } from "./LoadingBar"; -import { FetchTracker } from "./FetchTracker"; +import { tw } from "./twind.js"; +import { Footer, FooterProps } from "./Footer.js"; +import { Header, HeaderProps } from "./Header.js"; +import { LoadingBar } from "./LoadingBar.js"; +import { FetchTracker } from "./FetchTracker.js"; export type PageProps = FooterProps & HeaderProps; diff --git a/packages/frontend/src/PageRenderer.spec.tsx b/packages/frontend/src/PageRenderer.spec.tsx index 3485c23a..ae5b9d49 100644 --- a/packages/frontend/src/PageRenderer.spec.tsx +++ b/packages/frontend/src/PageRenderer.spec.tsx @@ -1,6 +1,7 @@ +import React from "react"; import { act, render } from "@testing-library/react"; -import { PageRenderer } from "./PageRenderer"; -import { history } from "./History"; +import { PageRenderer } from "./PageRenderer.js"; +import { history } from "./History.js"; jest.mock("./History", () => { const history = jest.fn(); diff --git a/packages/frontend/src/PageRenderer.tsx b/packages/frontend/src/PageRenderer.tsx index 7d622007..60696e96 100644 --- a/packages/frontend/src/PageRenderer.tsx +++ b/packages/frontend/src/PageRenderer.tsx @@ -1,8 +1,8 @@ -import { useCallback, useEffect, useState } from "react"; -import { PageWithItems, PageWithListProps } from "./PageWithItems"; -import { PageWithMarkdown, PageWithMarkdownProps } from "./PageWithMarkdown"; -import { createTitle } from "./title"; -import { history } from "./History"; +import React, { useCallback, useEffect, useState } from "react"; +import { PageWithItems, PageWithListProps } from "./PageWithItems.js"; +import { PageWithMarkdown, PageWithMarkdownProps } from "./PageWithMarkdown.js"; +import { createTitle } from "./title.js"; +import { history } from "./History.js"; function getPageProps(input: PageRendererProps) { if ("payload" in input) { diff --git a/packages/frontend/src/PageWithItems.stories.tsx b/packages/frontend/src/PageWithItems.stories.tsx index eb0aff06..09bdbce9 100644 --- a/packages/frontend/src/PageWithItems.stories.tsx +++ b/packages/frontend/src/PageWithItems.stories.tsx @@ -1,5 +1,6 @@ +import React from "react"; import { ComponentMeta, ComponentStory } from "@storybook/react"; -import { PageWithItems } from "./PageWithItems"; +import { PageWithItems } from "./PageWithItems.js"; export default { title: "PageWithItems", diff --git a/packages/frontend/src/PageWithItems.tsx b/packages/frontend/src/PageWithItems.tsx index 2aed4bb7..15b8e37d 100644 --- a/packages/frontend/src/PageWithItems.tsx +++ b/packages/frontend/src/PageWithItems.tsx @@ -1,8 +1,9 @@ -import { DateSpan } from "./DateSpan"; -import { Page, PageProps } from "./Page"; -import { tw } from "./twind"; -import { Anchor, Link } from "./links"; -import { MarkedContent } from "./marked/MarkedContent"; +import React from "react"; +import { DateSpan } from "./DateSpan.js"; +import { Page, PageProps } from "./Page.js"; +import { tw } from "./twind.js"; +import { Anchor, Link } from "./links.js"; +import { MarkedContent } from "./marked/MarkedContent.js"; export type PageItem = { date?: string; diff --git a/packages/frontend/src/PageWithMarkdown.spec.tsx b/packages/frontend/src/PageWithMarkdown.spec.tsx index 0c911a13..9fd028fb 100644 --- a/packages/frontend/src/PageWithMarkdown.spec.tsx +++ b/packages/frontend/src/PageWithMarkdown.spec.tsx @@ -1,5 +1,6 @@ +import React from "react"; import { render, screen } from "@testing-library/react"; -import { PageWithMarkdown } from "./PageWithMarkdown"; +import { PageWithMarkdown } from "./PageWithMarkdown.js"; describe("PageWithMarkdown", () => { it("should render html", async () => { diff --git a/packages/frontend/src/PageWithMarkdown.stories.tsx b/packages/frontend/src/PageWithMarkdown.stories.tsx index 882843c9..493fcd52 100644 --- a/packages/frontend/src/PageWithMarkdown.stories.tsx +++ b/packages/frontend/src/PageWithMarkdown.stories.tsx @@ -1,8 +1,9 @@ +import React from "react"; import { ComponentMeta, ComponentStory } from "@storybook/react"; import trueArticle from "../../web/src/articles/testing-rxjs.md"; import articleContainingTweet from "../../web/src/articles/devoxx-2014.md"; -import { PageWithMarkdown } from "./PageWithMarkdown"; -import { AsyncContext, AsyncContextState } from "./AsyncContext"; +import { PageWithMarkdown } from "./PageWithMarkdown.js"; +import { AsyncContext, AsyncContextState } from "./AsyncContext.js"; export default { title: "PageWithMarkdown", diff --git a/packages/frontend/src/PageWithMarkdown.tsx b/packages/frontend/src/PageWithMarkdown.tsx index 223d99a4..f214559e 100644 --- a/packages/frontend/src/PageWithMarkdown.tsx +++ b/packages/frontend/src/PageWithMarkdown.tsx @@ -1,5 +1,6 @@ -import { Page, PageProps } from "./Page"; -import { MarkedContent } from "./marked/MarkedContent"; +import React from "react"; +import { Page, PageProps } from "./Page.js"; +import { MarkedContent } from "./marked/MarkedContent.js"; export type PageWithMarkdownProps = PageProps & { bodyMarkdown?: string; diff --git a/packages/frontend/src/PrismCodeBlock.spec.tsx b/packages/frontend/src/PrismCodeBlock.spec.tsx index 367d5755..230c3d17 100644 --- a/packages/frontend/src/PrismCodeBlock.spec.tsx +++ b/packages/frontend/src/PrismCodeBlock.spec.tsx @@ -1,5 +1,6 @@ +import React from "react"; import { render } from "@testing-library/react"; -import { PrismCodeBlock } from "./PrismCodeBlock"; +import { PrismCodeBlock } from "./PrismCodeBlock.js"; describe("PrismCode", () => { it("should render formated the given code", () => { diff --git a/packages/frontend/src/PrismCodeBlock.stories.tsx b/packages/frontend/src/PrismCodeBlock.stories.tsx index af11f7ff..ea59e7c1 100644 --- a/packages/frontend/src/PrismCodeBlock.stories.tsx +++ b/packages/frontend/src/PrismCodeBlock.stories.tsx @@ -1,6 +1,7 @@ +import React from "react"; import { ComponentMeta, ComponentStory } from "@storybook/react"; -import { PrismCodeBlock } from "./PrismCodeBlock"; -import { Link } from "./links"; +import { PrismCodeBlock } from "./PrismCodeBlock.js"; +import { Link } from "./links.js"; export default { title: PrismCodeBlock.name, diff --git a/packages/frontend/src/PrismCodeBlock.tsx b/packages/frontend/src/PrismCodeBlock.tsx index 463eeddf..bbb5baad 100644 --- a/packages/frontend/src/PrismCodeBlock.tsx +++ b/packages/frontend/src/PrismCodeBlock.tsx @@ -1,6 +1,7 @@ +import React from "react"; import { PropsWithChildren } from "react"; -import { getGrammar, highlight } from "./prism"; -import { tw } from "./twind"; +import { getGrammar, highlight } from "./prism.js"; +import { tw } from "./twind.js"; export type PrismCodeProps = { language?: string; diff --git a/packages/frontend/src/index.ts b/packages/frontend/src/index.ts index 92b53f0b..24a88d08 100644 --- a/packages/frontend/src/index.ts +++ b/packages/frontend/src/index.ts @@ -1,9 +1,9 @@ -import { setup } from "./twind"; -export * from "./PageWithMarkdown"; -export * from "./PageWithItems"; -export * from "./PageRenderer"; -export * from "./md"; -export * from "./title"; -export * from "./History"; +import { setup } from "./twind.js"; +export * from "./PageWithMarkdown.js"; +export * from "./PageWithItems.js"; +export * from "./PageRenderer.js"; +export * from "./md.js"; +export * from "./title.js"; +export * from "./History.js"; setup(); diff --git a/packages/frontend/src/links.spec.tsx b/packages/frontend/src/links.spec.tsx index 36e8a10a..c9c5a81b 100644 --- a/packages/frontend/src/links.spec.tsx +++ b/packages/frontend/src/links.spec.tsx @@ -1,7 +1,8 @@ +import React from "react"; import fetchMock from "jest-fetch-mock"; import { render, fireEvent, waitFor } from "@testing-library/react"; -import { Anchor } from "./links"; -import * as history from "./History"; +import { Anchor } from "./links.js"; +import * as history from "./History.js"; jest.mock("./History", () => ({ history: jest.fn(), @@ -9,7 +10,7 @@ jest.mock("./History", () => ({ describe("links", () => { beforeEach(() => { - fetchMock.resetMocks(); + fetchMock.default.resetMocks(); jest.mocked(history.history).mockReturnValue({ pushState: jest.fn(), @@ -59,7 +60,7 @@ describe("links", () => { it("pushes the fetched state to history", async () => { const payload = "payload"; - fetchMock.mockOnce(payload); + fetchMock.default.mockOnce(payload); const pushState = jest.fn(); jest.mocked(history.history).mockReturnValue({ pushState, @@ -84,7 +85,7 @@ describe("links", () => { it("pushes an href with an ending / to the history", async () => { const payload = "payload"; - fetchMock.mockOnce(payload); + fetchMock.default.mockOnce(payload); const pushState = jest.fn(); jest.mocked(history.history).mockReturnValue({ pushState, diff --git a/packages/frontend/src/links.stories.tsx b/packages/frontend/src/links.stories.tsx index 7272b147..e2f22619 100644 --- a/packages/frontend/src/links.stories.tsx +++ b/packages/frontend/src/links.stories.tsx @@ -1,7 +1,8 @@ +import React from "react"; import { ComponentMeta, ComponentStory } from "@storybook/react"; -import { PageWithMarkdown } from "./PageWithMarkdown"; -import { Link } from "./links"; -import { CodeSpan } from "./marked/CodeSpan"; +import { PageWithMarkdown } from "./PageWithMarkdown.js"; +import { Link } from "./links.js"; +import { CodeSpan } from "./marked/CodeSpan.js"; export default { title: "links", diff --git a/packages/frontend/src/links.tsx b/packages/frontend/src/links.tsx index 9bc249b6..bea9d4b1 100644 --- a/packages/frontend/src/links.tsx +++ b/packages/frontend/src/links.tsx @@ -1,7 +1,8 @@ +import React from "react"; import { MouseEvent, useCallback, PropsWithChildren } from "react"; -import { tw } from "./twind"; -import { Icon, IconProps } from "./Icon"; -import { history } from "./History"; +import { tw } from "./twind.js"; +import { Icon, IconProps } from "./Icon.js"; +import { history } from "./History.js"; function computeHref(href: string) { if (!href.endsWith("/")) { diff --git a/packages/frontend/src/marked/CodeBlock.tsx b/packages/frontend/src/marked/CodeBlock.tsx index 1e6099c7..ec180811 100644 --- a/packages/frontend/src/marked/CodeBlock.tsx +++ b/packages/frontend/src/marked/CodeBlock.tsx @@ -1,6 +1,6 @@ import React from "react"; import { CodeBlockRendererProps } from "react-marked-renderer"; -import { PrismCodeBlock } from "../PrismCodeBlock"; +import { PrismCodeBlock } from "../PrismCodeBlock.js"; export function CodeBlock({ lang, children }: CodeBlockRendererProps) { const code = typeof children === "string" ? children : undefined; diff --git a/packages/frontend/src/marked/CodeSpan.tsx b/packages/frontend/src/marked/CodeSpan.tsx index 06e876c5..8f5f395d 100644 --- a/packages/frontend/src/marked/CodeSpan.tsx +++ b/packages/frontend/src/marked/CodeSpan.tsx @@ -1,6 +1,6 @@ import React from "react"; import { CodeSpanRendererProps } from "react-marked-renderer"; -import { tw } from "../twind"; +import { tw } from "../twind.js"; export function CodeSpan({ children }: CodeSpanRendererProps) { return {children}; diff --git a/packages/frontend/src/marked/Gist.spec.ts b/packages/frontend/src/marked/Gist.spec.ts index a4ecebd2..5add78d3 100644 --- a/packages/frontend/src/marked/Gist.spec.ts +++ b/packages/frontend/src/marked/Gist.spec.ts @@ -1,4 +1,4 @@ -import { parseGist } from "./Gist"; +import { parseGist } from "./Gist.js"; describe("Gist", () => { describe("parseGist", () => { diff --git a/packages/frontend/src/marked/Gist.tsx b/packages/frontend/src/marked/Gist.tsx index 6931a41c..b087799a 100644 --- a/packages/frontend/src/marked/Gist.tsx +++ b/packages/frontend/src/marked/Gist.tsx @@ -1,7 +1,7 @@ import React, { PropsWithChildren } from "react"; -import { useFetch } from "../AsyncContext"; -import { LinkWithIcon } from "../links"; -import { PrismCodeBlock } from "../PrismCodeBlock"; +import { useFetch } from "../AsyncContext.js"; +import { LinkWithIcon } from "../links.js"; +import { PrismCodeBlock } from "../PrismCodeBlock.js"; function computeLanguage(file?: string) { if (file && file.indexOf(".js") > 0) { diff --git a/packages/frontend/src/marked/Heading.tsx b/packages/frontend/src/marked/Heading.tsx index aa32a20a..dca12541 100644 --- a/packages/frontend/src/marked/Heading.tsx +++ b/packages/frontend/src/marked/Heading.tsx @@ -1,7 +1,7 @@ import { createElement } from "react"; import { HeadingRendererProps } from "react-marked-renderer"; import { apply } from "twind"; -import { tw } from "../twind"; +import { tw } from "../twind.js"; type HeadingWeight = "h1" | "h2" | "h3" | "h4"; const depths = [1, 2, 3, 4]; diff --git a/packages/frontend/src/marked/Html.spec.tsx b/packages/frontend/src/marked/Html.spec.tsx index 0d3e3a91..782b2cf5 100644 --- a/packages/frontend/src/marked/Html.spec.tsx +++ b/packages/frontend/src/marked/Html.spec.tsx @@ -1,6 +1,6 @@ import { render } from "@testing-library/react"; import React from "react"; -import { Html } from "./Html"; +import { Html } from "./Html.js"; describe("Html", () => { it("should render html", async () => { diff --git a/packages/frontend/src/marked/Html.tsx b/packages/frontend/src/marked/Html.tsx index bb0acbb7..9b4940a6 100644 --- a/packages/frontend/src/marked/Html.tsx +++ b/packages/frontend/src/marked/Html.tsx @@ -1,7 +1,7 @@ import React, { useCallback } from "react"; import { HtmlRendererProps } from "react-marked-renderer"; -import { Script } from "../Script"; -import { Gist, parseGist } from "./Gist"; +import { Script } from "../Script.js"; +import { Gist, parseGist } from "./Gist.js"; const twitterUrl = "//platform.twitter.com/widgets.js"; diff --git a/packages/frontend/src/marked/List.tsx b/packages/frontend/src/marked/List.tsx index b2fc6530..5987db30 100644 --- a/packages/frontend/src/marked/List.tsx +++ b/packages/frontend/src/marked/List.tsx @@ -1,6 +1,6 @@ import { createElement } from "react"; import { ListRendererProps } from "react-marked-renderer"; -import { tw } from "../twind"; +import { tw } from "../twind.js"; export function List({ children, ordered }: ListRendererProps) { const Component = ordered ? "ol" : "ul"; diff --git a/packages/frontend/src/marked/MarkedContent.spec.tsx b/packages/frontend/src/marked/MarkedContent.spec.tsx index ca9a7481..0072fb4c 100644 --- a/packages/frontend/src/marked/MarkedContent.spec.tsx +++ b/packages/frontend/src/marked/MarkedContent.spec.tsx @@ -1,7 +1,7 @@ import { render, screen, waitFor } from "@testing-library/react"; import { marked } from "marked"; import React from "react"; -import { MarkedContent } from "./MarkedContent"; +import { MarkedContent } from "./MarkedContent.js"; describe("MarkedContent", () => { function renderMarked(raw: string) { diff --git a/packages/frontend/src/marked/MarkedContent.tsx b/packages/frontend/src/marked/MarkedContent.tsx index 36c09dbb..ee0c268f 100644 --- a/packages/frontend/src/marked/MarkedContent.tsx +++ b/packages/frontend/src/marked/MarkedContent.tsx @@ -1,11 +1,11 @@ import React from "react"; import { DEFAULT_MARKDOWN_RENDERERS, Markdown } from "react-marked-renderer"; -import { CodeBlock } from "./CodeBlock"; -import { CodeSpan } from "./CodeSpan"; -import { Heading } from "./Heading"; -import { Html } from "./Html"; -import { List } from "./List"; -import { MarkedLink } from "./MarkedLink"; +import { CodeBlock } from "./CodeBlock.js"; +import { CodeSpan } from "./CodeSpan.js"; +import { Heading } from "./Heading.js"; +import { Html } from "./Html.js"; +import { List } from "./List.js"; +import { MarkedLink } from "./MarkedLink.js"; const renderers = { ...DEFAULT_MARKDOWN_RENDERERS, diff --git a/packages/frontend/src/marked/MarkedLink.tsx b/packages/frontend/src/marked/MarkedLink.tsx index 16d26ad8..8eedabdf 100644 --- a/packages/frontend/src/marked/MarkedLink.tsx +++ b/packages/frontend/src/marked/MarkedLink.tsx @@ -1,6 +1,6 @@ import React from "react"; import { LinkRendererProps } from "react-marked-renderer"; -import { Link } from "../links"; +import { Link } from "../links.js"; export function MarkedLink({ children, href }: LinkRendererProps) { return {children}; diff --git a/packages/frontend/src/md.spec.ts b/packages/frontend/src/md.spec.ts index 2cba5889..a6dbf5f5 100644 --- a/packages/frontend/src/md.spec.ts +++ b/packages/frontend/src/md.spec.ts @@ -1,4 +1,4 @@ -import * as md from "./md"; +import * as md from "./md.js"; describe("md", () => { it("exports parse function", () => { diff --git a/packages/frontend/src/prism.ts b/packages/frontend/src/prism.ts index 08c2da26..d5e3db4d 100644 --- a/packages/frontend/src/prism.ts +++ b/packages/frontend/src/prism.ts @@ -1,14 +1,14 @@ import type prism from "prismjs"; -import { languages, highlight as pHighlight } from "prismjs"; -import "prismjs/components/prism-java"; -import "prismjs/components/prism-groovy"; +import prismjs from "prismjs"; +import "prismjs/components/prism-java.js"; +import "prismjs/components/prism-groovy.js"; export function getGrammar(lang = "none"): { grammar: prism.Grammar; lang: string; className: string; } { - const grammar = languages[lang]; + const grammar = prismjs.languages[lang]; if (!grammar) { return getGrammar("plain"); @@ -18,5 +18,5 @@ export function getGrammar(lang = "none"): { } export function highlight(code: string, grammar: prism.Grammar, lang: string) { - return pHighlight(code, grammar, lang); + return prismjs.highlight(code, grammar, lang); } diff --git a/packages/frontend/src/render.spec.ts b/packages/frontend/src/render.spec.ts index b989d039..1fdbf440 100644 --- a/packages/frontend/src/render.spec.ts +++ b/packages/frontend/src/render.spec.ts @@ -1,4 +1,4 @@ -import { render } from "./render"; +import { render } from "./render.js"; describe("render", () => { test("returns an html string", async () => { diff --git a/packages/frontend/src/render.tsx b/packages/frontend/src/render.tsx index bc99e5c3..d4ba79fc 100644 --- a/packages/frontend/src/render.tsx +++ b/packages/frontend/src/render.tsx @@ -1,10 +1,11 @@ -import { renderToString } from "react-dom/server"; -import nfetch from "node-fetch"; +import React from "react"; +import { renderToString } from "react-dom/server.js"; import { asyncVirtualSheet, getStyleTag } from "twind/server"; -import { setup } from "./twind"; -import { FetchContent, createAsyncContextProvider } from "./AsyncContext"; -import { PageRenderer, PageRendererProps } from "./PageRenderer"; +import { setup } from "./twind.js"; +import { FetchContent, createAsyncContextProvider } from "./AsyncContext.js"; +import { PageRenderer, PageRendererProps } from "./PageRenderer.js"; +const _fetch = fetch; const sheet = asyncVirtualSheet(); setup({ sheet }); @@ -26,7 +27,7 @@ export async function render({ fetchContent || ((url: string) => { logger?.log(`Downloading ${url}`); - return nfetch(url).then((b) => { + return _fetch(url).then((b) => { if (!b.ok) { throw new Error(`Could not download ${url}`); } diff --git a/packages/frontend/tsconfig.json b/packages/frontend/tsconfig.json index 66e5e1d3..ebb15e88 100644 --- a/packages/frontend/tsconfig.json +++ b/packages/frontend/tsconfig.json @@ -8,11 +8,10 @@ "rootDir": "src/", "outDir": "dist/", "declaration": true, - "target": "es2016", - "jsx": "react-jsx", - "jsxImportSource": "react", - "module": "CommonJS", - "moduleResolution": "node", + "target": "es2021", + "jsx": "react", + "module": "Node16", + "moduleResolution": "node16", "isolatedModules": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, diff --git a/packages/parcel-reporter-staticsite/jest.config.mjs b/packages/parcel-reporter-staticsite/jest.config.mjs index c6314410..08628a0c 100644 --- a/packages/parcel-reporter-staticsite/jest.config.mjs +++ b/packages/parcel-reporter-staticsite/jest.config.mjs @@ -5,6 +5,9 @@ const config = { transform: { "^.+\\.(t|j)sx?$": ["@swc/jest"], }, + moduleNameMapper: { + "^(.+?)\\.js$": "$1", // Redirect .js imports to .ts + }, }; export default config; diff --git a/packages/parcel-reporter-staticsite/src/AWSService.ts b/packages/parcel-reporter-staticsite/src/AWSService.ts index 1c27831e..43e1b205 100644 --- a/packages/parcel-reporter-staticsite/src/AWSService.ts +++ b/packages/parcel-reporter-staticsite/src/AWSService.ts @@ -5,7 +5,7 @@ import { CloudFrontClient, CreateInvalidationCommand, } from "@aws-sdk/client-cloudfront"; -import { getBranch } from "./utils"; +import { getBranch } from "./utils.js"; class AWSService { private region = "eu-central-1"; diff --git a/packages/parcel-reporter-staticsite/src/StaticSiteReporter.ts b/packages/parcel-reporter-staticsite/src/StaticSiteReporter.ts index 41fd0faa..8dfad50f 100644 --- a/packages/parcel-reporter-staticsite/src/StaticSiteReporter.ts +++ b/packages/parcel-reporter-staticsite/src/StaticSiteReporter.ts @@ -1,8 +1,8 @@ /* eslint-env node */ import { Reporter } from "@parcel/plugin"; import * as chalk from "chalk"; -import { createAWSService } from "./AWSService"; -import { createRedirectionRule, log } from "./utils"; +import { createAWSService } from "./AWSService.js"; +import { createRedirectionRule, log } from "./utils.js"; export default new Reporter({ async report({ event }) { diff --git a/packages/parcel-reporter-staticsite/src/utils.spec.ts b/packages/parcel-reporter-staticsite/src/utils.spec.ts index 5e153576..aaef2702 100644 --- a/packages/parcel-reporter-staticsite/src/utils.spec.ts +++ b/packages/parcel-reporter-staticsite/src/utils.spec.ts @@ -1,6 +1,6 @@ /* eslint-env jest */ -import { createAlias } from "./utils"; +import { createAlias } from "./utils.js"; describe("utils", () => { describe("createAlias", () => { diff --git a/packages/parcel-transformer-staticsite/htmlbody.js b/packages/parcel-transformer-staticsite/htmlbody.js index 9f08333d..eac137aa 100644 --- a/packages/parcel-transformer-staticsite/htmlbody.js +++ b/packages/parcel-transformer-staticsite/htmlbody.js @@ -1,2 +1,2 @@ // eslint-disable-next-line no-undef,@typescript-eslint/no-var-requires -exports.default = require("./dist/StaticSiteTransformer").default; +export { default } from "./dist/StaticSiteTransformer.js"; diff --git a/packages/parcel-transformer-staticsite/jest.config.mjs b/packages/parcel-transformer-staticsite/jest.config.mjs index 89979d80..08628a0c 100644 --- a/packages/parcel-transformer-staticsite/jest.config.mjs +++ b/packages/parcel-transformer-staticsite/jest.config.mjs @@ -5,6 +5,9 @@ const config = { transform: { "^.+\\.(t|j)sx?$": ["@swc/jest"], }, + moduleNameMapper: { + "^(.+?)\\.js$": "$1", // Redirect .js imports to .ts + }, }; -export default config; \ No newline at end of file +export default config; diff --git a/packages/parcel-transformer-staticsite/md.js b/packages/parcel-transformer-staticsite/md.js index 9f08333d..eac137aa 100644 --- a/packages/parcel-transformer-staticsite/md.js +++ b/packages/parcel-transformer-staticsite/md.js @@ -1,2 +1,2 @@ // eslint-disable-next-line no-undef,@typescript-eslint/no-var-requires -exports.default = require("./dist/StaticSiteTransformer").default; +export { default } from "./dist/StaticSiteTransformer.js"; diff --git a/packages/parcel-transformer-staticsite/meta.js b/packages/parcel-transformer-staticsite/meta.js index 9f08333d..eac137aa 100644 --- a/packages/parcel-transformer-staticsite/meta.js +++ b/packages/parcel-transformer-staticsite/meta.js @@ -1,2 +1,2 @@ // eslint-disable-next-line no-undef,@typescript-eslint/no-var-requires -exports.default = require("./dist/StaticSiteTransformer").default; +export { default } from "./dist/StaticSiteTransformer.js"; diff --git a/packages/parcel-transformer-staticsite/package.json b/packages/parcel-transformer-staticsite/package.json index 62caef9d..3cf0bf02 100644 --- a/packages/parcel-transformer-staticsite/package.json +++ b/packages/parcel-transformer-staticsite/package.json @@ -3,6 +3,7 @@ "version": "3.10.5", "private": true, "main": "./dist/StaticSiteTransformer.js", + "type": "module", "engines": { "parcel": "2.x" }, diff --git a/packages/parcel-transformer-staticsite/src/StaticSiteTransformer.ts b/packages/parcel-transformer-staticsite/src/StaticSiteTransformer.ts index 534dd642..a4487d2a 100644 --- a/packages/parcel-transformer-staticsite/src/StaticSiteTransformer.ts +++ b/packages/parcel-transformer-staticsite/src/StaticSiteTransformer.ts @@ -1,10 +1,10 @@ import * as path from "path"; import type { Transformer as TransformerOpts } from "@parcel/types"; import { Transformer } from "@parcel/plugin"; -import { transformSitemap } from "./sitemap-transformer"; -import { transformRobots } from "./robots-transformer"; -import { transformMd } from "./md-transformer"; -import { transformHtmlBody } from "./htmlbody-transformer"; +import { transformSitemap } from "./sitemap-transformer.js"; +import { transformRobots } from "./robots-transformer.js"; +import { transformMd } from "./md-transformer.js"; +import { transformHtmlBody } from "./htmlbody-transformer.js"; export type MdTrasformerConfig = { pkgVersion: string; diff --git a/packages/parcel-transformer-staticsite/src/date-sorter.spec.ts b/packages/parcel-transformer-staticsite/src/date-sorter.spec.ts index eb423143..437800b6 100644 --- a/packages/parcel-transformer-staticsite/src/date-sorter.spec.ts +++ b/packages/parcel-transformer-staticsite/src/date-sorter.spec.ts @@ -1,5 +1,5 @@ /* eslint-env jest */ -import { sortByDate } from "./date-sorter"; +import { sortByDate } from "./date-sorter.js"; describe("date-sorter", () => { test("sorts by the containing date", () => { diff --git a/packages/parcel-transformer-staticsite/src/htmlbody-transformer.ts b/packages/parcel-transformer-staticsite/src/htmlbody-transformer.ts index 86840eac..193434a3 100644 --- a/packages/parcel-transformer-staticsite/src/htmlbody-transformer.ts +++ b/packages/parcel-transformer-staticsite/src/htmlbody-transformer.ts @@ -1,6 +1,6 @@ import { compileFile } from "pug"; import { createTitle } from "@valotas/valotas-frontend"; -import { StaticSiteTransformerFn } from "./StaticSiteTransformer"; +import { StaticSiteTransformerFn } from "./StaticSiteTransformer.js"; function getString(obj: object, prop: string) { const value = (obj as any)[prop]; diff --git a/packages/parcel-transformer-staticsite/src/key-factory.spec.ts b/packages/parcel-transformer-staticsite/src/key-factory.spec.ts index d2989ac8..0b62d39e 100644 --- a/packages/parcel-transformer-staticsite/src/key-factory.spec.ts +++ b/packages/parcel-transformer-staticsite/src/key-factory.spec.ts @@ -1,6 +1,6 @@ /* eslint-env jest */ -import { computeKey } from "./key-factory"; +import { computeKey } from "./key-factory.js"; describe("key-factory", () => { test("returns the base name", () => { diff --git a/packages/parcel-transformer-staticsite/src/md-transformer.ts b/packages/parcel-transformer-staticsite/src/md-transformer.ts index a9ff2992..03e00561 100644 --- a/packages/parcel-transformer-staticsite/src/md-transformer.ts +++ b/packages/parcel-transformer-staticsite/src/md-transformer.ts @@ -1,9 +1,9 @@ import type { MutableAsset, PluginLogger } from "@parcel/types"; import { parse } from "@valotas/valotas-frontend"; -import { render } from "@valotas/valotas-frontend/dist/render"; -import { StaticSiteTransformerFn } from "./StaticSiteTransformer"; -import { createLazyDependency } from "./dep"; -import { computeKey } from "./key-factory"; +import { render } from "@valotas/valotas-frontend/dist/render.js"; +import { StaticSiteTransformerFn } from "./StaticSiteTransformer.js"; +import { createLazyDependency } from "./dep.js"; +import { computeKey } from "./key-factory.js"; export type MdTrasformerConfig = { pkgVersion: string; diff --git a/packages/parcel-transformer-staticsite/src/robots-transformer.ts b/packages/parcel-transformer-staticsite/src/robots-transformer.ts index 3c534d24..93e707d2 100644 --- a/packages/parcel-transformer-staticsite/src/robots-transformer.ts +++ b/packages/parcel-transformer-staticsite/src/robots-transformer.ts @@ -1,7 +1,7 @@ -import { createParallelDependency } from "./dep"; -import { computeKey } from "./key-factory"; -import { parseRobots } from "./robots"; -import { StaticSiteTransformerFn } from "./StaticSiteTransformer"; +import { createParallelDependency } from "./dep.js"; +import { computeKey } from "./key-factory.js"; +import { parseRobots } from "./robots.js"; +import { StaticSiteTransformerFn } from "./StaticSiteTransformer.js"; export const transformRobots: StaticSiteTransformerFn = async ({ asset }) => { const robotsContent = await asset.getCode(); diff --git a/packages/parcel-transformer-staticsite/src/robots.spec.ts b/packages/parcel-transformer-staticsite/src/robots.spec.ts index 43bb2826..8766665f 100644 --- a/packages/parcel-transformer-staticsite/src/robots.spec.ts +++ b/packages/parcel-transformer-staticsite/src/robots.spec.ts @@ -1,5 +1,5 @@ /* eslint-env jest */ -import { parseRobots } from "./robots"; +import { parseRobots } from "./robots.js"; describe("robots", () => { test("returns empty rules for empty content", () => { diff --git a/packages/parcel-transformer-staticsite/src/sitemap-transformer.spec.ts b/packages/parcel-transformer-staticsite/src/sitemap-transformer.spec.ts index 001a8638..9439cddb 100644 --- a/packages/parcel-transformer-staticsite/src/sitemap-transformer.spec.ts +++ b/packages/parcel-transformer-staticsite/src/sitemap-transformer.spec.ts @@ -1,5 +1,5 @@ /* eslint-env jest */ -import { _getAllTags } from "./sitemap-transformer"; +import { _getAllTags } from "./sitemap-transformer.js"; describe("sitemap-transformer", () => { describe("_getAllTags", () => { diff --git a/packages/parcel-transformer-staticsite/src/sitemap-transformer.ts b/packages/parcel-transformer-staticsite/src/sitemap-transformer.ts index 7edd52da..61be4f87 100644 --- a/packages/parcel-transformer-staticsite/src/sitemap-transformer.ts +++ b/packages/parcel-transformer-staticsite/src/sitemap-transformer.ts @@ -2,11 +2,11 @@ import * as path from "path"; import type { FileSystem } from "@parcel/fs"; import type { TransformerResult } from "@parcel/types"; import { parse } from "@valotas/valotas-frontend"; -import { parseSitemap } from "./sitemap"; -import { StaticSiteTransformerFn } from "./StaticSiteTransformer"; -import { sortByDate } from "./date-sorter"; -import { createParallelDependency } from "./dep"; -import { computeKey } from "./key-factory"; +import { parseSitemap } from "./sitemap.js"; +import { StaticSiteTransformerFn } from "./StaticSiteTransformer.js"; +import { sortByDate } from "./date-sorter.js"; +import { createParallelDependency } from "./dep.js"; +import { computeKey } from "./key-factory.js"; type MD = ReturnType & { key: string; specifier: string }; type MDMeta = Omit; diff --git a/packages/parcel-transformer-staticsite/src/sitiemap.spec.ts b/packages/parcel-transformer-staticsite/src/sitemap.spec.ts similarity index 95% rename from packages/parcel-transformer-staticsite/src/sitiemap.spec.ts rename to packages/parcel-transformer-staticsite/src/sitemap.spec.ts index 16b14ac5..a7738c83 100644 --- a/packages/parcel-transformer-staticsite/src/sitiemap.spec.ts +++ b/packages/parcel-transformer-staticsite/src/sitemap.spec.ts @@ -1,10 +1,12 @@ /* eslint-env jest */ import * as path from "path"; +import { fileURLToPath } from "node:url"; import { NodeFS } from "@parcel/fs"; -import { _parseSitemapContent } from "./sitemap"; +import { _parseSitemapContent } from "./sitemap.js"; const fs = new NodeFS(); +const __filename = fileURLToPath(import.meta.url); const filePath = path.resolve( __filename, "..", diff --git a/packages/parcel-transformer-staticsite/src/sitemap.ts b/packages/parcel-transformer-staticsite/src/sitemap.ts index 5794a328..a9d3b6a6 100644 --- a/packages/parcel-transformer-staticsite/src/sitemap.ts +++ b/packages/parcel-transformer-staticsite/src/sitemap.ts @@ -1,8 +1,10 @@ import * as path from "path"; -import { glob, isGlob, normalizeSeparators } from "@parcel/utils"; +import parcelUtils from "@parcel/utils"; import type { FileSystem } from "@parcel/fs"; import type { MutableAsset } from "@parcel/types"; -import { computeKey } from "./key-factory"; +import { computeKey } from "./key-factory.js"; + +const { glob, isGlob, normalizeSeparators } = parcelUtils; export type SitemapDependency = { key: string; diff --git a/packages/parcel-transformer-staticsite/tsconfig.json b/packages/parcel-transformer-staticsite/tsconfig.json index 7bab4335..67e857be 100644 --- a/packages/parcel-transformer-staticsite/tsconfig.json +++ b/packages/parcel-transformer-staticsite/tsconfig.json @@ -5,7 +5,7 @@ and https://parceljs.org/languages/typescript/ to see why some values have been chosen */ - "module": "CommonJS", + "module": "ES2020", "target": "es2020", "moduleResolution": "Node", "isolatedModules": true, diff --git a/packages/parcel-transformer-staticsite/txt.js b/packages/parcel-transformer-staticsite/txt.js index 9f08333d..eac137aa 100644 --- a/packages/parcel-transformer-staticsite/txt.js +++ b/packages/parcel-transformer-staticsite/txt.js @@ -1,2 +1,2 @@ // eslint-disable-next-line no-undef,@typescript-eslint/no-var-requires -exports.default = require("./dist/StaticSiteTransformer").default; +export { default } from "./dist/StaticSiteTransformer.js"; From 7c887ad7cdbd4d9270ea312641dcefed3fd096a1 Mon Sep 17 00:00:00 2001 From: Georgios Valotasios Date: Sat, 29 Jun 2024 14:07:39 +0200 Subject: [PATCH 3/3] fix: remove node-fetch dependency --- package-lock.json | 95 ++++++++++++++++++++++------------ packages/frontend/package.json | 1 - 2 files changed, 63 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3d8829fc..13647a54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21255,9 +21255,8 @@ }, "node_modules/eslint-config-prettier": { "version": "9.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", - "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, + "license": "MIT", "bin": { "eslint-config-prettier": "bin/cli.js" }, @@ -27135,6 +27134,7 @@ }, "node_modules/node-fetch": { "version": "2.6.7", + "dev": true, "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" @@ -27153,14 +27153,17 @@ }, "node_modules/node-fetch/node_modules/tr46": { "version": "0.0.3", + "dev": true, "license": "MIT" }, "node_modules/node-fetch/node_modules/webidl-conversions": { "version": "3.0.1", + "dev": true, "license": "BSD-2-Clause" }, "node_modules/node-fetch/node_modules/whatwg-url": { "version": "5.0.0", + "dev": true, "license": "MIT", "dependencies": { "tr46": "~0.0.3", @@ -34164,7 +34167,6 @@ "@types/prismjs": "^1.26.0", "date-fns": "^2.28.0", "moment": "^2.29.1", - "node-fetch": "^2.6.7", "prismjs": "^1.29.0", "react": "^17.0.2", "react-dom": "^17.0.2", @@ -34189,8 +34191,9 @@ }, "packages/frontend/node_modules/@types/react-dom": { "version": "17.0.25", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.25.tgz", + "integrity": "sha512-urx7A7UxkZQmThYA4So0NelOVjx3V4rNFVJwp0WZlbIK5eM4rNJDiN3R/E9ix0MBh6kAEojk/9YL+Te6D9zHNA==", "dev": true, - "license": "MIT", "dependencies": { "@types/react": "^17" } @@ -34208,16 +34211,18 @@ }, "packages/parcel-namer-staticsite/node_modules/brace-expansion": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, - "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } }, "packages/parcel-namer-staticsite/node_modules/foreground-child": { "version": "3.2.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", + "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", "dev": true, - "license": "ISC", "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" @@ -34231,8 +34236,9 @@ }, "packages/parcel-namer-staticsite/node_modules/glob": { "version": "10.4.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", + "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", "dev": true, - "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^3.1.2", @@ -34253,8 +34259,9 @@ }, "packages/parcel-namer-staticsite/node_modules/minimatch": { "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, - "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -34267,16 +34274,18 @@ }, "packages/parcel-namer-staticsite/node_modules/minipass": { "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "dev": true, - "license": "ISC", "engines": { "node": ">=16 || 14 >=14.17" } }, "packages/parcel-namer-staticsite/node_modules/rimraf": { "version": "5.0.7", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.7.tgz", + "integrity": "sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==", "dev": true, - "license": "ISC", "dependencies": { "glob": "^10.3.7" }, @@ -34292,8 +34301,9 @@ }, "packages/parcel-namer-staticsite/node_modules/signal-exit": { "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true, - "license": "ISC", "engines": { "node": ">=14" }, @@ -34320,16 +34330,18 @@ }, "packages/parcel-reporter-staticsite/node_modules/brace-expansion": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, - "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } }, "packages/parcel-reporter-staticsite/node_modules/foreground-child": { "version": "3.2.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", + "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", "dev": true, - "license": "ISC", "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" @@ -34343,8 +34355,9 @@ }, "packages/parcel-reporter-staticsite/node_modules/glob": { "version": "10.4.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", + "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", "dev": true, - "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^3.1.2", @@ -34365,8 +34378,9 @@ }, "packages/parcel-reporter-staticsite/node_modules/minimatch": { "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, - "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -34379,16 +34393,18 @@ }, "packages/parcel-reporter-staticsite/node_modules/minipass": { "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "dev": true, - "license": "ISC", "engines": { "node": ">=16 || 14 >=14.17" } }, "packages/parcel-reporter-staticsite/node_modules/rimraf": { "version": "5.0.7", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.7.tgz", + "integrity": "sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==", "dev": true, - "license": "ISC", "dependencies": { "glob": "^10.3.7" }, @@ -34404,8 +34420,9 @@ }, "packages/parcel-reporter-staticsite/node_modules/signal-exit": { "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true, - "license": "ISC", "engines": { "node": ">=14" }, @@ -34536,16 +34553,18 @@ }, "packages/parcel-transformer-staticsite/node_modules/brace-expansion": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, - "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } }, "packages/parcel-transformer-staticsite/node_modules/foreground-child": { "version": "3.2.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", + "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", "dev": true, - "license": "ISC", "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" @@ -34559,8 +34578,9 @@ }, "packages/parcel-transformer-staticsite/node_modules/glob": { "version": "10.4.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", + "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", "dev": true, - "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^3.1.2", @@ -34581,8 +34601,9 @@ }, "packages/parcel-transformer-staticsite/node_modules/minimatch": { "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, - "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -34595,16 +34616,18 @@ }, "packages/parcel-transformer-staticsite/node_modules/minipass": { "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "dev": true, - "license": "ISC", "engines": { "node": ">=16 || 14 >=14.17" } }, "packages/parcel-transformer-staticsite/node_modules/rimraf": { "version": "5.0.7", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.7.tgz", + "integrity": "sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==", "dev": true, - "license": "ISC", "dependencies": { "glob": "^10.3.7" }, @@ -34620,8 +34643,9 @@ }, "packages/parcel-transformer-staticsite/node_modules/signal-exit": { "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true, - "license": "ISC", "engines": { "node": ">=14" }, @@ -34643,16 +34667,18 @@ }, "packages/web/node_modules/brace-expansion": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, - "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } }, "packages/web/node_modules/foreground-child": { "version": "3.2.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", + "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", "dev": true, - "license": "ISC", "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" @@ -34666,8 +34692,9 @@ }, "packages/web/node_modules/glob": { "version": "10.4.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", + "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", "dev": true, - "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^3.1.2", @@ -34688,8 +34715,9 @@ }, "packages/web/node_modules/minimatch": { "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, - "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -34702,16 +34730,18 @@ }, "packages/web/node_modules/minipass": { "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "dev": true, - "license": "ISC", "engines": { "node": ">=16 || 14 >=14.17" } }, "packages/web/node_modules/rimraf": { "version": "5.0.7", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.7.tgz", + "integrity": "sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==", "dev": true, - "license": "ISC", "dependencies": { "glob": "^10.3.7" }, @@ -34727,8 +34757,9 @@ }, "packages/web/node_modules/signal-exit": { "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true, - "license": "ISC", "engines": { "node": ">=14" }, diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 4b5ad410..8b1e4228 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -27,7 +27,6 @@ "@types/prismjs": "^1.26.0", "date-fns": "^2.28.0", "moment": "^2.29.1", - "node-fetch": "^2.6.7", "prismjs": "^1.29.0", "react": "^17.0.2", "react-dom": "^17.0.2",