Skip to content

Commit

Permalink
feat!: change TS Types exports location (#218)
Browse files Browse the repository at this point in the history
* feat!: change TS Types exports location
  • Loading branch information
ghiscoding authored Feb 20, 2024
1 parent 09c699f commit 38d3142
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"url": "https://ko-fi.com/ghiscoding"
},
"scripts": {
"clean": "rimraf --glob **/dist */tsconfig.tsbuildinfo",
"clean": "rimraf --glob **/dist **/tsconfig.tsbuildinfo",
"prebuild": "pnpm clean && pnpm biome:lint:write && pnpm biome:format:write",
"build": "pnpm -r --stream build",
"build:demo": "pnpm -r --stream --filter=\"{packages/demo/**}\" build",
Expand Down
2 changes: 1 addition & 1 deletion packages/multiple-select-vanilla/build-prod.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ for (const format of buildFormats) {
// multiple-select.js
runBuild({
format,
outfile: `dist/${format}/multiple-select.${extension}`,
outfile: `dist/multiple-select.${extension}`,
});

// build all locales
Expand Down
15 changes: 12 additions & 3 deletions packages/multiple-select-vanilla/build-watch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function runBuild(options) {
sourcemap: true,
logLevel: 'error',
// outfile: env === 'production' ? './dist/multiple-select.min.js' : './dist/multiple-select.js',
outfile: 'dist/esm/multiple-select.js',
outfile: 'dist/multiple-select.js',
},
...options,
};
Expand All @@ -32,7 +32,7 @@ function runBuild(options) {
console.info(`⚡️ Built in ${endTime - startTime}ms`);
}

function runLocaleBuild() {
function runMergedLocaleBuild() {
// merge all Locales into a single file "multiple-select-all-locales.js"
runBuild({
entryPoints: ['./src/locales/all-locales-index.ts'],
Expand All @@ -56,7 +56,16 @@ async function runCompilation(changedFiles) {
tsLogged = true;
}
if (changedFile.includes('locales')) {
runLocaleBuild();
// rebuild changed locale and also merged locale into a single locale
const [_, locale] = changedFile.match(/locales[\\\/]multiple-select-(.*)\.ts$/) || [];
if (locale?.length === 5) {
runBuild({
entryPoints: [`src/locales/multiple-select-${locale}.ts`],
format: 'esm',
outfile: `dist/locales/multiple-select-${locale}.js`,
});
}
runMergedLocaleBuild();
} else {
runBuild();
}
Expand Down
25 changes: 9 additions & 16 deletions packages/multiple-select-vanilla/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
{
"name": "multiple-select-vanilla",
"version": "1.2.5",
"main": "./dist/cjs/multiple-select.cjs",
"module": "./dist/esm/multiple-select.js",
"types": "index.d.ts",
"typesVersions": {
">=4.2": {
"*": [
"dist/types/*"
]
}
},
"main": "./dist/multiple-select.cjs",
"module": "./dist/multiple-select.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"node": "./dist/cjs/multiple-select.cjs",
"require": "./dist/cjs/multiple-select.cjs",
"default": "./dist/esm/multiple-select.js"
"types": "./dist/index.d.ts",
"node": "./dist/multiple-select.cjs",
"require": "./dist/multiple-select.cjs",
"default": "./dist/multiple-select.js"
},
"./dist/browser/*": "./dist/browser/*",
"./dist/locales/*": "./dist/locales/*",
Expand Down Expand Up @@ -59,8 +52,8 @@
"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/esm/multiple-select.js",
"build:types": "tsc --emitDeclarationOnly --incremental --declarationMap false --outDir dist/types",
"build:types:prod": "tsc --emitDeclarationOnly --incremental --declarationMap --outDir dist/types",
"build:types": "tsc --emitDeclarationOnly --incremental --declarationMap false --outDir dist",
"build:types:prod": "tsc --emitDeclarationOnly --incremental --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 Down
2 changes: 1 addition & 1 deletion packages/multiple-select-vanilla/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"declaration": true,
"declarationMap": true,
"rootDir": "src",
"outDir": "dist/esm",
"outDir": "dist",
"target": "ES2021",
"useDefineForClassFields": true,
"module": "ESNext",
Expand Down

0 comments on commit 38d3142

Please sign in to comment.