From 6e61677d6ecf3e9b08e979f878f9cfce1f0debcb Mon Sep 17 00:00:00 2001 From: davidgoss Date: Wed, 21 Apr 2021 14:11:37 +0100 Subject: [PATCH 1/2] Revert "cli: esm support (#1589)" This reverts commit 1a8bc7946aa2836b5f6a34dd920e030c81760cca. --- dependency-lint.yml | 1 - docs/cli.md | 16 ---- features/esm.feature | 80 ----------------- features/support/hooks.ts | 14 +-- package.json | 7 +- src/cli/argv_parser.ts | 2 - src/cli/configuration_builder.ts | 4 +- src/cli/configuration_builder_spec.ts | 91 ++++---------------- src/cli/helpers.ts | 8 +- src/cli/index.ts | 28 ++---- src/cli/profile_loader.ts | 12 +-- src/cli/profile_loader_spec.ts | 5 +- src/formatter/builder.ts | 74 ++++++---------- src/formatter/helpers/issue_helpers_spec.ts | 3 +- src/formatter/progress_bar_formatter_spec.ts | 5 +- src/importers.js | 17 ---- src/wrapper.mjs | 38 -------- test/formatter_helpers.ts | 3 +- tsconfig.json | 4 +- yarn.lock | 2 +- 20 files changed, 68 insertions(+), 346 deletions(-) delete mode 100644 features/esm.feature delete mode 100644 src/importers.js delete mode 100644 src/wrapper.mjs diff --git a/dependency-lint.yml b/dependency-lint.yml index a4c469fc7..d85654c33 100644 --- a/dependency-lint.yml +++ b/dependency-lint.yml @@ -43,7 +43,6 @@ requiredModules: - 'dist/**/*' - 'lib/**/*' - 'node_modules/**/*' - - 'src/importers.js' - 'tmp/**/*' root: '**/*.{js,ts}' stripLoaders: false diff --git a/docs/cli.md b/docs/cli.md index 2f2d86258..9b8a1acd1 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -81,22 +81,6 @@ You can pass in format options with `--format-options `. The JSON string m * Suggested use: add with profiles so you can define an object and use `JSON.stringify` instead of writing `JSON` manually. -## ES Modules (experimental) (Node.js 12+) - -You can optionally write your support code (steps, hooks, etc) with native ES modules syntax - i.e. using `import` and `export` statements without transpiling. - -To enable this, run with the `--esm` flag. - -This will also expand the default glob for support files to include the `.mjs` file extension. - -As well as support code, these things can also be in ES modules syntax: - -- Custom formatters -- Custom snippets -- Your `cucumber.js` config file - -You can use ES modules selectively/incrementally - the module loading strategy that the `--esm` flag activates supports both ES modules and CommonJS. - ## Colors Colors can be disabled with `--format-options '{"colorsEnabled": false}'` diff --git a/features/esm.feature b/features/esm.feature deleted file mode 100644 index 96397709c..000000000 --- a/features/esm.feature +++ /dev/null @@ -1,80 +0,0 @@ -Feature: ES modules support - - cucumber-js works with native ES modules, via a Cli flag `--esm` - - @esm - Scenario Outline: native module syntax works when using --esm - Given a file named "features/a.feature" with: - """ - Feature: - Scenario: one - Given a step passes - - Scenario: two - Given a step passes - """ - And a file named "features/step_definitions/cucumber_steps.js" with: - """ - import {Given} from '@cucumber/cucumber' - - Given(/^a step passes$/, function() {}); - """ - And a file named "cucumber.js" with: - """ - export default { - 'default': '--format message:messages.ndjson', - } - """ - And a file named "custom-formatter.js" with: - """ - import {SummaryFormatter} from '@cucumber/cucumber' - - export default class CustomFormatter extends SummaryFormatter {} - """ - And a file named "custom-snippet-syntax.js" with: - """ - export default class CustomSnippetSyntax { - build(opts) { - return 'hello world' - } - } - """ - When I run cucumber-js with ` --format ./custom-formatter.js --format-options '{"snippetSyntax": "./custom-snippet-syntax.js"}'` - Then it passes - Examples: - | options | - | --esm | - | --esm --parallel 2 | - - @esm - Scenario: .mjs support code files are matched by default when using --esm - Given a file named "features/a.feature" with: - """ - Feature: - Scenario: - Given a step passes - """ - And a file named "features/step_definitions/cucumber_steps.mjs" with: - """ - import {Given} from '@cucumber/cucumber' - - Given(/^a step passes$/, function() {}); - """ - When I run cucumber-js with `--esm` - Then it passes - - Scenario: native module syntax doesn't work without --esm - Given a file named "features/a.feature" with: - """ - Feature: - Scenario: - Given a step passes - """ - And a file named "features/step_definitions/cucumber_steps.js" with: - """ - import {Given} from '@cucumber/cucumber' - - Given(/^a step passes$/, function() {}); - """ - When I run cucumber-js - Then it fails \ No newline at end of file diff --git a/features/support/hooks.ts b/features/support/hooks.ts index a5f056d55..04d5bee06 100644 --- a/features/support/hooks.ts +++ b/features/support/hooks.ts @@ -13,7 +13,7 @@ Before('@debug', function (this: World) { this.debug = true }) -Before('@spawn or @esm', function (this: World) { +Before('@spawn', function (this: World) { this.spawn = true }) @@ -43,18 +43,6 @@ Before(function ( this.localExecutablePath = path.join(projectPath, 'bin', 'cucumber-js') }) -Before('@esm', function (this: World) { - const [majorVersion] = process.versions.node.split('.') - if (Number(majorVersion) < 12) { - return 'skipped' - } - fsExtra.writeJSONSync(path.join(this.tmpDir, 'package.json'), { - name: 'feature-test-pickle', - type: 'module', - }) - return undefined -}) - Before('@global-install', function (this: World) { const tmpObject = tmp.dirSync({ unsafeCleanup: true }) diff --git a/package.json b/package.json index 65da3aedd..9adb942fb 100644 --- a/package.json +++ b/package.json @@ -163,10 +163,6 @@ "lib": "./lib" }, "main": "./lib/index.js", - "exports": { - "import": "./lib/wrapper.mjs", - "require": "./lib/index.js" - }, "types": "./lib/index.d.ts", "engines": { "node": ">=10" @@ -186,6 +182,7 @@ "cli-table3": "^0.6.0", "colors": "^1.4.0", "commander": "^7.0.0", + "create-require": "^1.1.1", "duration": "^0.2.2", "durations": "^3.4.2", "figures": "^3.2.0", @@ -260,7 +257,7 @@ "typescript": "4.2.3" }, "scripts": { - "build-local": "tsc -p tsconfig.node.json && cp src/importers.js lib/ && cp src/wrapper.mjs lib/", + "build-local": "tsc -p tsconfig.node.json", "cck-test": "mocha 'compatibility/**/*_spec.ts'", "feature-test": "node ./bin/cucumber-js", "html-formatter": "node ./bin/cucumber-js --profile htmlFormatter", diff --git a/src/cli/argv_parser.ts b/src/cli/argv_parser.ts index 94e828009..1a80381fc 100644 --- a/src/cli/argv_parser.ts +++ b/src/cli/argv_parser.ts @@ -22,7 +22,6 @@ export interface IParsedArgvFormatOptions { export interface IParsedArgvOptions { backtrace: boolean dryRun: boolean - esm: boolean exit: boolean failFast: boolean format: string[] @@ -113,7 +112,6 @@ const ArgvParser = { 'invoke formatters without executing steps', false ) - .option('--esm', 'import support code via ES module imports', false) .option( '--exit', 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit', diff --git a/src/cli/configuration_builder.ts b/src/cli/configuration_builder.ts index 7c86484af..e830b11c5 100644 --- a/src/cli/configuration_builder.ts +++ b/src/cli/configuration_builder.ts @@ -19,7 +19,6 @@ export interface IConfigurationFormat { } export interface IConfiguration { - esm: boolean featureDefaultLanguage: string featurePaths: string[] formats: IConfigurationFormat[] @@ -81,11 +80,10 @@ export default class ConfigurationBuilder { } supportCodePaths = await this.expandPaths( unexpandedSupportCodePaths, - this.options.esm ? '.@(js|mjs)' : '.js' + '.js' ) } return { - esm: this.options.esm, featureDefaultLanguage: this.options.language, featurePaths, formats: this.getFormats(), diff --git a/src/cli/configuration_builder_spec.ts b/src/cli/configuration_builder_spec.ts index 61cda90c1..46138c50e 100644 --- a/src/cli/configuration_builder_spec.ts +++ b/src/cli/configuration_builder_spec.ts @@ -29,7 +29,6 @@ describe('Configuration', () => { // Assert expect(result).to.eql({ - esm: false, featureDefaultLanguage: 'en', featurePaths: [], formatOptions: {}, @@ -66,79 +65,27 @@ describe('Configuration', () => { }) describe('path to a feature', () => { - describe('without esm', () => { - it('returns the appropriate feature and support code paths', async function () { - // Arrange - const cwd = await buildTestWorkingDirectory() - const relativeFeaturePath = path.join('features', 'a.feature') - const featurePath = path.join(cwd, relativeFeaturePath) - await fsExtra.outputFile(featurePath, '') - const supportCodePath = path.join(cwd, 'features', 'a.js') - await fsExtra.outputFile(supportCodePath, '') - const argv = baseArgv.concat([relativeFeaturePath]) - - // Act - const { - featurePaths, - pickleFilterOptions, - supportCodePaths, - } = await ConfigurationBuilder.build({ argv, cwd }) - - // Assert - expect(featurePaths).to.eql([featurePath]) - expect(pickleFilterOptions.featurePaths).to.eql([relativeFeaturePath]) - expect(supportCodePaths).to.eql([supportCodePath]) - }) - }) + it('returns the appropriate feature and support code paths', async function () { + // Arrange + const cwd = await buildTestWorkingDirectory() + const relativeFeaturePath = path.join('features', 'a.feature') + const featurePath = path.join(cwd, relativeFeaturePath) + await fsExtra.outputFile(featurePath, '') + const supportCodePath = path.join(cwd, 'features', 'a.js') + await fsExtra.outputFile(supportCodePath, '') + const argv = baseArgv.concat([relativeFeaturePath]) - describe('with esm and js support files', () => { - it('returns the appropriate feature and support code paths', async function () { - // Arrange - const cwd = await buildTestWorkingDirectory() - const relativeFeaturePath = path.join('features', 'a.feature') - const featurePath = path.join(cwd, relativeFeaturePath) - await fsExtra.outputFile(featurePath, '') - const supportCodePath = path.join(cwd, 'features', 'a.js') - await fsExtra.outputFile(supportCodePath, '') - const argv = baseArgv.concat([relativeFeaturePath, '--esm']) - - // Act - const { - featurePaths, - pickleFilterOptions, - supportCodePaths, - } = await ConfigurationBuilder.build({ argv, cwd }) - - // Assert - expect(featurePaths).to.eql([featurePath]) - expect(pickleFilterOptions.featurePaths).to.eql([relativeFeaturePath]) - expect(supportCodePaths).to.eql([supportCodePath]) - }) - }) + // Act + const { + featurePaths, + pickleFilterOptions, + supportCodePaths, + } = await ConfigurationBuilder.build({ argv, cwd }) - describe('with esm and mjs support files', () => { - it('returns the appropriate feature and support code paths', async function () { - // Arrange - const cwd = await buildTestWorkingDirectory() - const relativeFeaturePath = path.join('features', 'a.feature') - const featurePath = path.join(cwd, relativeFeaturePath) - await fsExtra.outputFile(featurePath, '') - const supportCodePath = path.join(cwd, 'features', 'a.mjs') - await fsExtra.outputFile(supportCodePath, '') - const argv = baseArgv.concat([relativeFeaturePath, '--esm']) - - // Act - const { - featurePaths, - pickleFilterOptions, - supportCodePaths, - } = await ConfigurationBuilder.build({ argv, cwd }) - - // Assert - expect(featurePaths).to.eql([featurePath]) - expect(pickleFilterOptions.featurePaths).to.eql([relativeFeaturePath]) - expect(supportCodePaths).to.eql([supportCodePath]) - }) + // Assert + expect(featurePaths).to.eql([featurePath]) + expect(pickleFilterOptions.featurePaths).to.eql([relativeFeaturePath]) + expect(supportCodePaths).to.eql([supportCodePath]) }) }) diff --git a/src/cli/helpers.ts b/src/cli/helpers.ts index 514b22460..c56414f22 100644 --- a/src/cli/helpers.ts +++ b/src/cli/helpers.ts @@ -16,9 +16,6 @@ import TestCaseHookDefinition from '../models/test_case_hook_definition' import TestRunHookDefinition from '../models/test_run_hook_definition' import { builtinParameterTypes } from '../support_code_library_builder' -// eslint-disable-next-line @typescript-eslint/no-var-requires -const importers = require('../importers') - const StepDefinitionPatternType = messages.StepDefinition.StepDefinitionPattern.StepDefinitionPatternType @@ -32,11 +29,8 @@ export async function getExpandedArgv({ cwd, }: IGetExpandedArgvRequest): Promise { const { options } = ArgvParser.parse(argv) - const importer = options.esm ? importers.esm : importers.legacy let fullArgv = argv - const profileArgv = await new ProfileLoader(cwd, importer).getArgv( - options.profile - ) + const profileArgv = await new ProfileLoader(cwd).getArgv(options.profile) if (profileArgv.length > 0) { fullArgv = _.concat(argv.slice(0, 2), profileArgv, argv.slice(2)) } diff --git a/src/cli/index.ts b/src/cli/index.ts index a8e5f3672..25020be63 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -30,8 +30,6 @@ import { IParsedArgvFormatOptions } from './argv_parser' import HttpStream from '../formatter/http_stream' import { Writable } from 'stream' -// eslint-disable-next-line @typescript-eslint/no-var-requires -const importers = require('../importers') const { incrementing, uuid } = IdGenerator export interface ICliRunResult { @@ -53,16 +51,10 @@ interface IGetSupportCodeLibraryRequest { supportCodePaths: string[] } -export type IUserCodeImporter = ( - path: string, - isFilePath?: boolean -) => Promise - export default class Cli { private readonly argv: string[] private readonly cwd: string private readonly stdout: IFormatterStream - private importer: IUserCodeImporter = importers.legacy constructor({ argv, @@ -133,7 +125,6 @@ export default class Cli { eventDataCollector, log: stream.write.bind(stream), parsedArgvOptions: formatOptions, - importer: this.importer, stream, cleanup: stream === this.stdout @@ -151,7 +142,7 @@ export default class Cli { ) type = 'progress' } - return await FormatterBuilder.build(type, typeOptions) + return FormatterBuilder.build(type, typeOptions) } ) return async function () { @@ -161,18 +152,14 @@ export default class Cli { } } - async getSupportCodeLibrary({ + getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, - }: IGetSupportCodeLibraryRequest): Promise { - for (const requiredModule of supportCodeRequiredModules) { - await this.importer(requiredModule) - } + }: IGetSupportCodeLibraryRequest): ISupportCodeLibrary { + supportCodeRequiredModules.map((module) => require(module)) supportCodeLibraryBuilder.reset(this.cwd, newId) - for (const codePath of supportCodePaths) { - await this.importer(codePath, true) - } + supportCodePaths.forEach((codePath) => require(codePath)) return supportCodeLibraryBuilder.finalize() } @@ -191,10 +178,7 @@ export default class Cli { configuration.predictableIds && configuration.parallel <= 1 ? incrementing() : uuid() - if (configuration.esm) { - this.importer = importers.esm - } - const supportCodeLibrary = await this.getSupportCodeLibrary({ + const supportCodeLibrary = this.getSupportCodeLibrary({ newId, supportCodePaths: configuration.supportCodePaths, supportCodeRequiredModules: configuration.supportCodeRequiredModules, diff --git a/src/cli/profile_loader.ts b/src/cli/profile_loader.ts index 893fe32b1..0dd9b6344 100644 --- a/src/cli/profile_loader.ts +++ b/src/cli/profile_loader.ts @@ -3,13 +3,13 @@ import fs from 'mz/fs' import path from 'path' import stringArgv from 'string-argv' import { doesHaveValue, doesNotHaveValue } from '../value_checker' -import { IUserCodeImporter } from './index' export default class ProfileLoader { - constructor( - private readonly directory: string, - private readonly importer: IUserCodeImporter - ) {} + private readonly directory: string + + constructor(directory: string) { + this.directory = directory + } async getDefinitions(): Promise> { const definitionsFilePath = path.join(this.directory, 'cucumber.js') @@ -17,7 +17,7 @@ export default class ProfileLoader { if (!exists) { return {} } - const definitions = await this.importer(definitionsFilePath, true) + const definitions = require(definitionsFilePath) // eslint-disable-line @typescript-eslint/no-var-requires if (typeof definitions !== 'object') { throw new Error(`${definitionsFilePath} does not export an object`) } diff --git a/src/cli/profile_loader_spec.ts b/src/cli/profile_loader_spec.ts index d8813fcc6..a57d52ccd 100644 --- a/src/cli/profile_loader_spec.ts +++ b/src/cli/profile_loader_spec.ts @@ -7,9 +7,6 @@ import tmp, { DirOptions } from 'tmp' import { promisify } from 'util' import { doesHaveValue, valueOrDefault } from '../value_checker' -// eslint-disable-next-line @typescript-eslint/no-var-requires -const importers = require('../importers') - interface TestProfileLoaderOptions { definitionsFileContent?: string profiles?: string[] @@ -27,7 +24,7 @@ async function testProfileLoader( opts.definitionsFileContent ) } - const profileLoader = new ProfileLoader(cwd, importers.legacy) + const profileLoader = new ProfileLoader(cwd) return await profileLoader.getArgv(valueOrDefault(opts.profiles, [])) } diff --git a/src/formatter/builder.ts b/src/formatter/builder.ts index 4f6d2b10d..27da244eb 100644 --- a/src/formatter/builder.ts +++ b/src/formatter/builder.ts @@ -20,11 +20,10 @@ import { Writable as WritableStream } from 'stream' import { IParsedArgvFormatOptions } from '../cli/argv_parser' import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax' import HtmlFormatter from './html_formatter' -import { IUserCodeImporter } from '../cli' +import createRequire from 'create-require' interface IGetStepDefinitionSnippetBuilderOptions { cwd: string - importer: IUserCodeImporter snippetInterface?: SnippetInterface snippetSyntax?: string supportCodeLibrary: ISupportCodeLibrary @@ -36,29 +35,24 @@ export interface IBuildOptions { eventDataCollector: EventDataCollector log: IFormatterLogFn parsedArgvOptions: IParsedArgvFormatOptions - importer: IUserCodeImporter stream: WritableStream cleanup: IFormatterCleanupFn supportCodeLibrary: ISupportCodeLibrary } const FormatterBuilder = { - async build(type: string, options: IBuildOptions): Promise { - const FormatterConstructor = await FormatterBuilder.getConstructorByType( + build(type: string, options: IBuildOptions): Formatter { + const FormatterConstructor = FormatterBuilder.getConstructorByType( type, - options.cwd, - options.importer + options.cwd ) const colorFns = getColorFns(options.parsedArgvOptions.colorsEnabled) - const snippetBuilder = await FormatterBuilder.getStepDefinitionSnippetBuilder( - { - cwd: options.cwd, - importer: options.importer, - snippetInterface: options.parsedArgvOptions.snippetInterface, - snippetSyntax: options.parsedArgvOptions.snippetSyntax, - supportCodeLibrary: options.supportCodeLibrary, - } - ) + const snippetBuilder = FormatterBuilder.getStepDefinitionSnippetBuilder({ + cwd: options.cwd, + snippetInterface: options.parsedArgvOptions.snippetInterface, + snippetSyntax: options.parsedArgvOptions.snippetSyntax, + supportCodeLibrary: options.supportCodeLibrary, + }) return new FormatterConstructor({ colorFns, snippetBuilder, @@ -66,11 +60,7 @@ const FormatterBuilder = { }) }, - async getConstructorByType( - type: string, - cwd: string, - importer: IUserCodeImporter - ): Promise { + getConstructorByType(type: string, cwd: string): typeof Formatter { switch (type) { case 'json': return JsonFormatter @@ -93,13 +83,12 @@ const FormatterBuilder = { case 'usage-json': return UsageJsonFormatter default: - return await FormatterBuilder.loadCustomFormatter(type, cwd, importer) + return FormatterBuilder.loadCustomFormatter(type, cwd) } }, - async getStepDefinitionSnippetBuilder({ + getStepDefinitionSnippetBuilder({ cwd, - importer, snippetInterface, snippetSyntax, supportCodeLibrary, @@ -110,8 +99,7 @@ const FormatterBuilder = { let Syntax = JavascriptSnippetSyntax if (doesHaveValue(snippetSyntax)) { const fullSyntaxPath = path.resolve(cwd, snippetSyntax) - Syntax = await importer(fullSyntaxPath, true) - Syntax = FormatterBuilder.resolveConstructor(Syntax) + Syntax = require(fullSyntaxPath) // eslint-disable-line @typescript-eslint/no-var-requires } return new StepDefinitionSnippetBuilder({ snippetSyntax: new Syntax(snippetInterface), @@ -119,34 +107,20 @@ const FormatterBuilder = { }) }, - async loadCustomFormatter( - customFormatterPath: string, - cwd: string, - importer: IUserCodeImporter - ) { - let CustomFormatter = customFormatterPath.startsWith(`.`) - ? await importer(path.resolve(cwd, customFormatterPath), true) - : await importer(customFormatterPath) - CustomFormatter = FormatterBuilder.resolveConstructor(CustomFormatter) - if (doesHaveValue(CustomFormatter)) { - return CustomFormatter - } else { - throw new Error( - `Custom formatter (${customFormatterPath}) does not export a function` - ) - } - }, + loadCustomFormatter(customFormatterPath: string, cwd: string) { + const CustomFormatter = createRequire(cwd)(customFormatterPath) - resolveConstructor(ImportedCode: any) { - if (typeof ImportedCode === 'function') { - return ImportedCode + if (typeof CustomFormatter === 'function') { + return CustomFormatter } else if ( - doesHaveValue(ImportedCode) && - typeof ImportedCode.default === 'function' + doesHaveValue(CustomFormatter) && + typeof CustomFormatter.default === 'function' ) { - return ImportedCode.default + return CustomFormatter.default } - return null + throw new Error( + `Custom formatter (${customFormatterPath}) does not export a function` + ) }, } diff --git a/src/formatter/helpers/issue_helpers_spec.ts b/src/formatter/helpers/issue_helpers_spec.ts index 5afa258a6..ddae29f74 100644 --- a/src/formatter/helpers/issue_helpers_spec.ts +++ b/src/formatter/helpers/issue_helpers_spec.ts @@ -23,9 +23,8 @@ async function testFormatIssue(sourceData: string): Promise { cwd: 'project/', colorFns: getColorFns(false), number: 1, - snippetBuilder: await FormatterBuilder.getStepDefinitionSnippetBuilder({ + snippetBuilder: FormatterBuilder.getStepDefinitionSnippetBuilder({ cwd: 'project/', - importer: async (path) => await import(path), supportCodeLibrary, }), supportCodeLibrary, diff --git a/src/formatter/progress_bar_formatter_spec.ts b/src/formatter/progress_bar_formatter_spec.ts index deff57861..9ff6712f4 100644 --- a/src/formatter/progress_bar_formatter_spec.ts +++ b/src/formatter/progress_bar_formatter_spec.ts @@ -55,17 +55,16 @@ async function testProgressBarFormatter({ output += data } const passThrough = new PassThrough() - const progressBarFormatter = (await FormatterBuilder.build('progress-bar', { + const progressBarFormatter = FormatterBuilder.build('progress-bar', { cwd: '', eventBroadcaster, eventDataCollector: new EventDataCollector(eventBroadcaster), log: logFn, parsedArgvOptions: {}, - importer: async (path) => await import(path), stream: passThrough, cleanup: bluebird.promisify(passThrough.end.bind(passThrough)), supportCodeLibrary, - })) as ProgressBarFormatter + }) as ProgressBarFormatter let mocked = false for (const envelope of envelopes) { eventBroadcaster.emit('envelope', envelope) diff --git a/src/importers.js b/src/importers.js deleted file mode 100644 index 0a125fdec..000000000 --- a/src/importers.js +++ /dev/null @@ -1,17 +0,0 @@ -/* -Provides the async `import()` function to source code that needs it, -without having it transpiled down to commonjs `require()` by TypeScript. -When we drop Node 10 support, we'll stop transpiling to commonjs and remove this. - */ - -const { pathToFileURL } = require('url') - -module.exports = { - legacy: async (descriptor) => await Promise.resolve(require(descriptor)), - esm: async (descriptor, isFilePath) => { - if (isFilePath) { - descriptor = pathToFileURL(descriptor).toString() - } - return await import(descriptor) - }, -} diff --git a/src/wrapper.mjs b/src/wrapper.mjs deleted file mode 100644 index 360d5eee7..000000000 --- a/src/wrapper.mjs +++ /dev/null @@ -1,38 +0,0 @@ -import cucumber from './index.js' - -export const Cli = cucumber.Cli -export const parseGherkinMessageStream = cucumber.parseGherkinMessageStream -export const PickleFilter = cucumber.PickleFilter -export const Runtime = cucumber.Runtime -export const supportCodeLibraryBuilder = cucumber.supportCodeLibraryBuilder -export const Status = cucumber.Status -export const DataTable = cucumber.DataTable - -export const Formatter = cucumber.Formatter -export const FormatterBuilder = cucumber.FormatterBuilder -export const JsonFormatter = cucumber.JsonFormatter -export const ProgressFormatter = cucumber.ProgressFormatter -export const RerunFormatter = cucumber.RerunFormatter -export const SnippetsFormatter = cucumber.SnippetsFormatter -export const SummaryFormatter = cucumber.SummaryFormatter -export const UsageFormatter = cucumber.UsageFormatter -export const UsageJsonFormatter = cucumber.UsageJsonFormatter -export const formatterHelpers = cucumber.formatterHelpers - -export const After = cucumber.After -export const AfterAll = cucumber.AfterAll -export const AfterStep = cucumber.AfterStep -export const Before = cucumber.Before -export const BeforeAll = cucumber.BeforeAll -export const BeforeStep = cucumber.BeforeStep -export const defineParameterType = cucumber.defineParameterType -export const defineStep = cucumber.defineStep -export const Given = cucumber.Given -export const setDefaultTimeout = cucumber.setDefaultTimeout -export const setDefinitionFunctionWrapper = cucumber.setDefinitionFunctionWrapper -export const setWorldConstructor = cucumber.setWorldConstructor -export const Then = cucumber.Then -export const When = cucumber.When - -export const World = cucumber.World - diff --git a/test/formatter_helpers.ts b/test/formatter_helpers.ts index 2b791daf0..b12246b6b 100644 --- a/test/formatter_helpers.ts +++ b/test/formatter_helpers.ts @@ -59,13 +59,12 @@ export async function testFormatter({ output += data } const passThrough = new PassThrough() - await FormatterBuilder.build(type, { + FormatterBuilder.build(type, { cwd: '', eventBroadcaster, eventDataCollector, log: logFn, parsedArgvOptions, - importer: async (path) => await import(path), stream: passThrough, cleanup: bluebird.promisify(passThrough.end.bind(passThrough)), supportCodeLibrary, diff --git a/tsconfig.json b/tsconfig.json index c3204a3cf..fdb94c5fc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "esModuleInterop": true, - "lib": ["es2018"], + "lib": ["es2017"], "module": "commonjs", "noImplicitAny": true, "noImplicitReturns": true, @@ -9,7 +9,7 @@ "resolveJsonModule": true, "sourceMap": true, "inlineSources": true, - "target": "es2018", + "target": "es2017", "typeRoots": [ "./node_modules/@types", "./src/types" diff --git a/yarn.lock b/yarn.lock index a17b699e7..ce9e2cb80 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1359,7 +1359,7 @@ core-util-is@1.0.2: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -create-require@^1.1.0: +create-require@^1.1.0, create-require@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== From 49e1703176c75994746050d5ee43b350a4f48895 Mon Sep 17 00:00:00 2001 From: davidgoss Date: Wed, 21 Apr 2021 14:12:48 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f827f5616..5f02005e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO ### Fixed +* Temporarily remove ESM changes due to impact on formatters + ## [7.2.0] (2021-04-20) ### Added