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: remove tsup, replace with esbuild + dts with tsc #307

Merged
merged 2 commits into from
Oct 12, 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
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ jobs:
- name: Build Library
run: pnpm build:lib

- name: validate "Are the Types Wrong"
run: pnpm are-types-wrong

- name: Build Website (GitHub demo site)
run: pnpm build:demo

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"url": "https://ko-fi.com/ghiscoding"
},
"scripts": {
"are-types-wrong": "pnpm -r --stream --filter=\"{packages/multiple-select-vanilla/**}\" are-types-wrong",
"clean": "rimraf --glob **/dist **/tsconfig.tsbuildinfo",
"prebuild": "pnpm clean && pnpm biome:lint:write && pnpm biome:format:write",
"build": "pnpm -r --stream build",
Expand Down
6 changes: 0 additions & 6 deletions packages/multiple-select-vanilla/build-prod.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ const localeEntryPoints = [];
for (const format of buildFormats) {
const extension = format === 'cjs' ? 'cjs' : 'js';

// - let's use TSUP to get valid hybrid (CJS/ESM) approach with are-the-types-wrong, however keep the rest of the build
/*
runBuild({
format,
outfile: `dist/index.${extension}`,
});
*/

// build all locales
for (const localeFile of localeFiles) {
Expand All @@ -37,16 +34,13 @@ for (const format of buildFormats) {
outfile: `dist/locales/multiple-select-all-locales.${extension}`,
});

// - let's use TSUP to get valid hybrid (CJS/ESM) approach with are-the-types-wrong, however keep the rest of the build
// finally, create a regular bundle as a standalone which will be accessible as MultipleSelect from the global window object
// this file is basically a legacy alternative to import via a <script> tag
/*
runBuild({
format,
globalName: 'MultipleSelect',
outfile: `dist/browser/multiple-select.${extension}`,
});
*/
}

function runBuild(options) {
Expand Down
3 changes: 3 additions & 0 deletions packages/multiple-select-vanilla/clone-dts.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { readFileSync, writeFileSync } from 'node:fs';

writeFileSync('dist/index.d.cts', readFileSync('dist/index.d.ts'));
4 changes: 3 additions & 1 deletion packages/multiple-select-vanilla/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export type {};
import type { MultipleSelectLocale } from './src/models/locale.interface.js';
import type { MultipleSelectInstance } from './src/MultipleSelectInstance.js';
import type { MultipleSelectOption } from './src/models/multipleSelectOption.interface.js';

declare global {
interface Window {
Expand Down
18 changes: 7 additions & 11 deletions packages/multiple-select-vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
"license": "MIT",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
Expand Down Expand Up @@ -56,19 +55,18 @@
"url": "https://ko-fi.com/ghiscoding"
},
"scripts": {
"are-type-wrong": "attw --pack .",
"are-types-wrong": "attw --pack .",
"clean": "rimraf dist",
"esbuild:prod": "node build-prod.mjs",
"build": "pnpm clean && node build-prod.mjs && pnpm build:types:prod && tsup && pnpm sass:build && pnpm sass:copy",
"build:esbuild": "pnpm build:all && pnpm build:types:prod",
"postbuild:esbuild": "pnpm sass:build && pnpm sass:copy",
"build": "pnpm build:all && pnpm build:types:prod && pnpm clone:dts",
"postbuild": "pnpm sass:build && pnpm sass:copy",
"dev:init": "pnpm sass:build && pnpm sass:copy && pnpm build:all",
"build:all": "node build-prod.mjs && pnpm build:types:prod",
"build:all": "node build-prod.mjs",
"build:watch": "cross-env NODE_ENV='development' node build-watch.mjs",
"build:locales": "esbuild src/locales/all-locales-index.ts --bundle --minify --format=iife --target=es2021 --sourcemap --outfile=dist/locales/multiple-select-all-locales.js",
"build:esm": "esbuild src/index.ts --bundle --minify --format=esm --target=es2021 --sourcemap --outfile=dist/multiple-select.js",
"build:types": "tsc --emitDeclarationOnly --incremental --declarationMap false --outDir dist",
"build:types:prod": "tsc --emitDeclarationOnly --declarationMap --outDir dist",
"build:types:prod": "tsc --emitDeclarationOnly --incremental --declarationMap --outDir dist",
"clone:dts": "node clone-dts.mjs",
"sass:build": "sass src/styles:dist/styles/css --style=compressed --quiet-deps --no-source-map",
"postsass:build": "postcss dist/styles/css/**/* --dir dist/styles/css --base dist/styles/css --no-map --use cssnano --use autoprefixer --style=compressed",
"sass:watch": "sass src/styles:dist/styles/css --watch --style=compressed --quiet-deps --no-source-map",
Expand All @@ -84,13 +82,11 @@
"cross-env": "^7.0.3",
"cssnano": "^7.0.6",
"esbuild": "^0.24.0",
"esbuild-plugin-d.ts": "^1.3.0",
"fs-extra": "^11.2.0",
"postcss": "^8.4.47",
"postcss-cli": "^11.0.0",
"sass": "^1.79.5",
"tinyglobby": "^0.2.9",
"tsup": "^8.3.0",
"typescript": "5.6.3"
}
}
1 change: 0 additions & 1 deletion packages/multiple-select-vanilla/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"skipLibCheck": true,
"sourceMap": true
},
"exclude": ["node_modules", "**/*.spec.ts"],
Expand Down
43 changes: 0 additions & 43 deletions packages/multiple-select-vanilla/tsup.config.ts

This file was deleted.

Loading
Loading