Skip to content

Commit

Permalink
Stop using node: imports
Browse files Browse the repository at this point in the history
This was causing issues when the code was included in a server bundle.
The errors looked like this:

Module build failed: UnhandledSchemeError: Reading from "node:os" is not
handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
  • Loading branch information
ezzatron committed Mar 24, 2024
1 parent da18800 commit d753024
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/declaration/binary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffer } from "node:buffer";
import { Buffer } from "buffer";
import {
createLengthConstraint,
type LengthConstraintSpec,
Expand Down
2 changes: 1 addition & 1 deletion src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EOL } from "node:os";
import { EOL } from "os";
import { render as renderSpecification } from "./specification.js";
import { render as renderSummary } from "./summary.js";
import { Results, validate } from "./validation.js";
Expand Down
2 changes: 1 addition & 1 deletion src/specification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { basename } from "node:path";
import { basename } from "path";
import { extrinsicConstraints, type Constraint } from "./constraint.js";
import { createDisjunctionFormatter } from "./list.js";
import { code, inlineCode, italic, list, strong, table } from "./markdown.js";
Expand Down
2 changes: 1 addition & 1 deletion src/table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EOL } from "node:os";
import { EOL } from "os";

const segmenter = new Intl.Segmenter();

Expand Down
4 changes: 2 additions & 2 deletions test/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Console } from "node:console";
import { Transform } from "node:stream";
import { Console } from "console";
import { Transform } from "stream";
import { Mock, vi } from "vitest";

export function noop() {
Expand Down
2 changes: 1 addition & 1 deletion test/suite/declaration/binary.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffer } from "node:buffer";
import { Buffer } from "buffer";
import { describe, expectTypeOf, it } from "vitest";
import { binary, initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";
Expand Down
2 changes: 1 addition & 1 deletion test/suite/declaration/binary.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffer } from "node:buffer";
import { Buffer } from "buffer";
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/binary.js";
Expand Down
4 changes: 2 additions & 2 deletions test/suite/specification.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Temporal } from "@js-temporal/polyfill";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { join } from "path";
import { fileURLToPath } from "url";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { registerVariable } from "../../src/environment.js";
import {
Expand Down
4 changes: 2 additions & 2 deletions test/suite/summary.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Temporal } from "@js-temporal/polyfill";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { join } from "path";
import { fileURLToPath } from "url";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { registerVariable } from "../../src/environment.js";
import {
Expand Down

0 comments on commit d753024

Please sign in to comment.