From ebe11372a1b507a6af60b4da8f4dcf309851e0d0 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 27 Feb 2024 18:17:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Move=20the=20full=20wor?= =?UTF-8?q?kspace=20to=20ES=20Module=20(#502)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/tame-news-live.md | 7 +++++++ README.md | 1 + apps/www/{.eslintrc.js => .eslintrc.cjs} | 0 apps/www/{env.mjs => env.js} | 0 ...sitemap.config.mjs => next-sitemap.config.js} | 0 apps/www/{next.config.mjs => next.config.js} | 2 +- apps/www/package.json | 3 ++- .../{postcss.config.js => postcss.config.cjs} | 0 .../{tailwind.config.mjs => tailwind.config.js} | 0 apps/www/tsconfig.json | 3 +-- package.json | 11 +++++++---- .../{.eslintrc.js => .eslintrc.cjs} | 0 packages/eslint-config-custom/index.cjs | 3 +++ packages/eslint-config-custom/index.js | 3 --- packages/eslint-config-custom/package.json | 3 ++- .../usehooks-ts/{.eslintrc.js => .eslintrc.cjs} | 0 packages/usehooks-ts/README.md | 1 + packages/usehooks-ts/package.json | 15 +++++++-------- .../{vitest.config.mts => vitest.config.ts} | 0 pnpm-lock.yaml | 16 ++++++++-------- scripts/{copyHooks.mjs => copyHooks.js} | 2 +- scripts/{updateReadme.mjs => updateReadme.js} | 2 +- ...ateTestingIssue.mjs => updateTestingIssue.js} | 2 +- scripts/{utils.mjs => utils.js} | 0 .../config.ts => turbo/generators/config.cts | 14 ++++++++------ .../generators/templates/hook/hook.demo.tsx.hbs | 0 .../generators/templates/hook/hook.mdx.hbs | 0 .../generators/templates/hook/hook.test.ts.hbs | 0 .../generators/templates/hook/hook.ts.hbs | 0 .../generators/templates/hook/index.ts.hbs | 0 .../generators/templates/index.ts.hbs | 0 31 files changed, 51 insertions(+), 37 deletions(-) create mode 100644 .changeset/tame-news-live.md rename apps/www/{.eslintrc.js => .eslintrc.cjs} (100%) rename apps/www/{env.mjs => env.js} (100%) rename apps/www/{next-sitemap.config.mjs => next-sitemap.config.js} (100%) rename apps/www/{next.config.mjs => next.config.js} (82%) rename apps/www/{postcss.config.js => postcss.config.cjs} (100%) rename apps/www/{tailwind.config.mjs => tailwind.config.js} (100%) rename packages/eslint-config-custom/{.eslintrc.js => .eslintrc.cjs} (100%) create mode 100644 packages/eslint-config-custom/index.cjs delete mode 100644 packages/eslint-config-custom/index.js rename packages/usehooks-ts/{.eslintrc.js => .eslintrc.cjs} (100%) rename packages/usehooks-ts/{vitest.config.mts => vitest.config.ts} (100%) rename scripts/{copyHooks.mjs => copyHooks.js} (98%) rename scripts/{updateReadme.mjs => updateReadme.js} (99%) rename scripts/{updateTestingIssue.mjs => updateTestingIssue.js} (98%) rename scripts/{utils.mjs => utils.js} (100%) rename packages/usehooks-ts/turbo/generators/config.ts => turbo/generators/config.cts (70%) rename {packages/usehooks-ts/turbo => turbo}/generators/templates/hook/hook.demo.tsx.hbs (100%) rename {packages/usehooks-ts/turbo => turbo}/generators/templates/hook/hook.mdx.hbs (100%) rename {packages/usehooks-ts/turbo => turbo}/generators/templates/hook/hook.test.ts.hbs (100%) rename {packages/usehooks-ts/turbo => turbo}/generators/templates/hook/hook.ts.hbs (100%) rename {packages/usehooks-ts/turbo => turbo}/generators/templates/hook/index.ts.hbs (100%) rename {packages/usehooks-ts/turbo => turbo}/generators/templates/index.ts.hbs (100%) diff --git a/.changeset/tame-news-live.md b/.changeset/tame-news-live.md new file mode 100644 index 00000000..1365fe66 --- /dev/null +++ b/.changeset/tame-news-live.md @@ -0,0 +1,7 @@ +--- +"eslint-config-custom": major +"usehooks-ts": major +"www": major +--- + +Move the full workspace into ES Module diff --git a/README.md b/README.md index 79c27d03..8b83ad45 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ ![npm bundle size](https://img.shields.io/bundlephobia/minzip/usehooks-ts) ![npm](https://img.shields.io/npm/v/usehooks-ts) [![All Contributors](https://img.shields.io/badge/all_contributors-234-orange.svg?style=flat-square)](#contributors-) +
diff --git a/apps/www/.eslintrc.js b/apps/www/.eslintrc.cjs similarity index 100% rename from apps/www/.eslintrc.js rename to apps/www/.eslintrc.cjs diff --git a/apps/www/env.mjs b/apps/www/env.js similarity index 100% rename from apps/www/env.mjs rename to apps/www/env.js diff --git a/apps/www/next-sitemap.config.mjs b/apps/www/next-sitemap.config.js similarity index 100% rename from apps/www/next-sitemap.config.mjs rename to apps/www/next-sitemap.config.js diff --git a/apps/www/next.config.mjs b/apps/www/next.config.js similarity index 82% rename from apps/www/next.config.mjs rename to apps/www/next.config.js index 21920279..794eb4a0 100644 --- a/apps/www/next.config.mjs +++ b/apps/www/next.config.js @@ -1,4 +1,4 @@ -import './env.mjs' +import './env.js' /** @type {import('next').NextConfig} */ const nextConfig = {} diff --git a/apps/www/package.json b/apps/www/package.json index 995e9284..c448a86c 100644 --- a/apps/www/package.json +++ b/apps/www/package.json @@ -2,10 +2,11 @@ "name": "www", "version": "0.2.2", "private": true, + "type": "module", "scripts": { "dev": "next dev", "build": "pnpm generate && next build && pnpm generate-sitemap", - "generate-sitemap": "rimraf public/sitemap.xml public/robots.txt && next-sitemap --config ./next-sitemap.config.mjs", + "generate-sitemap": "rimraf public/sitemap.xml public/robots.txt && next-sitemap --config ./next-sitemap.config.js", "start": "next start", "lint": "next lint && tsc --noEmit", "clean": "rimraf *.tsbuildinfo .next generated .turbo", diff --git a/apps/www/postcss.config.js b/apps/www/postcss.config.cjs similarity index 100% rename from apps/www/postcss.config.js rename to apps/www/postcss.config.cjs diff --git a/apps/www/tailwind.config.mjs b/apps/www/tailwind.config.js similarity index 100% rename from apps/www/tailwind.config.mjs rename to apps/www/tailwind.config.js diff --git a/apps/www/tsconfig.json b/apps/www/tsconfig.json index 3ffaff55..3548bd55 100644 --- a/apps/www/tsconfig.json +++ b/apps/www/tsconfig.json @@ -28,8 +28,7 @@ "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", - "**/*.js", - "**/*.mjs" + "**/*.js" ], "exclude": ["node_modules"] } diff --git a/package.json b/package.json index 041b6cb1..7748ff34 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "author": "Julien CARON ", "homepage": "https://usehooks-ts.com", "module": "true", + "type": "module", "keywords": [ "typescript", "react", @@ -19,10 +20,10 @@ "clean": "rimraf .turbo && turbo run clean", "format": "prettier --write \"**/*.{json,md,mdx,css,scss,yaml,yml}\"", "lint": "turbo run lint", - "update-testing-issue": "zx ./scripts/updateTestingIssue.mjs", - "update-readme": "zx ./scripts/updateReadme.mjs", - "copy-hooks": "rimraf -rf ./apps/www/generated && zx ./scripts/copyHooks.mjs", - "gen-hook": "turbo gen hook && pnpm format", + "update-testing-issue": "zx ./scripts/updateTestingIssue.js", + "update-readme": "zx ./scripts/updateReadme.js", + "copy-hooks": "rimraf ./apps/www/generated && zx ./scripts/copyHooks.js", + "gen-hook": "turbo gen hook --config \"turbo/generators/config.cts\" && pnpm format", "changeset": "npx changeset", "changeset-version": "npx changeset version", "changeset-publish": "npx changeset publish" @@ -32,7 +33,9 @@ }, "devDependencies": { "@changesets/cli": "^2.27.1", + "@turbo/gen": "^1.12.4", "all-contributors-cli": "^6.26.1", + "date-fns": "^3.3.1", "eslint": "^8.56.0", "prettier": "^3.2.5", "rimraf": "^5.0.5", diff --git a/packages/eslint-config-custom/.eslintrc.js b/packages/eslint-config-custom/.eslintrc.cjs similarity index 100% rename from packages/eslint-config-custom/.eslintrc.js rename to packages/eslint-config-custom/.eslintrc.cjs diff --git a/packages/eslint-config-custom/index.cjs b/packages/eslint-config-custom/index.cjs new file mode 100644 index 00000000..9bedd79e --- /dev/null +++ b/packages/eslint-config-custom/index.cjs @@ -0,0 +1,3 @@ +const eslintrc = require('./.eslintrc.cjs') + +module.exports = eslintrc diff --git a/packages/eslint-config-custom/index.js b/packages/eslint-config-custom/index.js deleted file mode 100644 index 91e34557..00000000 --- a/packages/eslint-config-custom/index.js +++ /dev/null @@ -1,3 +0,0 @@ -const eslintrc = require('./.eslintrc.js') - -module.exports = eslintrc diff --git a/packages/eslint-config-custom/package.json b/packages/eslint-config-custom/package.json index ae9f3ae1..40fc739e 100644 --- a/packages/eslint-config-custom/package.json +++ b/packages/eslint-config-custom/package.json @@ -3,9 +3,10 @@ "private": true, "version": "1.2.0", "description": "Base configuration for Eslint", - "main": "index.js", + "main": "index.cjs", "author": "Julien CARON ", "license": "MIT", + "type": "module", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.0.2", "@typescript-eslint/parser": "^7.0.2", diff --git a/packages/usehooks-ts/.eslintrc.js b/packages/usehooks-ts/.eslintrc.cjs similarity index 100% rename from packages/usehooks-ts/.eslintrc.js rename to packages/usehooks-ts/.eslintrc.cjs diff --git a/packages/usehooks-ts/README.md b/packages/usehooks-ts/README.md index 79c27d03..8b83ad45 100644 --- a/packages/usehooks-ts/README.md +++ b/packages/usehooks-ts/README.md @@ -18,6 +18,7 @@ ![npm bundle size](https://img.shields.io/bundlephobia/minzip/usehooks-ts) ![npm](https://img.shields.io/npm/v/usehooks-ts) [![All Contributors](https://img.shields.io/badge/all_contributors-234-orange.svg?style=flat-square)](#contributors-) +
diff --git a/packages/usehooks-ts/package.json b/packages/usehooks-ts/package.json index c7f53957..2f871542 100644 --- a/packages/usehooks-ts/package.json +++ b/packages/usehooks-ts/package.json @@ -11,34 +11,33 @@ "hooks" ], "license": "MIT", - "main": "./dist/index.js", - "module": "./dist/index.mjs", + "type": "module", + "main": "./dist/index.cjs", + "module": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.js", - "import": "./dist/index.mjs", + "require": "./dist/index.cjs", + "import": "./dist/index.js", "types": "./dist/index.d.ts" } }, "sideEffects": false, "scripts": { - "build": "tsup && rm ./dist/index.d.mts", + "build": "tsup && rimraf ./dist/index.d.cts", "dev": "tsup --watch", "test": "vitest run", "test:watch": "vitest", - "clean": "rimraf -rf ./dist .turbo *.tsbuildinfo", + "clean": "rimraf dist .turbo *.tsbuildinfo", "lint": "eslint './src/**/*.{ts,tsx}' && tsc --noEmit" }, "devDependencies": { "@juggle/resize-observer": "^3.4.0", "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.1", - "@turbo/gen": "^1.12.4", "@types/lodash.debounce": "^4.0.9", "@types/node": "^20.11.19", "@types/react": "18.2.57", - "date-fns": "^3.3.1", "eslint-config-custom": "workspace:*", "eslint-plugin-jsdoc": "^48.1.0", "eslint-plugin-tree-shaking": "^1.12.1", diff --git a/packages/usehooks-ts/vitest.config.mts b/packages/usehooks-ts/vitest.config.ts similarity index 100% rename from packages/usehooks-ts/vitest.config.mts rename to packages/usehooks-ts/vitest.config.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99318f09..618fda58 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,9 +14,15 @@ importers: '@changesets/cli': specifier: ^2.27.1 version: 2.27.1 + '@turbo/gen': + specifier: ^1.12.4 + version: 1.12.4(@types/node@20.11.19)(typescript@5.3.3) all-contributors-cli: specifier: ^6.26.1 version: 6.26.1 + date-fns: + specifier: ^3.3.1 + version: 3.3.1 eslint: specifier: ^8.56.0 version: 8.56.0 @@ -184,9 +190,6 @@ importers: '@testing-library/react': specifier: ^14.2.1 version: 14.2.1(react-dom@18.2.0)(react@18.2.0) - '@turbo/gen': - specifier: ^1.12.4 - version: 1.12.4(@types/node@20.11.19)(typescript@5.3.3) '@types/lodash.debounce': specifier: ^4.0.9 version: 4.0.9 @@ -196,9 +199,6 @@ importers: '@types/react': specifier: 18.2.57 version: 18.2.57 - date-fns: - specifier: ^3.3.1 - version: 3.3.1 eslint-config-custom: specifier: workspace:* version: link:../eslint-config-custom @@ -1751,7 +1751,7 @@ packages: js-yaml: 4.1.0 ora: 4.1.1 rimraf: 3.0.2 - semver: 7.5.4 + semver: 7.6.0 update-check: 1.5.4 dev: true @@ -2642,7 +2642,7 @@ packages: /builtins@5.0.1: resolution: {integrity: sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==} dependencies: - semver: 7.5.4 + semver: 7.6.0 dev: true /bundle-require@4.0.2(esbuild@0.19.12): diff --git a/scripts/copyHooks.mjs b/scripts/copyHooks.js similarity index 98% rename from scripts/copyHooks.mjs rename to scripts/copyHooks.js index 9bf96d87..2847f23a 100644 --- a/scripts/copyHooks.mjs +++ b/scripts/copyHooks.js @@ -2,7 +2,7 @@ import { path, fs } from 'zx' -import { isHookFile } from './utils.mjs' +import { isHookFile } from './utils.js' const hooksDir = path.resolve('./packages/usehooks-ts/src') const outputDir = path.resolve('./apps/www/generated') diff --git a/scripts/updateReadme.mjs b/scripts/updateReadme.js similarity index 99% rename from scripts/updateReadme.mjs rename to scripts/updateReadme.js index 9824afe8..8a34fed3 100644 --- a/scripts/updateReadme.mjs +++ b/scripts/updateReadme.js @@ -2,7 +2,7 @@ import { path, fs } from 'zx' -import { camelToKebabCase, isDemoFile, isHookFile } from './utils.mjs' +import { camelToKebabCase, isDemoFile, isHookFile } from './utils.js' //////////////////////////////////////////////////////////////////////// // 1. Imperative script that updates the hook list in the README file. diff --git a/scripts/updateTestingIssue.mjs b/scripts/updateTestingIssue.js similarity index 98% rename from scripts/updateTestingIssue.mjs rename to scripts/updateTestingIssue.js index 6ee6471e..9ab92002 100644 --- a/scripts/updateTestingIssue.mjs +++ b/scripts/updateTestingIssue.js @@ -2,7 +2,7 @@ import { path, fs, $ } from 'zx' -import { isHookFile, isTestFile } from './utils.mjs' +import { isHookFile, isTestFile } from './utils.js' const GITHUB_REPO = `juliencrn/usehooks-ts` const GITHUB_ISSUE_PATH = `${GITHUB_REPO}/issues/423` diff --git a/scripts/utils.mjs b/scripts/utils.js similarity index 100% rename from scripts/utils.mjs rename to scripts/utils.js diff --git a/packages/usehooks-ts/turbo/generators/config.ts b/turbo/generators/config.cts similarity index 70% rename from packages/usehooks-ts/turbo/generators/config.ts rename to turbo/generators/config.cts index ea76e864..9d26cf72 100644 --- a/packages/usehooks-ts/turbo/generators/config.ts +++ b/turbo/generators/config.cts @@ -1,7 +1,9 @@ import type { PlopTypes } from '@turbo/gen' import { format } from 'date-fns' +import path from 'path' export default function generator(plop: PlopTypes.NodePlopAPI): void { + const usehooksSrcPath = path.resolve('packages/usehooks-ts/src') plop.setGenerator('hook', { description: 'Create a post', prompts: [ @@ -15,14 +17,14 @@ export default function generator(plop: PlopTypes.NodePlopAPI): void { // Create the hook file itself { type: 'add', - path: 'src/{{camelCase name}}/{{camelCase name}}.ts', + path: usehooksSrcPath + '/{{camelCase name}}/{{camelCase name}}.ts', templateFile: 'templates/hook/hook.ts.hbs', }, // Create the test file { type: 'add', - path: 'src/{{camelCase name}}/{{camelCase name}}.test.ts', + path: usehooksSrcPath + '/{{camelCase name}}/{{camelCase name}}.test.ts', templateFile: 'templates/hook/hook.test.ts.hbs', }, @@ -32,28 +34,28 @@ export default function generator(plop: PlopTypes.NodePlopAPI): void { date: format(new Date(), 'yyyy-MM-dd'), }, type: 'add', - path: 'src/{{camelCase name}}/{{camelCase name}}.md', + path: usehooksSrcPath + '/{{camelCase name}}/{{camelCase name}}.md', templateFile: 'templates/hook/hook.mdx.hbs', }, // Create the demo react component file { type: 'add', - path: 'src/{{camelCase name}}/{{camelCase name}}.demo.tsx', + path: usehooksSrcPath + '/{{camelCase name}}/{{camelCase name}}.demo.tsx', templateFile: 'templates/hook/hook.demo.tsx.hbs', }, // Create the hook's index file { type: 'add', - path: 'src/{{camelCase name}}/index.ts', + path: usehooksSrcPath + '/{{camelCase name}}/index.ts', templateFile: 'templates/hook/index.ts.hbs', }, // Update the global hooks index file { type: 'append', - path: 'src/index.ts', + path: usehooksSrcPath + '/index.ts', templateFile: 'templates/index.ts.hbs', }, ], diff --git a/packages/usehooks-ts/turbo/generators/templates/hook/hook.demo.tsx.hbs b/turbo/generators/templates/hook/hook.demo.tsx.hbs similarity index 100% rename from packages/usehooks-ts/turbo/generators/templates/hook/hook.demo.tsx.hbs rename to turbo/generators/templates/hook/hook.demo.tsx.hbs diff --git a/packages/usehooks-ts/turbo/generators/templates/hook/hook.mdx.hbs b/turbo/generators/templates/hook/hook.mdx.hbs similarity index 100% rename from packages/usehooks-ts/turbo/generators/templates/hook/hook.mdx.hbs rename to turbo/generators/templates/hook/hook.mdx.hbs diff --git a/packages/usehooks-ts/turbo/generators/templates/hook/hook.test.ts.hbs b/turbo/generators/templates/hook/hook.test.ts.hbs similarity index 100% rename from packages/usehooks-ts/turbo/generators/templates/hook/hook.test.ts.hbs rename to turbo/generators/templates/hook/hook.test.ts.hbs diff --git a/packages/usehooks-ts/turbo/generators/templates/hook/hook.ts.hbs b/turbo/generators/templates/hook/hook.ts.hbs similarity index 100% rename from packages/usehooks-ts/turbo/generators/templates/hook/hook.ts.hbs rename to turbo/generators/templates/hook/hook.ts.hbs diff --git a/packages/usehooks-ts/turbo/generators/templates/hook/index.ts.hbs b/turbo/generators/templates/hook/index.ts.hbs similarity index 100% rename from packages/usehooks-ts/turbo/generators/templates/hook/index.ts.hbs rename to turbo/generators/templates/hook/index.ts.hbs diff --git a/packages/usehooks-ts/turbo/generators/templates/index.ts.hbs b/turbo/generators/templates/index.ts.hbs similarity index 100% rename from packages/usehooks-ts/turbo/generators/templates/index.ts.hbs rename to turbo/generators/templates/index.ts.hbs