Skip to content

feat(jest-haste-map): support dependencyExtractor written in ESM - #12008

Merged
SimenB merged 9 commits into
jestjs:mainfrom
chentsulin:import-dependencyExtractor
Feb 24, 2022
Merged

feat(jest-haste-map): support dependencyExtractor written in ESM#12008
SimenB merged 9 commits into
jestjs:mainfrom
chentsulin:import-dependencyExtractor

Conversation

@chentsulin

Copy link
Copy Markdown
Contributor

Summary

Part of #11167.

See the discussion on the dependencyExtractor config: #11167 (comment)

Test plan

  • Integration test added.
  • Converted new HasteMap(...) calls to await HasteMap.create(...)
  • Converted Runtime.createHasteMap(...) calls to await Runtime.createHasteMap(...)

Comment thread packages/jest-haste-map/src/index.ts Outdated
Comment thread packages/jest-haste-map/src/worker.ts Outdated
@chentsulin
chentsulin force-pushed the import-dependencyExtractor branch from 5c21bae to db74246 Compare October 28, 2021 09:26
}

static create(options: Options): HasteMap {
static async create(options: Options): Promise<HasteMap> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code in general looks good, but this makes it a breaking change and must wait for Jest 28 🙂 I'll add it to the milestone so we don't forget

@SimenB SimenB added this to the Jest 28 milestone Oct 28, 2021
@chentsulin
chentsulin force-pushed the import-dependencyExtractor branch 3 times, most recently from 8cce621 to f59420e Compare October 28, 2021 11:36
Comment thread e2e/__tests__/findRelatedFiles.test.ts Outdated
'a.js': 'module.exports = {foo: 5};',
'dependencyExtractor.mjs': `
const DYNAMIC_IMPORT_RE = /(?:^|[^.]\\s*)(\\bdynamicImport\\s*?\\(\\s*?)([\`'"])([^\`'"]+)(\\2\\s*?\\))/g;
export function extract(code, filePath) {

@chentsulin chentsulin Oct 28, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.