diff --git a/.changeset/kind-donkeys-remember.md b/.changeset/kind-donkeys-remember.md
new file mode 100644
index 000000000..06d4ef2b0
--- /dev/null
+++ b/.changeset/kind-donkeys-remember.md
@@ -0,0 +1,7 @@
+---
+'@kitajs/fastify-html-plugin': patch
+'@kitajs/ts-html-plugin': patch
+'@kitajs/html': patch
+---
+
+Added node: prefix
diff --git a/packages/fastify-html-plugin/examples/htmx.tsx b/packages/fastify-html-plugin/examples/htmx.tsx
index 36cbd0644..b1ee6d2f6 100644
--- a/packages/fastify-html-plugin/examples/htmx.tsx
+++ b/packages/fastify-html-plugin/examples/htmx.tsx
@@ -3,7 +3,7 @@
import fastifyFormbody from '@fastify/formbody';
import { Suspense } from '@kitajs/html/suspense';
import fastify from 'fastify';
-import { setTimeout } from 'timers/promises';
+import { setTimeout } from 'node:timers/promises';
import { fastifyKitaHtml } from '..';
const app = fastify({ logger: true });
diff --git a/packages/html/suspense.d.ts b/packages/html/suspense.d.ts
index 37ca502f0..3ce2d7e3e 100644
--- a/packages/html/suspense.d.ts
+++ b/packages/html/suspense.d.ts
@@ -1,4 +1,4 @@
-import type { Readable } from 'stream';
+import type { Readable } from 'node:stream';
import type { Children } from './';
declare global {
diff --git a/packages/html/suspense.js b/packages/html/suspense.js
index f8cd530c9..5d1ab7c3a 100644
--- a/packages/html/suspense.js
+++ b/packages/html/suspense.js
@@ -1,5 +1,5 @@
const { contentsToString, contentToString } = require('./index');
-const { Readable } = require('stream');
+const { Readable } = require('node:stream');
// Avoids double initialization in case this file is not cached by
// module bundlers.
@@ -169,11 +169,11 @@ function Suspense(props) {
// Keeps string return type
if (typeof fallback === 'string') {
- return '
' + fallback + '
';
+ return `${fallback}
`;
}
return fallback.then(function resolveCallback(resolved) {
- return '' + resolved + '
';
+ return `${resolved}
`;
});
/**
@@ -204,7 +204,7 @@ function Suspense(props) {
// Writes the chunk
data.stream.push(
// prettier-ignore
- '' + result + ''
+ `${result}`
);
}
}
diff --git a/packages/ts-html-plugin/src/cli.ts b/packages/ts-html-plugin/src/cli.ts
index 5040216c3..c2afbdd6d 100644
--- a/packages/ts-html-plugin/src/cli.ts
+++ b/packages/ts-html-plugin/src/cli.ts
@@ -1,9 +1,9 @@
#!/usr/bin/env node
import chalk from 'chalk';
-import fs from 'fs';
-import { EOL } from 'os';
-import path from 'path';
+import fs from 'node:fs';
+import { EOL } from 'node:os';
+import path from 'node:path';
import ts from 'typescript';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
@@ -166,7 +166,7 @@ async function main() {
files = [];
for (let i = 0; i < args._.length; i++) {
- let file = String(args._[i]);
+ const file = String(args._[i]);
if (!fileExists(file)) {
console.error(
@@ -189,7 +189,7 @@ async function main() {
}
if (!files.length) {
- console.error((!simplified ? chalk.red : String)(`No files were found to check.`));
+ console.error((!simplified ? chalk.red : String)('No files were found to check.'));
return process.exit(1);
}
diff --git a/packages/ts-html-plugin/test/util/lang-server.ts b/packages/ts-html-plugin/test/util/lang-server.ts
index 3e2a8b380..b0b350505 100644
--- a/packages/ts-html-plugin/test/util/lang-server.ts
+++ b/packages/ts-html-plugin/test/util/lang-server.ts
@@ -1,8 +1,8 @@
-import { ChildProcess, fork } from 'child_process';
-import { EventEmitter } from 'events';
-import { Deferred, deferred } from 'fast-defer';
-import { statSync } from 'fs';
-import path from 'path';
+import { deferred, type Deferred } from 'fast-defer';
+import { fork, type ChildProcess } from 'node:child_process';
+import { EventEmitter } from 'node:events';
+import { statSync } from 'node:fs';
+import path from 'node:path';
import ts from 'typescript/lib/tsserverlibrary';
/** All requests used in tests */
@@ -82,9 +82,9 @@ export class TSLangServer {
this.server.on('exit', this.exitPromise.resolve);
this.server.on('error', this.exitPromise.reject);
- this.server.stdout!.setEncoding('utf-8');
+ this.server.stdout?.setEncoding('utf-8');
- this.server.stdout!.on('data', (data) => {
+ this.server.stdout?.on('data', (data) => {
const obj = JSON.parse(data.split('\n', 3)[2]);
if (this.debug) {
@@ -97,7 +97,7 @@ export class TSLangServer {
// Error is fatal, close the server
if (!this.isClosed) {
this.isClosed = true;
- this.server.stdin!.end();
+ this.server.stdin?.end();
}
} else if (obj.type === 'event') {
this.responseEventEmitter.emit(obj.event, obj);
@@ -109,7 +109,7 @@ export class TSLangServer {
/** Opens the project, sends diagnostics request and returns the response */
async openWithDiagnostics(content: TemplateStringsArray, ...args: any[]) {
- const fileContent = TEST_HELPERS + '\n' + String.raw(content, ...args).trim();
+ const fileContent = `${TEST_HELPERS}\n${String.raw(content, ...args).trim()}`;
if (this.debug) {
console.log(this.strWithLineNumbers(fileContent));
@@ -147,7 +147,7 @@ export class TSLangServer {
send(command: Omit) {
const response = deferred();
- this.server.stdin!.write(this.formatCommand(command), (err) =>
+ this.server.stdin?.write(this.formatCommand(command), (err) =>
err ? response.reject(err) : response.resolve()
);
@@ -155,10 +155,9 @@ export class TSLangServer {
}
private formatCommand(command: Omit) {
- return (
- JSON.stringify(Object.assign({ seq: ++this.sequence, type: 'request' }, command)) +
- '\n'
- );
+ return `${JSON.stringify(
+ Object.assign({ seq: ++this.sequence, type: 'request' }, command)
+ )}\n`;
}
waitEvent(eventName: string) {
@@ -198,7 +197,7 @@ export class TSLangServer {
[Symbol.asyncDispose]() {
if (!this.isClosed) {
this.isClosed = true;
- this.server.stdin!.end();
+ this.server.stdin?.end();
}
return this.exitPromise;