Skip to content
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
7 changes: 4 additions & 3 deletions packages/common-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
},
"scripts": {
"dev": "nodemon --on-change-only --watch ./src --ext ts --exec \"yarn dev:build\"",
"dev:build": "tsup && tsc --emitDeclarationOnly --declaration && tsc-alias",
"build": "tsup",
"ci:build": "tsup",
"dev:build": "yarn build",
"build": "tsup && yarn build:types",
"build:types": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"ci:build": "yarn build",
"lint": "npx eslint . --ext .ts --max-warnings 80",
"lint:fix": "npx eslint . --ext .ts --fix",
"ci:lint": "yarn lint && yarn tsc --noEmit",
Expand Down
10 changes: 5 additions & 5 deletions packages/common-utils/src/core/handlebarsEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const KNOWN_HELPERS = {
function parseAndCompile(
template: string,
strict: boolean,
): HandlebarsTemplateDelegate {
): Handlebars.TemplateDelegate {
// hb.compile() defers parsing until the first render, which would push
// syntax errors out to every render call. Parse up front and hand compile()
// the AST instead, so a malformed template fails here, once.
Expand All @@ -83,7 +83,7 @@ function parseAndCompile(
}

type CompileResult =
| { delegate: HandlebarsTemplateDelegate }
| { delegate: Handlebars.TemplateDelegate }
| { error: unknown };

const strictCache = new Map<string, CompileResult>();
Expand All @@ -93,7 +93,7 @@ function compileCached(
cache: Map<string, CompileResult>,
template: string,
strict: boolean,
): HandlebarsTemplateDelegate {
): Handlebars.TemplateDelegate {
let result = cache.get(template);
if (!result) {
try {
Expand All @@ -111,15 +111,15 @@ function compileCached(
* Compile a template whose render throws if it references a key that isn't in
* the context.
*/
export function compileStrict(template: string): HandlebarsTemplateDelegate {
export function compileStrict(template: string): Handlebars.TemplateDelegate {
return compileCached(strictCache, template, true);
}

/**
* Compile a template whose render leaves missing keys empty. Throws on invalid
* syntax.
*/
export function compileLenient(template: string): HandlebarsTemplateDelegate {
export function compileLenient(template: string): Handlebars.TemplateDelegate {
return compileCached(lenientCache, template, false);
}

Expand Down
7 changes: 7 additions & 0 deletions packages/common-utils/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true
},
"exclude": ["node_modules", "src/**/__tests__/**", "src/**/*.test.ts"]
}
11 changes: 2 additions & 9 deletions packages/common-utils/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@ import type { Options } from 'tsup';
export const tsup: Options = {
splitting: true,
clean: true, // clean up the dist folder
dts: {
// tsup's DTS bundler (rollup-plugin-dts) unconditionally injects the
// `baseUrl` compiler option, which TypeScript 6 reports as deprecated
// (TS5101). Acknowledge the deprecation so DTS generation succeeds until
// tsup stops forcing baseUrl.
compilerOptions: {
ignoreDeprecations: '6.0',
},
}, // generate dts files
// Declarations come from (the more efficient) tsc
dts: false,
format: ['cjs', 'esm'], // generate cjs and esm files
minify: true,
bundle: true,
Expand Down
Loading