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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ temp

# npm pack result
*.tgz
!tarballs/krutoo-ts-loader-0.0.0.tgz

# vscode
.vscode/settings.json
6 changes: 3 additions & 3 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
* This script will build package.
*/
import fs from 'node:fs/promises';
import { execAsync } from './utils.ts';
import { $ } from './utils.ts';

// clean dist folder
await fs.rm('./dist', { recursive: true, force: true });

// build .js files
await execAsync('npx tsc -p tsconfig.build-js.json');
await $('npx tsc -p tsconfig.build-js.json');

// build .d.ts files
await execAsync('npx tsc -p tsconfig.build-dts.json');
await $('npx tsc -p tsconfig.build-dts.json');

// format (for reduce package size by replacing indent from 4 to 2)
await execAsync('npx prettier "dist/**/*.js" -w --log-level=error --ignore-path=./.nonexistent');
await $('npx prettier "dist/**/*.js" -w --log-level=error --ignore-path=./.nonexistent');
30 changes: 24 additions & 6 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exec } from 'node:child_process';
import { spawn } from 'node:child_process';
import fs from 'node:fs/promises';
import { EOL } from 'node:os';
import path from 'node:path';
Expand All @@ -11,12 +11,30 @@ export function normalizePathname(pathname: string): string {
return `./${pathname}`;
}

export async function execAsync(cmd: string): Promise<void> {
return await new Promise<void>((done, fail) => {
const proc = exec(cmd, err => (err ? fail(err) : done()));
/**
* Runs shell script using `spawn`.
* @param cmd Command to run.
* @returns Promise that resolves when process closed.
*/
export function $(cmd: string): Promise<void> {
return new Promise((done, fail) => {
const child = spawn(cmd, {
stdio: 'inherit',
shell: true,
env: { ...process.env, FORCE_COLOR: '3' },
});

proc.stdout?.pipe(process.stdout);
proc.stderr?.pipe(process.stderr);
child.on('error', fail);

child.on('close', (code, signal) => {
if (code === 0) {
done();
} else {
fail(
new Error(signal ? `Process killed, signal ${signal}` : `Process exited, code ${code}`),
);
}
});
});
}

Expand Down
1 change: 1 addition & 0 deletions src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// IMPORTANT: "./rspack/mod.ts" is not added here by the same reason
// IMPORTANT: "./testing/mod.ts" is not added here because in practice it need only in test environment
// IMPORTANT: "./store/mod.ts" is not added here because it is a little bit more than just utility
// IMPORTANT: "./router/mod.ts" is not added here by the same reason
export * from './dom/mod.ts';
export * from './math/mod.ts';
export * from './types/mod.ts';
Expand Down
6 changes: 3 additions & 3 deletions tests-e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading