Skip to content

Conversation

@TomFryersMidsummer
Copy link
Contributor

Some build-in Node modules, like node:test, have to be imported as node:test, not just test. The old version did not consider these to be built-in.

The new implementation also ought to be faster, being a single Set look-up.

Some build-in Node modules, like node:test, have to be imported as
node:test, not just test. The old version did not consider these to be
built-in.

The new implementation also ought to be faster, being a single Set
look-up.
@vladislavarsenev
Copy link
Collaborator

Hi @TomFryersMidsummer. Thanks for your PR and effort. Can you please provide in what case plugin doesn't consider node:* module as builtin? We have test that covers this case tests/BuiltinModules/snapshots/ppsi.spec.mjs.snap here, and it seems to work fine.

@TomFryersMidsummer
Copy link
Contributor Author

TomFryersMidsummer commented Jan 5, 2026

With this configuration:

...
importOrder:
  - "<BUILTIN_MODULES>"
  - "<THIRD_PARTY_MODULES>"
  - "^[./]"
importOrderSeparation: true

plugins:
  - "@trivago/prettier-plugin-sort-imports"

Prettier was formatting this:

import { describe, it } from "node:test";
import assert from "node:assert/strict";
import request from "supertest";
import { Router } from "express";
import { auth } from "../../src/auth/auth.ts";
import { createServer } from "http";
import { keyRequirementsMet } from "../../src/auth/keyStrategy.js";
import { mockDatabase } from "../../src/utils/database.ts";
...

into this:

import { createServer } from "http";
import assert from "node:assert/strict";

import { Router } from "express";
import { describe, it } from "node:test";
import request from "supertest";

import { auth } from "../../src/auth/auth.ts";
import { keyRequirementsMet } from "../../src/auth/keyStrategy.js";
import { mockDatabase } from "../../src/utils/database.ts";
...

node:test is in the wrong place.

@vladislavarsenev
Copy link
Collaborator

With this configuration:

...
importOrder:
  - "<BUILTIN_MODULES>"
  - "<THIRD_PARTY_MODULES>"
  - "^[./]"
importOrderSeparation: true

plugins:
  - "@trivago/prettier-plugin-sort-imports"

Prettier was formatting this:

import { describe, it } from "node:test";
import assert from "node:assert/strict";
import request from "supertest";
import { Router } from "express";
import { auth } from "../../src/auth/auth.ts";
import { createServer } from "http";
import { keyRequirementsMet } from "../../src/auth/keyStrategy.js";
import { mockDatabase } from "../../src/utils/database.ts";
...

into this:

import { createServer } from "http";
import assert from "node:assert/strict";

import { Router } from "express";
import { describe, it } from "node:test";
import request from "supertest";

import { auth } from "../../src/auth/auth.ts";
import { keyRequirementsMet } from "../../src/auth/keyStrategy.js";
import { mockDatabase } from "../../src/utils/database.ts";
...

node:test is in the wrong place.

I see. Sorry that read description not carefully enough. Your implementation is cleaner indeed and fixes the problem you described earlier. I'll merge it and release soon. Thank you for your effort🙂

@vladislavarsenev vladislavarsenev self-requested a review January 6, 2026 22:20
@vladislavarsenev vladislavarsenev merged commit 97214c3 into trivago:main Jan 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants