Skip to content

Commit

Permalink
Replace old-style import asserts for node compat
Browse files Browse the repository at this point in the history
This `import assert` syntax is experimental, and was removed in newer
Node versions in favor of with `import ... with`.  some node versions
(including Node 18) support both syntaxes

Unsure what minimum node version we need to support - if we can restrict
to Node 18+, then we could instead replace this with `import ... with`

Signed-off-by: Tom Jakubowski <tom@prospective.dev>
  • Loading branch information
tomjakubowski committed Sep 10, 2024
1 parent 13faa99 commit 9cc5960
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
7 changes: 6 additions & 1 deletion packages/perspective-jupyterlab/test/jupyter/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ import { test, expect } from "@playwright/test";
import fs from "fs";
import path from "path";
import rimraf from "rimraf";
import notebook_template from "./notebook_template.json" assert { type: "json" };
import { fileURLToPath } from "url";
import { dirname } from "path";

const __dirname = dirname(fileURLToPath(import.meta.url));
const notebook_template = JSON.parse(
fs.readFileSync(__dirname + "/notebook_template.json", {
encoding: "utf-8",
})
);

const DIST_ROOT = path.join(__dirname, "..", "..", "dist", "esm");
const TEST_CONFIG_ROOT = path.join(__dirname, "..", "config", "jupyter");

Expand Down
4 changes: 3 additions & 1 deletion rust/perspective-python/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import * as fs from "node:fs";
import pkg from "./package.json" assert { type: "json" };
import sh from "../../tools/perspective-scripts/sh.mjs";
import * as url from "url";

const __dirname = url.fileURLToPath(new URL(".", import.meta.url)).slice(0, -1);
const pkg = JSON.parse(
fs.readFileSync(__dirname + "/package.json", { encoding: "utf-8" })
);

let flags = "--release";
if (!!process.env.PSP_DEBUG) {
Expand Down
7 changes: 3 additions & 4 deletions tools/perspective-scripts/install_emsdk.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import os from "os";
import fs from "fs";
import * as dotenv from "dotenv";
import sh from "./sh.mjs";
import * as url from "url";
import { getWorkspaceRoot, getWorkspacePackageJson } from "./workspace.mjs";

const __dirname = url.fileURLToPath(new URL(".", import.meta.url)).slice(0, -1);
const pkg = JSON.parse(fs.readFileSync(`${__dirname}/../../package.json`));
const pkg = getWorkspacePackageJson();

const emscripten = pkg.emscripten;

Expand All @@ -27,7 +26,7 @@ dotenv.config({
});

function base() {
return sh.path`${__dirname}/../../.emsdk`;
return sh.path`${getWorkspaceRoot()}/.emsdk`;
}

function emsdk_checkout() {
Expand Down
7 changes: 3 additions & 4 deletions tools/perspective-scripts/install_llvm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import pkg from "../../package.json" assert { type: "json" };
import os from "os";
import * as fs from "node:fs";
import * as url from "url";
import { mkdirSync } from "fs";
import { execSync } from "child_process";
import path from "path";
import { getWorkspaceRoot, getWorkspacePackageJson } from "./workspace.mjs";

const __dirname = url.fileURLToPath(new URL(".", import.meta.url)).slice(0, -1);
const pkg = getWorkspacePackageJson();

const LLVM_VERSION = pkg.llvm;
const DOWNLOAD_DIR = path.join(`${__dirname}/../../.llvm`, "llvm-toolchain");
const DOWNLOAD_DIR = path.join(getWorkspaceRoot(), ".llvm", "llvm-toolchain");

function getLLVMPackageName() {
const system = os.platform();
Expand Down
4 changes: 3 additions & 1 deletion tools/perspective-scripts/repack_wheel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

import { execSync } from "node:child_process";
import * as fs from "node:fs";
import pkg from "../../package.json" assert { type: "json" };
import { getWorkspacePackageJson } from "./workspace.mjs";

const pkg = getWorkspacePackageJson();

const wheel_file = fs.readdirSync(".").filter((x) => x.endsWith(".whl"))[0];
execSync(`wheel unpack ${wheel_file}`);
Expand Down

0 comments on commit 9cc5960

Please sign in to comment.