Skip to content

Commit

Permalink
chore: remove old importer hack
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgoss committed Oct 7, 2023
1 parent 895b3f7 commit 2c21af5
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 31 deletions.
1 change: 0 additions & 1 deletion dependency-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ requiredModules:
- 'dist/**/*'
- 'lib/**/*'
- 'node_modules/**/*'
- 'src/importer.js'
- 'tmp/**/*'
root: '**/*.{js,ts}'
stripLoaders: false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
"ansi-regex": "^5.0.1"
},
"scripts": {
"build-local": "genversion --es6 src/version.ts && tsc --build tsconfig.node.json && shx cp src/importer.js lib/ && shx cp src/wrapper.mjs lib/ && shx cp src/api/wrapper.mjs lib/api/",
"build-local": "genversion --es6 src/version.ts && tsc --build tsconfig.node.json && shx cp src/wrapper.mjs lib/ && shx cp src/api/wrapper.mjs lib/api/",
"cck-test": "mocha 'compatibility/**/*_spec.ts'",
"docs:ci": "api-extractor run --verbose",
"docs:local": "api-extractor run --verbose --local && api-documenter markdown --input-folder ./tmp/api-extractor --output-folder ./docs/api",
Expand Down
5 changes: 1 addition & 4 deletions src/api/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import supportCodeLibraryBuilder from '../support_code_library_builder'
import { pathToFileURL } from 'url'
import tryRequire from '../try_require'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { importer } = require('../importer')

export async function getSupportCodeLibrary({
cwd,
newId,
Expand All @@ -30,7 +27,7 @@ export async function getSupportCodeLibrary({
requirePaths.map((path) => tryRequire(path))

for (const path of importPaths) {
await importer(pathToFileURL(path))
await import(pathToFileURL(path).toString())
}

return supportCodeLibraryBuilder.finalize()
Expand Down
7 changes: 2 additions & 5 deletions src/configuration/from_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import ArgvParser from './argv_parser'
import { checkSchema } from './check_schema'
import { ILogger } from '../logger'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { importer } = require('../importer')

export async function fromFile(
logger: ILogger,
cwd: string,
Expand Down Expand Up @@ -74,7 +71,7 @@ async function loadFile(
logger.debug(
`Loading configuration file "${file}" as ESM based on extension`
)
definitions = await importer(pathToFileURL(filePath))
definitions = await import(pathToFileURL(filePath).toString())
break
case '.js':
{
Expand All @@ -89,7 +86,7 @@ async function loadFile(
logger.debug(
`Loading configuration file "${file}" as ESM based on "${parentPackage.name}" package type`
)
definitions = await importer(pathToFileURL(filePath))
definitions = await import(pathToFileURL(filePath).toString())
} else {
logger.debug(
`Loading configuration file "${file}" as CommonJS based on "${parentPackage.name}" package type`
Expand Down
4 changes: 1 addition & 3 deletions src/formatter/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { Writable as WritableStream } from 'stream'
import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'
import { pathToFileURL } from 'url'
import Formatters from './helpers/formatters'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { importer } = require('../importer')

interface IGetStepDefinitionSnippetBuilderOptions {
cwd: string
Expand Down Expand Up @@ -120,7 +118,7 @@ const FormatterBuilder = {
},

async loadFile(urlOrName: URL | string) {
return await importer(urlOrName)
return await import(urlOrName.toString())
},

resolveConstructor(ImportedCode: any) {
Expand Down
13 changes: 0 additions & 13 deletions src/importer.js

This file was deleted.

4 changes: 1 addition & 3 deletions src/runtime/parallel/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {
} from './command_types'
import tryRequire from '../../try_require'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { importer } = require('../../importer')
const { uuid } = IdGenerator

type IExitFunction = (exitCode: number, error?: Error, message?: string) => void
Expand Down Expand Up @@ -78,7 +76,7 @@ export default class Worker {
requireModules.map((module) => tryRequire(module))
requirePaths.map((module) => tryRequire(module))
for (const path of importPaths) {
await importer(pathToFileURL(path))
await import(pathToFileURL(path).toString())
}
this.supportCodeLibrary = supportCodeLibraryBuilder.finalize(supportCodeIds)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"esModuleInterop": true,
"lib": ["es2022"],
"module": "commonjs",
"module": "node16",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
Expand Down

0 comments on commit 2c21af5

Please sign in to comment.