Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Oct 4, 2024
2 parents a3a7166 + 405bc50 commit 543e76e
Show file tree
Hide file tree
Showing 6 changed files with 1,007 additions and 168 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
"playwright:install": "pnpm exec playwright install"
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@lerna-lite/cli": "^3.9.1",
"@lerna-lite/publish": "^3.9.1",
"@lerna-lite/watch": "^3.9.1",
"@biomejs/biome": "^1.9.3",
"@lerna-lite/cli": "^3.9.2",
"@lerna-lite/publish": "^3.9.2",
"@lerna-lite/watch": "^3.9.2",
"@playwright/test": "^1.47.2",
"@types/node": "^22.5.5",
"@types/node": "^22.7.4",
"conventional-changelog-conventionalcommits": "^7.0.2",
"cross-env": "^7.0.3",
"npm-run-all2": "^6.2.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
"dependencies": {
"@popperjs/core": "^2.11.8",
"bootstrap": "^5.3.3",
"dompurify": "^3.1.6",
"dompurify": "^3.1.7",
"font-awesome": "^4.7.0",
"multiple-select-vanilla": "workspace:*"
},
"devDependencies": {
"@types/dompurify": "^3.0.5",
"sass": "^1.79.3",
"sass": "^1.79.4",
"typescript": "5.6.2",
"vite": "^5.4.7"
"vite": "^5.4.8"
}
}
9 changes: 6 additions & 3 deletions packages/multiple-select-vanilla/build-prod.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { buildSync } from 'esbuild';
import { globSync } from 'glob';
import { globSync } from 'tinyglobby';

const buildFormats = ['cjs', 'esm'];
const localeFiles = globSync('src/locales/**/*.ts');
const localeEntryPoints = [];

for (const format of buildFormats) {
const extension = format === 'cjs' ? 'cjs' : 'js';
// multiple-select.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/multiple-select.${extension}`,
outfile: `dist/index.${extension}`,
});
*/

// build all locales
for (const localeFile of localeFiles) {
Expand Down
36 changes: 24 additions & 12 deletions packages/multiple-select-vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@
],
"homepage": "https://github.com/ghiscoding/multiple-select-vanilla",
"license": "MIT",
"main": "./dist/multiple-select.cjs",
"module": "./dist/multiple-select.js",
"types": "dist/index.d.ts",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/multiple-select.js",
"require": "./dist/multiple-select.cjs"
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./dist/browser/*": "./dist/browser/*",
"./dist/locales/*": "./dist/locales/*",
Expand All @@ -50,16 +56,19 @@
"url": "https://ko-fi.com/ghiscoding"
},
"scripts": {
"are-type-wrong": "attw --pack .",
"clean": "rimraf dist",
"build": "pnpm build:all && pnpm build:types:prod",
"postbuild": "pnpm sass:build && pnpm sass:copy",
"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",
"dev:init": "pnpm sass:build && pnpm sass:copy && pnpm build:all",
"build:all": "node build-prod.mjs && pnpm build:types:prod",
"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 --incremental --declarationMap --outDir dist",
"build:types:prod": "tsc --emitDeclarationOnly --declarationMap --outDir dist",
"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 @@ -69,16 +78,19 @@
"@types/trusted-types": "^2.0.7"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.16.4",
"autoprefixer": "^10.4.20",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"cssnano": "^7.0.6",
"esbuild": "^0.23.1",
"esbuild": "^0.24.0",
"esbuild-plugin-d.ts": "^1.3.0",
"fs-extra": "^11.2.0",
"glob": "^10.4.5",
"postcss": "^8.4.47",
"postcss-cli": "^11.0.0",
"sass": "^1.79.3",
"sass": "^1.79.4",
"tinyglobby": "^0.2.9",
"tsup": "^8.3.0",
"typescript": "5.6.2"
}
}
41 changes: 41 additions & 0 deletions packages/multiple-select-vanilla/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { defineConfig } from 'tsup';

export default defineConfig(options => [
// for bundlers like vite, rollup, esbuild, webpack etc
{
entry: ['src/**.ts'],
format: ['esm'],
splitting: false,
sourcemap: true,
// clean: true,
dts: !options.watch,
outExtension: ({ format }) => ({ js: format === 'cjs' ? '.cjs' : '.mjs' }),
},
// common js for node and other backend runtimes
{
entry: ['src/index.ts'],
format: ['cjs'],
splitting: false,
sourcemap: true,
// clean: true,
dts: !options.watch,
outExtension: ({ format }) => ({
js: format === 'cjs' ? '.cjs' : '.mjs',
}),
},

// IIFE bundle js for cdn (window object for legacy <script>)
// {
// entry: {
// 'multiple-select': 'src/index.ts',
// },
// format: ['iife'],
// globalName: 'MultipleSelect',
// splitting: false,
// sourcemap: true,
// clean: true,
// outExtension: ({ format }) => ({
// js: '.iife.js',
// }),
// },
]);
Loading

0 comments on commit 543e76e

Please sign in to comment.