Skip to content

Commit

Permalink
fix: ES2022 build compatibility and move to NodeNext for module (#2258)
Browse files Browse the repository at this point in the history
Closes #2257
  • Loading branch information
vladfrangu authored Dec 27, 2023
1 parent 57f1671 commit 7fe1e68
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/templates/templates/cheerio-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@apify/tsconfig",
"compilerOptions": {
"module": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
"outDir": "dist",
"noUnusedLocals": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@apify/tsconfig",
"compilerOptions": {
"module": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
"outDir": "dist",
"noUnusedLocals": false,
Expand Down
3 changes: 2 additions & 1 deletion packages/templates/templates/playwright-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@apify/tsconfig",
"compilerOptions": {
"module": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
"outDir": "dist",
"noUnusedLocals": false,
Expand Down
3 changes: 2 additions & 1 deletion packages/templates/templates/puppeteer-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@apify/tsconfig",
"compilerOptions": {
"module": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
"outDir": "dist",
"noUnusedLocals": false,
Expand Down
1 change: 1 addition & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@apify/log": "^2.4.0",
"@apify/ps-tree": "^1.2.0",
"@crawlee/types": "3.7.0",
"@types/sax": "^1.2.7",
"cheerio": "^1.0.0-rc.12",
"got-scraping": "^4.0.3",
"ow": "^0.28.1",
Expand Down
13 changes: 9 additions & 4 deletions scripts/typescript_fixes.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { readFileSync, writeFileSync } from 'fs';

import { globby } from 'globby';

const files = await globby('packages/*/dist/**/*.d.ts');
Expand All @@ -17,13 +18,17 @@ for (const filepath of files) {
changed = true;
} else if (
// playwright/puppeteer/got-scraping import
line.match(/^([^']+)'(playwright|puppeteer|got-scraping)'/) ||
line.match(/^([^']+)'(playwright|puppeteer|got-scraping)'/)
// proxy-per-page reexport of puppeteer
line.match(/: Puppeteer\.\w+/) ||
|| line.match(/: Puppeteer\.\w+/)
// don't ask me why, but this one is needed too ¯\_(ツ)_/¯
line.match(/^export interface (PlaywrightHook|PuppeteerHook)/)
|| line.match(/^export interface (PlaywrightHook|PuppeteerHook)/)
// /// <reference types="something" /> from newer nodenext resolutions
|| line.match(/^\/\/\/ <reference types="[^"]+" \/>/)
// import("something") from compatibility with ES2022 module -.-
|| line.match(/import\("([^"]+)"(?:.*)?\)/)
) {
output.push('// @ts-ignore optional peer dependency');
output.push('// @ts-ignore optional peer dependency or compatibility with es2022');
output.push(line);
changed = true;
} else {
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ __metadata:
"@apify/log": "npm:^2.4.0"
"@apify/ps-tree": "npm:^1.2.0"
"@crawlee/types": "npm:3.7.0"
"@types/sax": "npm:^1.2.7"
cheerio: "npm:^1.0.0-rc.12"
got-scraping: "npm:^4.0.3"
ow: "npm:^0.28.1"
Expand Down Expand Up @@ -2112,7 +2113,7 @@ __metadata:
languageName: node
linkType: hard

"@types/sax@npm:^1.0.0":
"@types/sax@npm:^1.0.0, @types/sax@npm:^1.2.7":
version: 1.2.7
resolution: "@types/sax@npm:1.2.7"
dependencies:
Expand Down

0 comments on commit 7fe1e68

Please sign in to comment.