diff --git a/src/plugin.test.ts b/src/plugin.test.ts index 9cb90bc..66809c3 100644 --- a/src/plugin.test.ts +++ b/src/plugin.test.ts @@ -340,6 +340,21 @@ describe("runtimeVersion 1", () => { expect(output).toMatchSnapshot() }) + it("removes `node:` import prefixes", async (ctx) => { + const input = dedent` + import crypto from "node:crypto" + + var hash = crypto.createHash("sha1") + hash.update("data") + hash.digest("base64") + ` + const result = await buildFile(ctx, input) + + const output = getOutput(result) + expect(output).not.toContain("node:") + expect(output).toContain('from "crypto"') + }) + it("minification does not rename handler function", async (ctx) => { const input = dedent` function handler(event: Record) { @@ -672,6 +687,22 @@ describe("runtimeVersion 2", () => { const output = getOutput(result) expect(output).toMatchSnapshot() }) + + it("removes `node:` import prefixes", async (ctx) => { + const input = dedent` + import crypto from "node:crypto" + + var hash = crypto.createHash("sha1") + hash.update("data") + hash.digest("base64") + ` + const result = await buildFile(ctx, input) + + const output = getOutput(result) + expect(output).not.toContain("node:") + expect(output).toContain('from "crypto"') + }) + it("minification does not rename handler function", async (ctx) => { const input = dedent` function handler(event: Record) { diff --git a/src/plugin.ts b/src/plugin.ts index 333c23b..6907207 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -13,6 +13,9 @@ const supportedV1 = { "rest-argument": true, // ES 9 named capture groups are supported. "regexp-named-capture-groups": true, + // Cannot use `node:` prefixes + "node-colon-prefix-import": false, + "node-colon-prefix-require": false, } const supportedV2 = {