Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

chore: enforce file extensions in relative imports (#4246)

Martin Adámekdc52c6dffd55
diff --git a/oxlint.config.ts b/oxlint.config.ts
index d304d9aaf..910deafd8 100644
--- a/oxlint.config.ts
+++ b/oxlint.config.ts
@@ -28,6 +28,7 @@ export default defineConfig({
afterEach: 'readonly',
},
rules: {
+ 'import/extensions': ['error', 'always', { ignorePackages: true, checkTypeImports: true }],
'no-undef': 'off',
'no-console': 'off',
'no-throw-literal': 'error',
diff --git a/packages/stagehand-crawler/src/index.ts b/packages/stagehand-crawler/src/index.ts
index f2616a50c..edfcfafc1 100644
--- a/packages/stagehand-crawler/src/index.ts
+++ b/packages/stagehand-crawler/src/index.ts
@@ -54,11 +54,11 @@
export * from '@crawlee/browser';
// Export main crawler class
-export { StagehandCrawler, createStagehandRouter } from './internals/stagehand-crawler';
+export { StagehandCrawler, createStagehandRouter } from './internals/stagehand-crawler.js';
// Export the browser pool factories, which are how a pool with non-default options reaches the crawler
-export { stagehandBrowserPool } from './internals/stagehand-browser-pool';
-export type { StagehandBrowserPool, StagehandBrowserPoolOptions } from './internals/stagehand-browser-pool';
+export { stagehandBrowserPool } from './internals/stagehand-browser-pool.js';
+export type { StagehandBrowserPool, StagehandBrowserPoolOptions } from './internals/stagehand-browser-pool.js';
// Export types
export type {
@@ -68,9 +68,9 @@ export type {
StagehandHook,
StagehandGotoOptions,
StagehandCrawlerOptions,
-} from './internals/stagehand-crawler';
+} from './internals/stagehand-crawler.js';
-export type { StagehandLaunchContext } from './internals/stagehand-launcher';
+export type { StagehandLaunchContext } from './internals/stagehand-launcher.js';
// Re-export key types from Stagehand for convenience
export type {
diff --git a/packages/stagehand-crawler/src/internals/stagehand-browser-pool.ts b/packages/stagehand-crawler/src/internals/stagehand-browser-pool.ts
index 4ebdc5a0a..088235295 100644
--- a/packages/stagehand-crawler/src/internals/stagehand-browser-pool.ts
+++ b/packages/stagehand-crawler/src/internals/stagehand-browser-pool.ts
@@ -2,10 +2,10 @@ import type { Configuration } from '@crawlee/browser';
import type { BrowserPool, BrowserPoolHooks, BrowserPoolOptions } from '@crawlee/browser-pool';
import type { Page } from 'playwright';
-import type { StagehandOptions } from './stagehand-crawler';
-import type { StagehandLaunchContext } from './stagehand-launcher';
-import { StagehandLauncher } from './stagehand-launcher';
-import type { StagehandPlugin } from './stagehand-plugin';
+import type { StagehandOptions } from './stagehand-crawler.js';
+import type { StagehandLaunchContext } from './stagehand-launcher.js';
+import { StagehandLauncher } from './stagehand-launcher.js';
+import type { StagehandPlugin } from './stagehand-plugin.js';
/** A {@apilink BrowserPool} of Stagehand browsers, as built by {@apilink stagehandBrowserPool}. */
export type StagehandBrowserPool = BrowserPool<{ browserPlugins: [StagehandPlugin] }, [StagehandPlugin]>;
diff --git a/packages/stagehand-crawler/src/internals/stagehand-controller.ts b/packages/stagehand-crawler/src/internals/stagehand-controller.ts
index 102ee8a18..927813015 100644
--- a/packages/stagehand-crawler/src/internals/stagehand-controller.ts
+++ b/packages/stagehand-crawler/src/internals/stagehand-controller.ts
@@ -5,7 +5,7 @@ import type { Cookie } from '@crawlee/types';
import { sleep } from '@crawlee/utils';
import type { Browser as PlaywrightBrowser, BrowserType, LaunchOptions, Page } from 'playwright';
-import type { StagehandPlugin } from './stagehand-plugin';
+import type { StagehandPlugin } from './stagehand-plugin.js';
/**
* StagehandController manages the lifecycle of a Stagehand-controlled browser for Crawlee's BrowserPool.
diff --git a/packages/stagehand-crawler/src/internals/stagehand-crawler.ts b/packages/stagehand-crawler/src/internals/stagehand-crawler.ts
index e8ec72048..05a945ec8 100644
--- a/packages/stagehand-crawler/src/internals/stagehand-crawler.ts
+++ b/packages/stagehand-crawler/src/internals/stagehand-crawler.ts
@@ -31,10 +31,10 @@ import { assertBrowserPoolNotConfigured, parseArgument, schemas } from '@crawlee
import type { Page, Response } from 'playwright';
import { z } from 'zod';
-import { stagehandBrowserPool } from './stagehand-browser-pool';
-import type { StagehandController } from './stagehand-controller';
-import type { StagehandLaunchContext } from './stagehand-launcher';
-import { enhancePageWithStagehand } from './utils/stagehand-utils';
+import { stagehandBrowserPool } from './stagehand-browser-pool.js';
+import type { StagehandController } from './stagehand-controller.js';
+import type { StagehandLaunchContext } from './stagehand-launcher.js';
+import { enhancePageWithStagehand } from './utils/stagehand-utils.js';
/**
* Stagehand-specific configuration options.
diff --git a/packages/stagehand-crawler/src/internals/stagehand-launcher.ts b/packages/stagehand-crawler/src/internals/stagehand-launcher.ts
index 9c4d2e298..93ec15a34 100644
--- a/packages/stagehand-crawler/src/internals/stagehand-launcher.ts
+++ b/packages/stagehand-crawler/src/internals/stagehand-launcher.ts
@@ -4,8 +4,8 @@ import { parseArgument, schemas } from '@crawlee/utils/internal';
import type { BrowserType, LaunchOptions } from 'playwright';
import { z } from 'zod';
-import type { StagehandOptions } from './stagehand-crawler';
-import { StagehandPlugin } from './stagehand-plugin';
+import type { StagehandOptions } from './stagehand-crawler.js';
+import { StagehandPlugin } from './stagehand-plugin.js';
/**
* Launch context for Stagehand crawler with AI-specific options.
diff --git a/packages/stagehand-crawler/src/internals/stagehand-plugin.ts b/packages/stagehand-crawler/src/internals/stagehand-plugin.ts
index bbe2778d6..7b782f333 100644
--- a/packages/stagehand-crawler/src/internals/stagehand-plugin.ts
+++ b/packages/stagehand-crawler/src/internals/stagehand-plugin.ts
@@ -7,8 +7,8 @@ import type { Browser as PlaywrightBrowser, BrowserType, LaunchOptions } from 'p
// Firefox and WebKit are not supported by Stagehand.
import { chromium } from 'playwright';
-import { StagehandController } from './stagehand-controller';
-import type { StagehandOptions } from './stagehand-crawler';
+import { StagehandController } from './stagehand-controller.js';
+import type { StagehandOptions } from './stagehand-crawler.js';
/**
* Options for StagehandPlugin initialization.
diff --git a/packages/stagehand-crawler/src/internals/utils/stagehand-utils.ts b/packages/stagehand-crawler/src/internals/utils/stagehand-utils.ts
index 6b7ee11af..bf0ab9bf9 100644
--- a/packages/stagehand-crawler/src/internals/utils/stagehand-utils.ts
+++ b/packages/stagehand-crawler/src/internals/utils/stagehand-utils.ts
@@ -2,7 +2,7 @@ import type { ActOptions, AgentConfig, ExtractOptions, ObserveOptions, Stagehand
import type { Page } from 'playwright';
import type { ZodType } from 'zod';
-import type { StagehandPage } from '../stagehand-crawler';
+import type { StagehandPage } from '../stagehand-crawler.js';
const PROVIDER_ENV_VARS: Record<string, string> = {
OpenAI: 'OPENAI_API_KEY',