diff --git a/src/constants.ts b/src/constants.ts index e044e8f..3ce945c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -23,9 +23,11 @@ export const mergeableImportFlavors = [ importFlavorType, ] as const; -export const BUILTIN_MODULES_REGEX_STR = `^(?:node:)?(?:${builtinModules.join( +// NOTE: 'test' is not included in `builtinModules` so explicitly check for "node:test" +// REF: https://github.com/nodejs/node/issues/42785 +export const BUILTIN_MODULES_REGEX_STR = `(^(?:node:)?(?:${builtinModules.join( '|', -)})$`; +)})$)|(^node:test$)`; export const BUILTIN_MODULES_SPECIAL_WORD = ''; /** diff --git a/tests/BuiltinModulesNodeTest/__snapshots__/ppsi.spec.ts.snap b/tests/BuiltinModulesNodeTest/__snapshots__/ppsi.spec.ts.snap new file mode 100644 index 0000000..eb11fc4 --- /dev/null +++ b/tests/BuiltinModulesNodeTest/__snapshots__/ppsi.spec.ts.snap @@ -0,0 +1,25 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`groups-node-test-with-builtin-modules.js - typescript-verify > groups-node-test-with-builtin-modules.js 1`] = ` +import nodeUtil from 'node:util'; + +import nodeNodeTestTest from 'node:node:test:test'; +import nodeNodeTest from 'node:node:test'; +import nodeTestTest from 'node:test:test'; +import nodeTest from 'node:test'; +import test from 'test' +import node from 'node'; + +import fs from 'fs'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import fs from "fs"; +import nodeTest from "node:test"; +import nodeUtil from "node:util"; + +import node from "node"; +import nodeNodeTest from "node:node:test"; +import nodeNodeTestTest from "node:node:test:test"; +import nodeTestTest from "node:test:test"; +import test from "test"; + +`; diff --git a/tests/BuiltinModulesNodeTest/groups-node-test-with-builtin-modules.js b/tests/BuiltinModulesNodeTest/groups-node-test-with-builtin-modules.js new file mode 100644 index 0000000..f9d301f --- /dev/null +++ b/tests/BuiltinModulesNodeTest/groups-node-test-with-builtin-modules.js @@ -0,0 +1,10 @@ +import nodeUtil from 'node:util'; + +import nodeNodeTestTest from 'node:node:test:test'; +import nodeNodeTest from 'node:node:test'; +import nodeTestTest from 'node:test:test'; +import nodeTest from 'node:test'; +import test from 'test' +import node from 'node'; + +import fs from 'fs'; diff --git a/tests/BuiltinModulesNodeTest/ppsi.spec.ts b/tests/BuiltinModulesNodeTest/ppsi.spec.ts new file mode 100644 index 0000000..6330354 --- /dev/null +++ b/tests/BuiltinModulesNodeTest/ppsi.spec.ts @@ -0,0 +1,12 @@ +import {run_spec} from '../../test-setup/run_spec'; + +run_spec(__dirname, ["typescript"], { + importOrder: [ + "", + "", + "", + "", + "", + "^[.]", + ], +});