Skip to content

Commit

Permalink
fix: should transpile ansiHTML to es5 (#10)
Browse files Browse the repository at this point in the history
* fix: should transpile ansiHTML to es5

* fix: should transpile ansiHTML to es5
  • Loading branch information
LingyuCoder authored Oct 12, 2024
1 parent 18a8e4e commit 72ce63c
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
.DS_Store
*.local
*.log*
*.tsbuildinfo

# Dist
node_modules
dist/
client/
test-results

# Test
Expand Down
1 change: 1 addition & 0 deletions client/index.js → client-src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions client/utils/reloadApp.js → client-src/utils/reloadApp.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-nocheck

import hotEmitter from "@rspack/core/hot/emitter.js";
import { log } from "webpack-dev-server/client/utils/log.js";

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"./package.json": "./package.json"
},
"scripts": {
"build": "tsc -b ./tsconfig.build.json",
"build": "pnpm run build:server && pnpm run build:client",
"build:server": "tsc -b ./tsconfig.build.json",
"build:client": "tsc -b ./tsconfig.client.json",
"dev": "tsc -b -w",
"lint": "biome check .",
"lint:write": "biome check . --write",
Expand Down
4 changes: 1 addition & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Copyright (c) JS Foundation and other contributors
* https://github.com/webpack/webpack-dev-server/blob/b0f15ace0123c125d5870609ef4691c141a6d187/LICENSE
*/
import path from "node:path";

import type { Server } from "node:http";
import type { Socket } from "node:net";
import { type Compiler, MultiCompiler } from "@rspack/core";
Expand Down Expand Up @@ -91,7 +89,7 @@ export class RspackDevServer extends WebpackDevServer {
}

compiler.options.resolve.alias = {
"ansi-html-community": path.resolve(__dirname, "./ansiHTML"),
"ansi-html-community": require.resolve("@rspack/dev-server/client/utils/ansiHTML"),
...compiler.options.resolve.alias
};
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ansiHTML.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ansiHTML from "../src/ansiHTML";
import ansiHTML from "../client-src/utils/ansiHTML";

describe("ansi-html", () => {
it("should transform 24-bit rgb ansi colors", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"checkJs": false,
"rootDir": "../"
},
"include": ["../src", "../tests"],
"include": ["../src", "../tests", "../client-src"],
"references": []
}
14 changes: 14 additions & 0 deletions tsconfig.client.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ES2020",
"target": "ES5",
"outDir": "client",
"rootDir": "client-src",
"composite": false,
"sourceMap": false,
"declarationMap": false,
"declaration": false
},
"include": ["client-src"]
}

0 comments on commit 72ce63c

Please sign in to comment.