Skip to content

Commit

Permalink
chore: more cleanup for ESM + Vite (#273)
Browse files Browse the repository at this point in the history
vite.config.ts:
- don't use build.lib.name, only needed for umd/iife packages
- simplify build.lib.fileName
- use ESM node module for `path` via `node:path`

package.json:
- register types at root too, not just exports
- also run publint when running `npm run lint`
- remove `directories` key, not needed (defined from CommonJS spec)
  • Loading branch information
neoncitylights authored Dec 25, 2023
1 parent a49274e commit 850667d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@
"url": "https://github.com/sponsors/{{author}}"
},
"type": "module",
"module": "./dist/{{package}}.es.js",
"types": "./dist/index.d.ts",
"module": "./dist/{{package}}.mjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/{{package}}.es.js"
"import": "./dist/{{package}}.mjs"
}
},
"files": [
"dist"
],
"directories": {
"test": "tests"
},
"scripts": {
"build": "vite build",
"build:typedoc": "npx typedoc",
Expand All @@ -43,7 +41,7 @@
"test:ui": "npm run test -- --ui",
"test:watch": "npm run test -- --watch",
"test:all": "npm run test:ci && npm run lint",
"lint": "npm run lint:md && npm run lint:es",
"lint": "npm run lint:md && npm run lint:es && npm run lint:pub",
"lint:fix": "npm run lint:md-fix && npm run lint:es-fix",
"lint:md": "markdownlint-cli2 \"*/**.md\" \"#node_modules\"",
"lint:md-fix": "npm run lint:md -- --fix",
Expand Down
6 changes: 3 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import path from 'path';
import path from 'node:path';

import dts from 'vite-plugin-dts';
import { defineConfig } from 'vitest/config';

export default defineConfig({
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: '{{package}}',
formats: ['es'],
fileName: (format) => `{{package}}.${format}.js`,
fileName: () => '{{package}}.mjs',
},
},
define: {
Expand Down

0 comments on commit 850667d

Please sign in to comment.