Skip to content

Commit

Permalink
Merge branch 'master' into feature/high-resolution-screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
seankmartin committed Dec 16, 2024
2 parents ee77c66 + a4404b9 commit bd73859
Show file tree
Hide file tree
Showing 291 changed files with 41,452 additions and 21,552 deletions.
16 changes: 0 additions & 16 deletions .eslintignore

This file was deleted.

68 changes: 0 additions & 68 deletions .eslintrc.yml

This file was deleted.

15 changes: 11 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
tags:
- v**
pull_request:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false

jobs:
client:
Expand Down Expand Up @@ -97,12 +104,12 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Uncomment the action below for an interactive shell
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- uses: ./.github/actions/setup-firefox
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Install Python packaging/test tools
run: pip install tox nox wheel numpy -r python/requirements-test.txt
- uses: ./.github/actions/setup-firefox
- run: nox -s lint format mypy
- name: Check for dirty working directory
run: git diff --exit-code
Expand Down
5 changes: 5 additions & 0 deletions .ncurc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
reject:
# API break
- "gl-matrix"
- "@types/gl-matrix"
- "codemirror"
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ prune examples
exclude .clang-format
exclude .editorconfig
exclude .eslintignore
exclude .eslintrc
exclude .style.yapf
exclude cors_webserver.py
exclude gulpfile.js
Expand All @@ -36,8 +35,9 @@ exclude MANIFEST.in
exclude *.ts
exclude .prettierrc.yml
exclude .prettierignore
exclude .eslintrc.yml
exclude eslint.config.js
exclude .ncurc.yml
exclude index.html
exclude webpack.config.js
exclude rspack.config.js
exclude firebase.json
exclude .firebaserc
27 changes: 20 additions & 7 deletions build_tools/build-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ function buildDeclarationFiles(
program.emit();
}

async function buildPackage(options: { inplace?: boolean }) {
const { inplace = false } = options;
async function buildPackage(options: {
inplace?: boolean;
skipDeclarations?: boolean;
}) {
const { inplace = false, skipDeclarations = false } = options;

const srcDir = path.resolve(rootDir, "src");
const outDir = inplace ? rootDir : path.resolve(rootDir, "dist", "package");
Expand Down Expand Up @@ -80,10 +83,12 @@ async function buildPackage(options: { inplace?: boolean }) {
"./",
).options;
}
buildDeclarationFiles(entryPoints, {
...compilerOptionsFromConfigFile,
outDir: libDir,
});
if (!skipDeclarations) {
buildDeclarationFiles(entryPoints, {
...compilerOptionsFromConfigFile,
outDir: libDir,
});
}

const otherSources = await glob(["**/*.{css,js,html,wasm}"], {
cwd: srcDir,
Expand Down Expand Up @@ -156,6 +161,11 @@ async function parseArgsAndRunMain() {
default: false,
description: "Convert package to built format inplace.",
},
["skip-declarations"]: {
type: "boolean",
default: false,
description: "Skip generating .d.ts files.",
},
["if-not-toplevel"]: {
type: "boolean",
default: false,
Expand Down Expand Up @@ -193,7 +203,10 @@ async function parseArgsAndRunMain() {
return;
}
}
buildPackage({ inplace: argv.inplace });
buildPackage({
inplace: argv.inplace,
skipDeclarations: argv.skipDeclarations,
});
}

if (process.argv[1] === import.meta.filename) {
Expand Down
38 changes: 18 additions & 20 deletions build_tools/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@

// Command-line interface for building Neuroglancer.

/// <reference types="webpack-dev-server" />

import process from "node:process";
import { pathToFileURL } from "node:url";
import path from "path";
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
import type { Configuration } from "webpack";
import webpackCli from "webpack-cli/lib/bootstrap.js"; // eslint-disable-line import/default
import { RspackCLI } from "@rspack/cli";
import type { Configuration } from "@rspack/core";
import ESLintPlugin from "eslint-rspack-plugin";
import { TsCheckerRspackPlugin } from "ts-checker-rspack-plugin";
import * as webpackMerge from "webpack-merge";
import yargs from "yargs";
import { normalizeConfigurationWithDefine } from "./webpack/configuration_with_define.js";
import { setConfig } from "./webpack/webpack_config_from_cli.cjs";
import { normalizeConfigurationWithDefine } from "./rspack/configuration_with_define.js";
import { setConfig } from "./rspack/rspack_config_from_cli.js";

export interface WebpackConfigurationWithDefine extends Configuration {
define?: Record<string, any> | undefined;
Expand Down Expand Up @@ -81,7 +80,7 @@ async function getWebpackConfig(
...extraConfigs: WebpackConfigurationWithDefine[]
): Promise<(...args: any[]) => Configuration> {
const configPaths = [
pathToFileURL(path.resolve(import.meta.dirname, "../webpack.config.js"))
pathToFileURL(path.resolve(import.meta.dirname, "../rspack.config.js"))
.href,
...argv.config.map((configPath) => pathToFileURL(configPath).href),
];
Expand Down Expand Up @@ -109,15 +108,15 @@ async function getWebpackConfig(
outDir = path.resolve(outDir);
}
const plugins = [];
if (argv.typecheck || argv.lint) {
if (argv.typecheck) {
plugins.push(new TsCheckerRspackPlugin());
}
if (argv.lint) {
plugins.push(
new ForkTsCheckerWebpackPlugin({
typescript: argv.typecheck,
eslint: argv.lint
? {
files: ".",
}
: undefined,
new ESLintPlugin({
configType: "flat",
files: ".",
threads: true,
}),
);
}
Expand All @@ -141,12 +140,11 @@ async function getWebpackConfig(
}

async function runWebpack(...args: string[]) {
// @ts-expect-error: no typings available
await webpackCli([
await new RspackCLI().run([
...process.argv.slice(0, 2),
...args,
"--config",
path.resolve(import.meta.dirname, "webpack", "webpack_config_from_cli.cjs"),
path.resolve(import.meta.dirname, "rspack", "rspack_config_from_cli.js"),
]);
}

Expand Down Expand Up @@ -211,7 +209,7 @@ function parseArgs() {
group: "Development server options",
type: "number",
nargs: 1,
default: 8080,
default: 0,
description: "Port number for the development server",
},
host: {
Expand Down
33 changes: 21 additions & 12 deletions config/generate-code.ts → build_tools/generate-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
* limitations under the License.
*/

"use strict";
import fs from "node:fs";
import path from "node:path";
import nunjucks from "nunjucks";

const nunjucks = require("nunjucks");
const fs = require("fs");
const path = require("path");

const rootDir = path.resolve(__dirname, "..");
const srcDir = path.resolve(rootDir, "src");
const rootDir = path.resolve(import.meta.dirname, "..");
const templatesDir = path.resolve(rootDir, "templates");

const env = nunjucks.configure(rootDir, {
Expand All @@ -34,15 +31,23 @@ const env = nunjucks.configure(rootDir, {
},
});

function writeGenerated(sourcePath, outputPath, contents) {
function writeGenerated(
sourcePath: string,
outputPath: string,
contents: string,
) {
fs.writeFileSync(
path.resolve(rootDir, "src", outputPath),
`// DO NOT EDIT. Generated from templates/${sourcePath}.
` + contents,
);
}

function renderTemplate(sourcePath, outputPath, context) {
function renderTemplate(
sourcePath: string,
outputPath: string,
context: Record<string, string | number>,
) {
writeGenerated(
sourcePath,
outputPath,
Expand All @@ -58,7 +63,7 @@ function writeSegmentationCompression() {
{},
);
for (const dataType of ["uint64", "uint32"]) {
const context = {
const context: Record<string, string | number> = {
dataType,
strideMultiplier: dataType === "uint64" ? 2 : 1,
};
Expand All @@ -72,7 +77,11 @@ function writeSegmentationCompression() {
}
}

function makeSubstitutions(inputPath, outputPath, replacements) {
function makeSubstitutions(
inputPath: string,
outputPath: string,
replacements: [string | RegExp, string][],
) {
let inputContents = fs.readFileSync(path.resolve(templatesDir, inputPath), {
encoding: "utf-8",
});
Expand Down Expand Up @@ -107,7 +116,7 @@ function writeDataStructures() {
const nextPrevReplacements = [
[/NEXT_PROPERTY/g, `next${i}`],
[/PREV_PROPERTY/g, `prev${i}`],
];
] as [string | RegExp, string][];
makeSubstitutions(
path.join(baseDir, "linked_list.template.ts"),
path.join(baseDir, `linked_list.${i}.ts`),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Converts a webpack configuration that optionally contains an extra `define`
// property into a regular webpack configuration with an added `DefinePlugin`.
// Converts an rspack configuration that optionally contains an extra `define`
// property into a regular rspack configuration with an added `DefinePlugin`.

import webpack from "webpack";
import { DefinePlugin } from "@rspack/core";

export function normalizeConfigurationWithDefine(config) {
let { define, plugins, ...rest } = config;
if (define !== undefined && Object.keys(define).length > 0) {
plugins ??= [];
plugins.push(new webpack.DefinePlugin(define));
plugins.push(new DefinePlugin(define));
}
return { plugins, ...rest };
}
12 changes: 12 additions & 0 deletions build_tools/rspack/rspack_config_from_cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This module is specified as the rspack config module when `cli.ts` invokes
// `@rspack/cli` programmatically.
//
// It simply returns the configuration previously set by `cli.ts`.

let config = undefined;

export function setConfig(newConfig) {
config = newConfig;
}

export default (...args) => config(...args);
4 changes: 2 additions & 2 deletions build_tools/update-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ packageJson.imports = imports;

packageJson.exports = {
".": "./src/main_module.ts",
"./*.js": "./src/*.ts",
"./*": "./src/*",
"./unstable/*.js": "./src/*.ts",
"./unstable/*": "./src/*",
};

const tempPackageJsonPath = packageJsonPath + ".tmp";
Expand Down
Loading

0 comments on commit bd73859

Please sign in to comment.