Skip to content

Commit

Permalink
build: 👷 export only index and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ChromeGG committed Jan 30, 2024
1 parent 30a9f89 commit 18460f4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
9 changes: 2 additions & 7 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:sonarjs/recommended',
'plugin:vitest/all',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'sonarjs', 'vitest'],
root: true,
ignorePatterns: ['dist'],
overrides: [
{
files: ['*.spec.ts'],
extends: ['plugin:vitest/all'],
rules: {
'vitest/prefer-to-be-truthy': 'off',
'vitest/prefer-to-be-falsy': 'off',
Expand All @@ -20,11 +21,5 @@ module.exports = {
'vitest/prefer-lowercase-title': 'off',
},
},
{
files: ['demo/**/*'],
rules: {
'vitest/require-hook': 'off',
},
},
],
}
18 changes: 18 additions & 0 deletions esbuild.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import * as esbuild from 'esbuild'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'

await esbuild.build({
entryPoints: ['src/index.ts'],
Expand All @@ -7,3 +10,18 @@ await esbuild.build({
format: 'esm',
minify: true,
})

// TODO can we do it with esbuild/tsconfig.json?
// remove all files with .d.ts extension from dist folder except index.d.ts
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const distDir = path.join(__dirname, 'dist')
const files = fs.readdirSync(distDir)

files.forEach((file) => {
if (file.endsWith('.d.ts') && file !== 'index.d.ts') {
fs.unlinkSync(path.join(distDir, file))
}
})

4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { CelVisitor } from './visitor.js'
import { CstNode } from 'chevrotain'
import { CelParseError } from './errors/CelParseError.js'

export { CelParseError } from './errors/CelParseError.js'
export { CelEvaluationError } from './errors/CelEvaluationError.js'
export { CelTypeError } from './errors/CelTypeError.js'

const parserInstance = new CelParser()

export type Success = {
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"*": ["*", "src/*"]
}
},
"include": ["src/**/*", "src/tokens.ts"],
"exclude": ["node_modules", "lib", "**/*.spec.ts"]
"include": ["src/index.ts"],
"exclude": ["node_modules", "dist", "**/*.spec.ts"]
}

0 comments on commit 18460f4

Please sign in to comment.