diff --git a/packages/adblocker-electron-example/README.md b/packages/adblocker-electron-example/README.md index aa3d9d7ba9..15ec91ec03 100644 --- a/packages/adblocker-electron-example/README.md +++ b/packages/adblocker-electron-example/README.md @@ -45,8 +45,19 @@ Blocking ads in Electron using [@cliqz/adblocker-electron](https://github.com/ghostery/adblocker/tree/master/packages/adblocker-electron). +Build code ```sh -$ yarn start +$ yarn build +``` + +Start example as commonjs module +```sh +$ yarn start:commonjs +``` + +Or, start example as esm module +```sh +$ yarn start:esm ``` Checkout [index.ts](./index.ts) for more details! diff --git a/packages/adblocker-electron-example/index.js b/packages/adblocker-electron-example/index.js deleted file mode 100644 index c142f50c21..0000000000 --- a/packages/adblocker-electron-example/index.js +++ /dev/null @@ -1,2 +0,0 @@ -import { tsImport } from 'tsx/esm/api' -await tsImport('./index.ts', import.meta.url) diff --git a/packages/adblocker-electron-example/package.json b/packages/adblocker-electron-example/package.json index 258250ba88..3561f8e749 100644 --- a/packages/adblocker-electron-example/package.json +++ b/packages/adblocker-electron-example/package.json @@ -9,10 +9,31 @@ "homepage": "https://github.com/ghostery/adblocker#readme", "license": "MPL-2.0", "type": "module", + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + } + }, + "exports": { + "./package.json": "./package.json", + ".": { + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts", + "module": "./dist/esm/index.js", "files": [ "LICENSE", - "index.ts", - "index.js" + "dist" ], "repository": { "type": "git", @@ -20,8 +41,11 @@ "directory": "packages/adblocker-electron-example" }, "scripts": { - "start": "electron index.js", - "lint": "eslint index.ts" + "clean": "rimraf dist .tshy .tshy-build", + "start:commonjs": "electron dist/commonjs/index.js", + "start:esm": "electron dist/commonjs/index.js", + "build": "tshy", + "lint": "eslint src/index.ts" }, "bugs": { "url": "https://github.com/ghostery/adblocker/issues" @@ -63,12 +87,13 @@ "dependencies": { "@cliqz/adblocker-electron": "^1.28.2", "cross-fetch": "^4.0.0", - "electron": "^31.0.0", - "tsx": "^4.16.2" + "electron": "^31.0.0" }, "devDependencies": { "@types/node": "^20.12.12", "eslint": "^9.3.0", + "rimraf": "^6.0.1", + "tshy": "^3.0.2", "typescript": "^5.5.2" } } diff --git a/packages/adblocker-electron-example/index.ts b/packages/adblocker-electron-example/src/index.ts similarity index 100% rename from packages/adblocker-electron-example/index.ts rename to packages/adblocker-electron-example/src/index.ts diff --git a/packages/adblocker-electron-example/tsconfig.json b/packages/adblocker-electron-example/tsconfig.json index 51fe4ee6bd..aff127c76b 100644 --- a/packages/adblocker-electron-example/tsconfig.json +++ b/packages/adblocker-electron-example/tsconfig.json @@ -4,6 +4,6 @@ { "path": "../adblocker-electron/tsconfig.json" } ], "files": [ - "./index.ts" + "./src/index.ts" ] } diff --git a/packages/adblocker-playwright-example/README.md b/packages/adblocker-playwright-example/README.md index c0169709c0..9e06bb0d04 100644 --- a/packages/adblocker-playwright-example/README.md +++ b/packages/adblocker-playwright-example/README.md @@ -1,7 +1,18 @@ Blocking ads in Playwright using [@cliqz/adblocker-playwright](https://github.com/ghostery/adblocker/tree/master/packages/adblocker-playwright). +Build code ```sh -$ yarn start +$ yarn build +``` + +Start as commonjs +```sh +$ yarn start:commonjs +``` + +Or, start as esm +``` +$ yarn start:esm ``` Checkout [index.ts](https://github.com/ghostery/adblocker/blob/master/packages/adblocker-playwright-example/index.ts) for more details! diff --git a/packages/adblocker-playwright-example/package.json b/packages/adblocker-playwright-example/package.json index 331f272809..53c1a9ef32 100644 --- a/packages/adblocker-playwright-example/package.json +++ b/packages/adblocker-playwright-example/package.json @@ -8,9 +8,32 @@ }, "homepage": "https://github.com/ghostery/adblocker#readme", "license": "MPL-2.0", + "type": "module", + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + } + }, + "exports": { + "./package.json": "./package.json", + ".": { + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts", + "module": "./dist/esm/index.js", "files": [ "LICENSE", - "index.ts" + "dist" ], "repository": { "type": "git", @@ -18,8 +41,11 @@ "directory": "packages/adblocker-playwright-example" }, "scripts": { - "start": "tsx index.ts", - "lint": "eslint index.ts" + "clean": "rimraf dist .tshy .tshy-build", + "start:commonjs": "node dist/commonjs/index.js", + "start:esm": "node dist/esm/index.js", + "build": "tshy", + "lint": "eslint src/index.ts" }, "bugs": { "url": "https://github.com/ghostery/adblocker/issues" @@ -27,12 +53,13 @@ "dependencies": { "@cliqz/adblocker-playwright": "^1.28.2", "cross-fetch": "^4.0.0", - "playwright": "^1.38.0", - "tsx": "^4.16.2" + "playwright": "^1.38.0" }, "devDependencies": { "@types/node": "^20.12.12", "eslint": "^9.3.0", + "rimraf": "^6.0.1", + "tshy": "^3.0.2", "typescript": "^5.5.2" }, "contributors": [ diff --git a/packages/adblocker-playwright-example/index.ts b/packages/adblocker-playwright-example/src/index.ts similarity index 100% rename from packages/adblocker-playwright-example/index.ts rename to packages/adblocker-playwright-example/src/index.ts diff --git a/packages/adblocker-playwright-example/tsconfig.json b/packages/adblocker-playwright-example/tsconfig.json index 45d2f6935d..3c1f8dccb7 100644 --- a/packages/adblocker-playwright-example/tsconfig.json +++ b/packages/adblocker-playwright-example/tsconfig.json @@ -4,6 +4,6 @@ { "path": "../adblocker-playwright/tsconfig.json" } ], "files": [ - "./index.ts" + "./src/index.ts" ] } diff --git a/packages/adblocker-puppeteer-example/README.md b/packages/adblocker-puppeteer-example/README.md index 41555db60d..cbeeb70433 100644 --- a/packages/adblocker-puppeteer-example/README.md +++ b/packages/adblocker-puppeteer-example/README.md @@ -45,8 +45,19 @@ Blocking ads in Puppeteer using [@cliqz/adblocker-puppeteer](https://github.com/ghostery/adblocker/tree/master/packages/adblocker-puppeteer). +Build code ```sh -$ yarn start +$ yarn build +``` + +Start example as commonjs module +```sh +$ yarn start:commonjs +``` + +Or, start example as esm module +```sh +$ yarn start:esm ``` Checkout [index.ts](./index.ts) for more details! diff --git a/packages/adblocker-puppeteer-example/package.json b/packages/adblocker-puppeteer-example/package.json index de6a5747c0..3904e2cce1 100644 --- a/packages/adblocker-puppeteer-example/package.json +++ b/packages/adblocker-puppeteer-example/package.json @@ -8,9 +8,32 @@ }, "homepage": "https://github.com/ghostery/adblocker#readme", "license": "MPL-2.0", + "type": "module", + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + } + }, + "exports": { + "./package.json": "./package.json", + ".": { + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts", + "module": "./dist/esm/index.js", "files": [ "LICENSE", - "index.ts" + "dist" ], "repository": { "type": "git", @@ -18,8 +41,11 @@ "directory": "packages/adblocker-puppeteer-example" }, "scripts": { - "start": "tsx index.ts", - "lint": "eslint index.ts" + "clean": "rimraf dist .tshy .tshy-build", + "start:commonjs": "node dist/commonjs/index.js", + "start:esm": "node dist/esm/index.js", + "build": "tshy", + "lint": "eslint src/index.ts" }, "bugs": { "url": "https://github.com/ghostery/adblocker/issues" @@ -27,12 +53,13 @@ "dependencies": { "@cliqz/adblocker-puppeteer": "^1.28.2", "cross-fetch": "^4.0.0", - "puppeteer": "22.13.0", - "tsx": "^4.16.2" + "puppeteer": "22.13.0" }, "devDependencies": { "@types/node": "^20.12.12", "eslint": "^9.3.0", + "rimraf": "^6.0.1", + "tshy": "^3.0.2", "typescript": "^5.5.2" }, "contributors": [ diff --git a/packages/adblocker-puppeteer-example/index.ts b/packages/adblocker-puppeteer-example/src/index.ts similarity index 95% rename from packages/adblocker-puppeteer-example/index.ts rename to packages/adblocker-puppeteer-example/src/index.ts index 414c7e5cfc..05eab107a6 100644 --- a/packages/adblocker-puppeteer-example/index.ts +++ b/packages/adblocker-puppeteer-example/src/index.ts @@ -5,7 +5,7 @@ import { promises as fs } from 'fs'; function getUrlToLoad(): string { let url = 'https://www.mangareader.to/'; - if (process.argv[process.argv.length - 1].endsWith('.ts') === false) { + if (process.argv[process.argv.length - 1].endsWith('.js') === false) { url = process.argv[process.argv.length - 1]; } diff --git a/packages/adblocker-puppeteer-example/tsconfig.json b/packages/adblocker-puppeteer-example/tsconfig.json index cb3fef9c17..3f5afbd57f 100644 --- a/packages/adblocker-puppeteer-example/tsconfig.json +++ b/packages/adblocker-puppeteer-example/tsconfig.json @@ -4,6 +4,6 @@ { "path": "../adblocker-puppeteer/tsconfig.json" } ], "files": [ - "./index.ts" + "./src/index.ts" ] } diff --git a/yarn.lock b/yarn.lock index fee2063f07..efa66e2358 100644 --- a/yarn.lock +++ b/yarn.lock @@ -396,7 +396,8 @@ __metadata: cross-fetch: "npm:^4.0.0" electron: "npm:^31.0.0" eslint: "npm:^9.3.0" - tsx: "npm:^4.16.2" + rimraf: "npm:^6.0.1" + tshy: "npm:^3.0.2" typescript: "npm:^5.5.2" languageName: unknown linkType: soft @@ -475,7 +476,8 @@ __metadata: cross-fetch: "npm:^4.0.0" eslint: "npm:^9.3.0" playwright: "npm:^1.38.0" - tsx: "npm:^4.16.2" + rimraf: "npm:^6.0.1" + tshy: "npm:^3.0.2" typescript: "npm:^5.5.2" languageName: unknown linkType: soft @@ -513,7 +515,8 @@ __metadata: cross-fetch: "npm:^4.0.0" eslint: "npm:^9.3.0" puppeteer: "npm:22.13.0" - tsx: "npm:^4.16.2" + rimraf: "npm:^6.0.1" + tshy: "npm:^3.0.2" typescript: "npm:^5.5.2" languageName: unknown linkType: soft