From 20dacf59eecf188f6cec91c8cafd5af38e57b89c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 6 Sep 2023 21:54:26 +0200 Subject: [PATCH] feat: move to ESM --- .eslintrc.js => .eslintrc.cjs | 0 .eslintrc.repo.js => .eslintrc.repo.cjs | 2 +- cypress/{.eslintrc.js => .eslintrc.cjs} | 0 mocks/index.js | 4 ++-- package.json | 5 +++-- postcss.config.js => postcss.config.cjs | 0 remix.config.js | 4 ++-- remix.init/index.js | 2 +- tsconfig.json | 2 +- 9 files changed, 10 insertions(+), 9 deletions(-) rename .eslintrc.js => .eslintrc.cjs (100%) rename .eslintrc.repo.js => .eslintrc.repo.cjs (96%) rename cypress/{.eslintrc.js => .eslintrc.cjs} (100%) rename postcss.config.js => postcss.config.cjs (100%) diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/.eslintrc.repo.js b/.eslintrc.repo.cjs similarity index 96% rename from .eslintrc.repo.js rename to .eslintrc.repo.cjs index 67f48962..a3796fa2 100644 --- a/.eslintrc.repo.js +++ b/.eslintrc.repo.cjs @@ -6,7 +6,7 @@ const WARN = 1; /** @type {import('eslint').Linter.Config} */ module.exports = { extends: [ - "./.eslintrc.js", + "./.eslintrc.cjs", "@remix-run/eslint-config/internal", "plugin:markdown/recommended", ], diff --git a/cypress/.eslintrc.js b/cypress/.eslintrc.cjs similarity index 100% rename from cypress/.eslintrc.js rename to cypress/.eslintrc.cjs diff --git a/mocks/index.js b/mocks/index.js index 41246682..9c4e4a7e 100644 --- a/mocks/index.js +++ b/mocks/index.js @@ -1,5 +1,5 @@ -const { rest } = require("msw"); -const { setupServer } = require("msw/node"); +import { rest } from "msw"; +import { setupServer } from "msw/node"; // put one-off handlers that don't really need an entire file to themselves here const miscHandlers = [ diff --git a/package.json b/package.json index 65a82e4a..1dc70ba3 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "blues-stack-template", "private": true, "sideEffects": false, + "type": "module", "scripts": { "build": "run-s build:*", "build:remix": "remix build", @@ -13,7 +14,7 @@ "format": "prettier --write .", "format:repo": "npm run format && npm run lint:repo -- --fix", "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .", - "lint:repo": "npm run lint -- --config ./.eslintrc.repo.js", + "lint:repo": "npm run lint -- --config ./.eslintrc.repo.cjs", "setup": "prisma generate && prisma migrate deploy && prisma db seed", "start": "cross-env NODE_ENV=production node ./build/server.js", "start:mocks": "cross-env NODE_ENV=production node --require ./mocks --require dotenv/config ./build/server.js", @@ -98,6 +99,6 @@ "node": ">=14.0.0" }, "prisma": { - "seed": "ts-node --require tsconfig-paths/register prisma/seed.ts" + "seed": "ts-node --esm --require tsconfig-paths/register prisma/seed.ts" } } diff --git a/postcss.config.js b/postcss.config.cjs similarity index 100% rename from postcss.config.js rename to postcss.config.cjs diff --git a/remix.config.js b/remix.config.js index 5b743123..feda42dd 100644 --- a/remix.config.js +++ b/remix.config.js @@ -1,5 +1,5 @@ /** @type {import('@remix-run/dev').AppConfig} */ -module.exports = { +export default { cacheDirectory: "./node_modules/.cache/remix", future: { v2_dev: true, @@ -11,6 +11,6 @@ module.exports = { }, ignoredRouteFiles: ["**/.*", "**/*.test.{js,jsx,ts,tsx}"], postcss: true, - serverModuleFormat: "cjs", + serverModuleFormat: "esm", tailwind: true, }; diff --git a/remix.init/index.js b/remix.init/index.js index 09309571..a539dd36 100644 --- a/remix.init/index.js +++ b/remix.init/index.js @@ -260,7 +260,7 @@ const main = async ({ isTypeScript, packageManager, rootDirectory }) => { fs.rm(path.join(rootDirectory, ".github", "workflows", "no-response.yml")), fs.rm(path.join(rootDirectory, ".github", "dependabot.yml")), fs.rm(path.join(rootDirectory, ".github", "PULL_REQUEST_TEMPLATE.md")), - fs.rm(path.join(rootDirectory, ".eslintrc.repo.js")), + fs.rm(path.join(rootDirectory, ".eslintrc.repo.cjs")), fs.rm(path.join(rootDirectory, "LICENSE.md")), ]; diff --git a/tsconfig.json b/tsconfig.json index 9bacef83..76e38a03 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "isolatedModules": true, "esModuleInterop": true, "jsx": "react-jsx", - "module": "CommonJS", + "module": "ES2020", "moduleResolution": "node", "resolveJsonModule": true, "target": "ES2019",