From 370ecc4d38dc2c2812cb8cf9296c48a7ca3d2d15 Mon Sep 17 00:00:00 2001 From: Vitaliy Potapov Date: Tue, 10 Sep 2024 09:29:25 +0400 Subject: [PATCH] revert subpath imports to relative paths, #218 --- CHANGELOG.md | 3 +++ eslint.config.mjs | 8 -------- package.json | 6 ------ src/cli/commands/env.ts | 2 +- src/reporter/cucumber/base.ts | 2 +- .../cucumber/messagesBuilder/AttachmentMapper.ts | 6 +++--- .../cucumber/messagesBuilder/GherkinDocument.ts | 4 ++-- .../cucumber/messagesBuilder/GherkinDocumentClone.ts | 4 ++-- .../cucumber/messagesBuilder/GherkinDocuments.ts | 10 +++++----- src/reporter/cucumber/messagesBuilder/Hook.ts | 2 +- src/reporter/cucumber/messagesBuilder/Meta.ts | 2 +- src/reporter/cucumber/messagesBuilder/Pickles.ts | 4 ++-- src/reporter/cucumber/messagesBuilder/Projects.ts | 2 +- src/reporter/cucumber/messagesBuilder/TestCase.ts | 6 +++--- src/reporter/cucumber/messagesBuilder/TestCaseRun.ts | 8 ++++---- .../cucumber/messagesBuilder/TestStepAttachments.ts | 2 +- src/reporter/cucumber/messagesBuilder/TestStepRun.ts | 2 +- src/reporter/cucumber/messagesBuilder/index.ts | 6 +++--- tsconfig.json | 1 - 19 files changed, 34 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bd68b99..5cde0ef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Dev +* revert `#` subpath imports to relative paths: consumers with `(module = commonjs) + (skipLibCheck = false)` can't compile the project ([#218](https://github.com/vitalets/playwright-bdd/issues/218)) + ## 7.3.0 * fix: skipped scenarios break cucumber reports ([#143](https://github.com/vitalets/playwright-bdd/issues/143)) * chore: update @cucumber/html-formatter ([#213](https://github.com/vitalets/playwright-bdd/issues/213)) diff --git a/eslint.config.mjs b/eslint.config.mjs index 8e138bb0..100fbeb6 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -52,14 +52,6 @@ export default [ // require is needed for some functions (copied from PW) '@typescript-eslint/no-var-requires': 0, '@typescript-eslint/no-require-imports': 0, - 'no-restricted-imports': [ - 'error', - { - // restrict high parent imports in favor of import subpaths (not path alias!) - // https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-imports-and-self-name-imports - patterns: ['../../../*'], - }, - ], }, }, { diff --git a/package.json b/package.json index 12763028..6c2b9ec1 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,6 @@ "./reporter/cucumber": "./dist/reporter/cucumber/index.js", "./package.json": "./package.json" }, - "imports": { - "#*": { - "pw-bdd-dev": "./src/*", - "default": "./dist/*" - } - }, "engines": { "node": ">=18" }, diff --git a/src/cli/commands/env.ts b/src/cli/commands/env.ts index 6eaccdea..ddceb92b 100644 --- a/src/cli/commands/env.ts +++ b/src/cli/commands/env.ts @@ -2,7 +2,7 @@ import { Command } from 'commander'; import { ConfigOption } from '../options'; import { Logger } from '../../utils/logger'; import { getPackageVersion } from '../../utils'; -import { resolveConfigFile } from '#playwright/loadConfig.js'; +import { resolveConfigFile } from '../../playwright/loadConfig.js'; import { relativeToCwd } from '../../utils/paths'; const logger = new Logger({ verbose: true }); diff --git a/src/reporter/cucumber/base.ts b/src/reporter/cucumber/base.ts index e0d38bdb..b3c97e62 100644 --- a/src/reporter/cucumber/base.ts +++ b/src/reporter/cucumber/base.ts @@ -8,7 +8,7 @@ import fs from 'node:fs'; import { Writable } from 'node:stream'; import { finished } from 'node:stream/promises'; import { EventEmitter } from 'node:events'; -import EventDataCollector from '#cucumber/formatter/EventDataCollector.js'; +import EventDataCollector from '../../cucumber/formatter/EventDataCollector.js'; export type InternalOptions = { cwd: string; diff --git a/src/reporter/cucumber/messagesBuilder/AttachmentMapper.ts b/src/reporter/cucumber/messagesBuilder/AttachmentMapper.ts index 0a7fdd95..82309aff 100644 --- a/src/reporter/cucumber/messagesBuilder/AttachmentMapper.ts +++ b/src/reporter/cucumber/messagesBuilder/AttachmentMapper.ts @@ -55,10 +55,10 @@ * 2.4 remove found attachment from attachments array */ import * as pw from '@playwright/test/reporter'; -import { AutofillMap } from '#utils/AutofillMap.js'; +import { AutofillMap } from '../../../utils/AutofillMap.js'; import { collectStepsWithCategory, getHooksRootPwStep } from './pwStepUtils'; -import { PwAttachment } from '#playwright/types.js'; -import { stripAnsiEscapes } from '#utils/stripAnsiEscapes.js'; +import { PwAttachment } from '../../../playwright/types.js'; +import { stripAnsiEscapes } from '../../../utils/stripAnsiEscapes.js'; export class AttachmentMapper { private stepAttachments = new AutofillMap(); diff --git a/src/reporter/cucumber/messagesBuilder/GherkinDocument.ts b/src/reporter/cucumber/messagesBuilder/GherkinDocument.ts index 1795ce4c..dfc564db 100644 --- a/src/reporter/cucumber/messagesBuilder/GherkinDocument.ts +++ b/src/reporter/cucumber/messagesBuilder/GherkinDocument.ts @@ -3,9 +3,9 @@ * Attaches extra fields (meta). */ import * as messages from '@cucumber/messages'; -import { GherkinDocumentWithPickles } from '#features/load.js'; +import { GherkinDocumentWithPickles } from '../../../features/load.js'; import { ConcreteEnvelope } from './types'; -import { omit } from '#utils/index.js'; +import { omit } from '../../../utils/index.js'; import { ProjectInfo, getFeatureUriWithProject } from './Projects'; type GherkinDocumentMeta = { diff --git a/src/reporter/cucumber/messagesBuilder/GherkinDocumentClone.ts b/src/reporter/cucumber/messagesBuilder/GherkinDocumentClone.ts index b7a46319..454a5be4 100644 --- a/src/reporter/cucumber/messagesBuilder/GherkinDocumentClone.ts +++ b/src/reporter/cucumber/messagesBuilder/GherkinDocumentClone.ts @@ -3,8 +3,8 @@ * pickle IDs and pickle steps IDs. */ import { randomUUID } from 'node:crypto'; -import { GherkinDocumentWithPickles, PickleWithLocation } from '#features/load.js'; -import { AutofillMap } from '#utils/AutofillMap.js'; +import { GherkinDocumentWithPickles, PickleWithLocation } from '../../../features/load.js'; +import { AutofillMap } from '../../../utils/AutofillMap.js'; export class GherkinDocumentClone { private oldNewIds = new AutofillMap(); diff --git a/src/reporter/cucumber/messagesBuilder/GherkinDocuments.ts b/src/reporter/cucumber/messagesBuilder/GherkinDocuments.ts index bf6060bd..b663709a 100644 --- a/src/reporter/cucumber/messagesBuilder/GherkinDocuments.ts +++ b/src/reporter/cucumber/messagesBuilder/GherkinDocuments.ts @@ -3,16 +3,16 @@ */ import path from 'node:path'; import * as messages from '@cucumber/messages'; -import { AutofillMap } from '#utils/AutofillMap.js'; +import { AutofillMap } from '../../../utils/AutofillMap.js'; import { TestCaseRun } from './TestCaseRun'; -import { FeaturesLoader, GherkinDocumentWithPickles } from '#features/load.js'; -import { getPlaywrightConfigDir } from '#config/configDir.js'; +import { FeaturesLoader, GherkinDocumentWithPickles } from '../../../features/load.js'; +import { getPlaywrightConfigDir } from '../../../config/configDir.js'; import { ConcreteEnvelope } from './types'; import { GherkinDocumentClone } from './GherkinDocumentClone'; import { GherkinDocumentMessage } from './GherkinDocument'; import { ProjectInfo, getFeatureUriWithProject } from './Projects'; -import { getEnvConfigs } from '#config/env.js'; -import { LANG_EN } from '#config/lang.js'; +import { getEnvConfigs } from '../../../config/env.js'; +import { LANG_EN } from '../../../config/lang.js'; export class GherkinDocuments { private featuresLoader = new FeaturesLoader(); diff --git a/src/reporter/cucumber/messagesBuilder/Hook.ts b/src/reporter/cucumber/messagesBuilder/Hook.ts index c7d70d83..3adbe124 100644 --- a/src/reporter/cucumber/messagesBuilder/Hook.ts +++ b/src/reporter/cucumber/messagesBuilder/Hook.ts @@ -5,7 +5,7 @@ import { randomUUID } from 'node:crypto'; import * as pw from '@playwright/test/reporter'; import * as messages from '@cucumber/messages'; -import { getPlaywrightConfigDir } from '#config/configDir.js'; +import { getPlaywrightConfigDir } from '../../../config/configDir.js'; import path from 'node:path'; export type HookType = 'before' | 'after'; diff --git a/src/reporter/cucumber/messagesBuilder/Meta.ts b/src/reporter/cucumber/messagesBuilder/Meta.ts index 4f44e219..f57c2881 100644 --- a/src/reporter/cucumber/messagesBuilder/Meta.ts +++ b/src/reporter/cucumber/messagesBuilder/Meta.ts @@ -4,7 +4,7 @@ */ import os from 'node:os'; import * as messages from '@cucumber/messages'; -import { getPackageVersion } from '#utils/index.js'; +import { getPackageVersion } from '../../../utils/index.js'; export class Meta { buildMessage() { diff --git a/src/reporter/cucumber/messagesBuilder/Pickles.ts b/src/reporter/cucumber/messagesBuilder/Pickles.ts index cfdea85c..f5b8824c 100644 --- a/src/reporter/cucumber/messagesBuilder/Pickles.ts +++ b/src/reporter/cucumber/messagesBuilder/Pickles.ts @@ -2,8 +2,8 @@ * Builds Pickle messages. */ import * as messages from '@cucumber/messages'; -import { omit } from '#utils/index.js'; -import { AutofillMap } from '#utils/AutofillMap.js'; +import { omit } from '../../../utils/index.js'; +import { AutofillMap } from '../../../utils/AutofillMap.js'; import { TestCase } from './TestCase'; import { ConcreteEnvelope } from './types'; import { getFeatureUriWithProject } from './Projects'; diff --git a/src/reporter/cucumber/messagesBuilder/Projects.ts b/src/reporter/cucumber/messagesBuilder/Projects.ts index 46569c76..e03e6b12 100644 --- a/src/reporter/cucumber/messagesBuilder/Projects.ts +++ b/src/reporter/cucumber/messagesBuilder/Projects.ts @@ -4,7 +4,7 @@ * See: https://github.com/microsoft/playwright/issues/29841 */ import * as pw from '@playwright/test/reporter'; -import { AutofillMap } from '#utils/AutofillMap.js'; +import { AutofillMap } from '../../../utils/AutofillMap.js'; export type ProjectInfo = { projectName?: string; diff --git a/src/reporter/cucumber/messagesBuilder/TestCase.ts b/src/reporter/cucumber/messagesBuilder/TestCase.ts index b75cccc0..7aa05cda 100644 --- a/src/reporter/cucumber/messagesBuilder/TestCase.ts +++ b/src/reporter/cucumber/messagesBuilder/TestCase.ts @@ -12,10 +12,10 @@ import * as messages from '@cucumber/messages'; import { TestCaseRun } from './TestCaseRun'; import { Hook, HookType } from './Hook'; -import { GherkinDocumentWithPickles, PickleWithLocation } from '#features/load.js'; -import { stringifyLocation } from '#utils/index.js'; +import { GherkinDocumentWithPickles, PickleWithLocation } from '../../../features/load.js'; +import { stringifyLocation } from '../../../utils/index.js'; import { ProjectInfo } from './Projects'; -import { BddData } from '#run/bddAnnotation/types.js'; +import { BddData } from '../../../run/bddAnnotation/types.js'; type HookWithStep = { hook: Hook; diff --git a/src/reporter/cucumber/messagesBuilder/TestCaseRun.ts b/src/reporter/cucumber/messagesBuilder/TestCaseRun.ts index 3839a355..2fd6c528 100644 --- a/src/reporter/cucumber/messagesBuilder/TestCaseRun.ts +++ b/src/reporter/cucumber/messagesBuilder/TestCaseRun.ts @@ -3,18 +3,18 @@ */ import * as pw from '@playwright/test/reporter'; import * as messages from '@cucumber/messages'; -import { stringifyLocation } from '#utils/index.js'; +import { stringifyLocation } from '../../../utils/index.js'; import { Hook, HookType } from './Hook'; import { TestCase } from './TestCase'; -import { AutofillMap } from '#utils/AutofillMap.js'; +import { AutofillMap } from '../../../utils/AutofillMap.js'; import { TestStepRun, TestStepRunEnvelope } from './TestStepRun'; import { toCucumberTimestamp } from './timing'; import { collectStepsWithCategory, isUnknownDuration } from './pwStepUtils'; import { AttachmentMapper } from './AttachmentMapper'; import { TestCaseRunHooks } from './TestCaseRunHooks'; import { ProjectInfo, getProjectInfo } from './Projects'; -import { BddData, BddDataStep } from '#run/bddAnnotation/types.js'; -import { getBddDataFromTest } from '#run/bddAnnotation/index.js'; +import { BddData, BddDataStep } from '../../../run/bddAnnotation/types.js'; +import { getBddDataFromTest } from '../../../run/bddAnnotation/index.js'; export type TestCaseRunEnvelope = TestStepRunEnvelope & Pick< diff --git a/src/reporter/cucumber/messagesBuilder/TestStepAttachments.ts b/src/reporter/cucumber/messagesBuilder/TestStepAttachments.ts index fd912a4f..834b0771 100644 --- a/src/reporter/cucumber/messagesBuilder/TestStepAttachments.ts +++ b/src/reporter/cucumber/messagesBuilder/TestStepAttachments.ts @@ -5,7 +5,7 @@ import fs from 'node:fs'; import * as pw from '@playwright/test/reporter'; import * as messages from '@cucumber/messages'; import { TestCaseRun } from './TestCaseRun'; -import { PwAttachment } from '#playwright/types.js'; +import { PwAttachment } from '../../../playwright/types.js'; import path from 'node:path'; export class TestStepAttachments { diff --git a/src/reporter/cucumber/messagesBuilder/TestStepRun.ts b/src/reporter/cucumber/messagesBuilder/TestStepRun.ts index cd066ed2..2d784af4 100644 --- a/src/reporter/cucumber/messagesBuilder/TestStepRun.ts +++ b/src/reporter/cucumber/messagesBuilder/TestStepRun.ts @@ -9,7 +9,7 @@ */ import * as pw from '@playwright/test/reporter'; import * as messages from '@cucumber/messages'; -import { stripAnsiEscapes } from '#utils/stripAnsiEscapes.js'; +import { stripAnsiEscapes } from '../../../utils/stripAnsiEscapes.js'; import { TestCaseRun } from './TestCaseRun'; import { toCucumberTimestamp } from './timing'; import { TestStepAttachments } from './TestStepAttachments'; diff --git a/src/reporter/cucumber/messagesBuilder/index.ts b/src/reporter/cucumber/messagesBuilder/index.ts index 325cd854..c3d22057 100644 --- a/src/reporter/cucumber/messagesBuilder/index.ts +++ b/src/reporter/cucumber/messagesBuilder/index.ts @@ -8,13 +8,13 @@ import { TestCase } from './TestCase'; import { Meta } from './Meta'; import { TimeMeasured, calcMinMaxByArray, toCucumberTimestamp } from './timing'; import EventEmitter from 'node:events'; -import EventDataCollector from '#cucumber/formatter/EventDataCollector.js'; +import EventDataCollector from '../../../cucumber/formatter/EventDataCollector.js'; import { Hook } from './Hook'; -import { AutofillMap } from '#utils/AutofillMap.js'; +import { AutofillMap } from '../../../utils/AutofillMap.js'; import { GherkinDocuments } from './GherkinDocuments'; import { Pickles } from './Pickles'; import { ConcreteEnvelope } from './types'; -import { hasBddConfig } from '#config/env.js'; +import { hasBddConfig } from '../../../config/env.js'; export class MessagesBuilder { private report = { diff --git a/tsconfig.json b/tsconfig.json index 87ad18c0..75d57a33 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,6 @@ "useUnknownInCatchVariables": false, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, - "customConditions": ["pw-bdd-dev"], "noEmit": true, "resolveJsonModule": true, "jsx": "react-jsx"