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

refactor: simplify build system #26

Merged
merged 9 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"clsx",
"Declarators",
"ecma",
"eprt",
"eslintrc",
"estree",
"linebreak",
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: npm
node-version: 20
node-version: 22

- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint:ci
# allow eslint to fail because not all plugins are compatible with eslint v9 yet
continue-on-error: true

- name: Typecheck
run: npm run typecheck
Expand Down Expand Up @@ -51,7 +49,7 @@ jobs:
node:
- 18
- 20
- 21
- 22
os:
- ubuntu-latest
- windows-latest
Expand Down
14 changes: 8 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
"configurations": [
{
"args": [
"run",
"${relativeFileDirname}/${fileBasenameNoExtension}"
"--test",
"--import",
"tsx",
"${relativeFileDirname}/${fileBasename}"
],
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"name": "debug current test file",
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"request": "launch",
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"smartStep": true,
"type": "node"
},
{
"args": [
"run",
"${relativeFileDirname}/${fileBasenameNoExtension}"
"--test",
"--import",
"tsx",
"${relativeFileDirname}/${fileBasename}"
],
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"name": "debug current test file with node internals",
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"request": "launch",
"skipFiles": [],
"smartStep": true,
Expand Down
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
"typescript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.importModuleSpecifierEnding": "js",
"typescript.preferences.useAliasesForRenames": true,
"typescript.preferences.autoImportFileExcludePatterns": [
"@types/node/test.d.ts"
],


// Markdown
"[markdown]": {
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
Expand Down
14 changes: 14 additions & 0 deletions build/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { writeFile } from "fs/promises";
import { $ } from "readable-tailwind:build:utils.js";

const esmDir = "lib/esm"
const cjsDir = "lib/cjs"

await $`npx tsc --module preserve --project tsconfig.build.json --outDir ${esmDir}`
await $`npx tsc-alias --outDir ${esmDir}`
await writeFile(`${esmDir}/package.json`, JSON.stringify({ type: "module" }), "utf-8")

await $`npx tsc --module commonjs --moduleResolution node --project tsconfig.build.json --verbatimModuleSyntax false --outDir ${cjsDir}`
await $`npx tsc-alias --outDir ${cjsDir}`
await writeFile(`${cjsDir}/package.json`, JSON.stringify({ type: "commonjs" }), "utf-8")

16 changes: 16 additions & 0 deletions build/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { exec } from 'node:child_process'

export async function $(
command: TemplateStringsArray,
...values: (boolean | number | string)[]
): Promise<string | Buffer> {
return new Promise((resolve, reject) => {
exec(String.raw(command, ...values), (error, stdout, stderr) => {
if (error && stderr) {
console.error(error, stderr)
reject(error)
}
resolve(stdout || stderr)
})
})
}
1 change: 1 addition & 0 deletions docs/parsers/html.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import eslintPluginReadableTailwind from "eslint-plugin-readable-tailwind";

import eslintParserHTML from "@html-eslint/parser";


export default [
{
languageOptions: {
Expand Down
1 change: 1 addition & 0 deletions docs/parsers/jsx.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Read more about the new [ESLint flat config format](https://eslint.org/docs/late
// eslint.config.js
import eslintPluginReadableTailwind from "eslint-plugin-readable-tailwind";


export default [
{
languageOptions: {
Expand Down
1 change: 1 addition & 0 deletions docs/parsers/svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Read more about the new [ESLint flat config format](https://eslint.org/docs/late
import eslintPluginReadableTailwind from "eslint-plugin-readable-tailwind";
import eslintParserSvelte from "svelte-eslint-parser";


export default [
{
languageOptions: {
Expand Down
1 change: 1 addition & 0 deletions docs/parsers/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Read more about the new [ESLint flat config format](https://eslint.org/docs/late
import eslintPluginReadableTailwind from "eslint-plugin-readable-tailwind";
import eslintParserVue from "vue-eslint-parser";


export default [
{
languageOptions: {
Expand Down
15 changes: 13 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import sharedConfig from "@schoero/configs/eslint";
import { ignore, imports, json, markdown, typescript, yaml } from "@schoero/configs/eslint";


export default [
...sharedConfig,
...ignore,
...imports,
...json,
...markdown,
...typescript,
...yaml,
{
files: ["**/*.test.{js,jsx,cjs,mjs,ts,tsx}", "**/*.test-d.{ts,tsx}"],
rules: {
Expand All @@ -11,5 +16,11 @@ export default [
"eslint-plugin-typescript/no-useless-template-literals": "off",
"eslint-plugin-vitest/expect-expect": "off"
}
},
{
files: ["**/*.test.ts"],
rules: {
"eslint-plugin-typescript/no-floating-promises": "off"
}
}
];
Loading