From 6e4b7b0e43c6457253594df8a7cf1993b9913101 Mon Sep 17 00:00:00 2001 From: Shogun Date: Mon, 7 Mar 2022 08:54:44 +0100 Subject: [PATCH] chore: Updated build system. --- .swcrc | 12 ++++++++++++ package.json | 24 ++++++++++++++---------- src/index.ts | 6 +++--- tsconfig.json | 2 +- 4 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 .swcrc diff --git a/.swcrc b/.swcrc new file mode 100644 index 0000000..a44031b --- /dev/null +++ b/.swcrc @@ -0,0 +1,12 @@ +{ + "env": { + "targets": "node >= 16" + }, + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": false, + "dynamicImport": true + } + } +} diff --git a/package.json b/package.json index 98ea98c..c4784b9 100644 --- a/package.json +++ b/package.json @@ -27,26 +27,30 @@ "typings": "./types/index.d.ts", "types": "./types/index.d.ts", "scripts": { - "prebuild": "rm -rf dist types && npm run lint", - "build": "tsc -p . && esm-pkg-add-imports-extensions dist", + "dev": "swc -w -d dist src", + "prebuild": "rm -rf dist types && npm run typecheck && npm run lint", + "build": "swc --delete-dir-on-start -d dist src", "format": "prettier -w src", + "typecheck": "tsc -p . --emitDeclarationOnly", "lint": "eslint src", - "ci": "npm run lint", + "ci": "npm run build && npm run lint", "prepublishOnly": "npm run ci", "postpublish": "git push origin && git push origin -f --tags" }, "dependencies": { - "webpack": "^5.51.1" + "webpack": "^5.70.0" }, "devDependencies": { - "@cowtech/eslint-config": "^8.0.1", - "@cowtech/esm-package-utils": "^0.9.3", - "@types/node": "^17.0.2", - "prettier": "^2.3.2", - "typescript": "^4.3.5" + "@cowtech/eslint-config": "^8.4.0", + "@swc/cli": "^0.1.55", + "@swc/core": "^1.2.150", + "@types/node": "^17.0.21", + "chokidar": "^3.5.3", + "prettier": "^2.5.1", + "typescript": "^4.6.2" }, "peerDependencies": { - "typescript": "^4.3.5" + "typescript": "^4.6.2" }, "engines": { "node": ">=14.15.0" diff --git a/src/index.ts b/src/index.ts index 95e5a30..0812253 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,11 @@ -import { sep } from 'path' +import { sep } from 'node:path' import { Compilation } from 'webpack' export const cacheName = '@cowtech/webpack' export const imagesExtensions = /\.(?:bmp|png|jpg|jpeg|gif|svg|webp)$/ -export const scriptUrlSuffix = /-(?:(?:[a-f0-9]+)\.mjs)$/i +export const scriptUrlSuffix = /-[\da-f]+\.mjs$/i export async function getManifestUrl(compilation: Compilation): Promise { const url = await compilation.getCache(cacheName).getPromise('html-webpack-tracker-plugin:manifest', null) @@ -30,7 +30,7 @@ export function normalizeAssetPath({ filename }: { filename?: string }): string export function generateVersion(): string { return new Date() .toISOString() - .replace(/([-:])|(\.\d+Z$)/g, '') + .replace(/([:-])|(\.\d+Z$)/g, '') .replace('T', '.') } diff --git a/tsconfig.json b/tsconfig.json index db0d1e6..65f9f1e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2020", + "target": "ES2021", "module": "ESNext", "moduleResolution": "node", "jsx": "preserve",