Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
--arg ccache '(import <nixpkgs> {}).sccache' \
--arg devTools '[]' \
--arg benchmarkTools '[]' \
${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-inspector"]'' \' || '\' }}
${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-inspector"]'' --arg withSQLite false \' || '\' }}
--run '
make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
'
2 changes: 2 additions & 0 deletions lib/internal/process/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const {
refreshOptions,
getEmbedderOptions,
} = require('internal/options');
const config = internalBinding('config');
const {
exposeLazyInterfaces,
defineReplaceableLazyAttribute,
Expand Down Expand Up @@ -398,6 +399,7 @@ function setupQuic() {

function setupWebStorage() {
if (getEmbedderOptions().noBrowserGlobals ||
!config.hasSQLite ||
!getOptionValue('--experimental-webstorage')) {
return;
}
Expand Down
77 changes: 43 additions & 34 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,54 +1,63 @@
{
pkgs ? import ./tools/nix/pkgs.nix { },
loadJSBuiltinsDynamically ? true, # Load `lib/**.js` from disk instead of embedding
withTemporal ? false,
ncu-path ? null, # Provide this if you want to use a local version of NCU
icu ? pkgs.icu,
sharedLibDeps ? import ./tools/nix/sharedLibDeps.nix { inherit pkgs withTemporal; },

# Optional build tools / config
ccache ? pkgs.ccache,
loadJSBuiltinsDynamically ? true, # Load `lib/**.js` from disk instead of embedding
ninja ? pkgs.ninja,
devTools ? import ./tools/nix/devTools.nix { inherit pkgs ncu-path; },
benchmarkTools ? import ./tools/nix/benchmarkTools.nix { inherit pkgs; },
extraConfigFlags ? [
"--without-npm"
"--debug-node"
]
++ pkgs.lib.optionals withTemporal [
"--v8-enable-temporal-support"
],

# Build options
icu ? pkgs.icu,
withSQLite ? true,
withSsl ? true,
withTemporal ? false,
sharedLibDeps ? import ./tools/nix/sharedLibDeps.nix {
inherit
pkgs
withSQLite
withSsl
withTemporal
;
},

# dev tools (not needed to build Node.js, useful to maintain it)
ncu-path ? null, # Provide this if you want to use a local version of NCU
devTools ? import ./tools/nix/devTools.nix { inherit pkgs ncu-path; },
benchmarkTools ? import ./tools/nix/benchmarkTools.nix { inherit pkgs; },
}:

let
useSharedICU = if builtins.isString icu then icu == "system" else icu != null;
useSharedAda = builtins.hasAttr "ada" sharedLibDeps;
useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps;

needsRustCompiler = withTemporal && !builtins.hasAttr "temporal_capi" sharedLibDeps;
in
pkgs.mkShell {
inherit (pkgs.nodejs_latest) nativeBuildInputs;

buildInputs = builtins.attrValues sharedLibDeps ++ pkgs.lib.optional useSharedICU icu;

packages = [
ccache
]
++ devTools
++ benchmarkTools
++ pkgs.lib.optionals (withTemporal && !builtins.hasAttr "temporal_capi" sharedLibDeps) [
pkgs.cargo
pkgs.rustc
];
packages =
pkgs.lib.optional (ccache != null) ccache
++ devTools
++ benchmarkTools
++ pkgs.lib.optionals needsRustCompiler [
pkgs.cargo
pkgs.rustc
];

shellHook =
if (ccache != null) then
''
export CC="${pkgs.lib.getExe ccache} $CC"
export CXX="${pkgs.lib.getExe ccache} $CXX"
''
else
"";
shellHook = pkgs.lib.optionalString (ccache != null) ''
export CC="${pkgs.lib.getExe ccache} $CC"
export CXX="${pkgs.lib.getExe ccache} $CXX"
'';

BUILD_WITH = if (ninja != null) then "ninja" else "make";
NINJA = if (ninja != null) then "${pkgs.lib.getExe ninja}" else "";
NINJA = pkgs.lib.optionalString (ninja != null) "${pkgs.lib.getExe ninja}";
CI_SKIP_TESTS = pkgs.lib.concatStringsSep "," (
[ ]
++ pkgs.lib.optionals useSharedAda [
Expand All @@ -70,12 +79,11 @@ pkgs.mkShell {
)
]
++ extraConfigFlags
++ pkgs.lib.optionals (ninja != null) [
"--ninja"
]
++ pkgs.lib.optionals loadJSBuiltinsDynamically [
"--node-builtin-modules-path=${builtins.toString ./.}"
]
++ pkgs.lib.optional (!withSQLite) "--without-sqlite"
++ pkgs.lib.optional (!withSsl) "--without-ssl"
++ pkgs.lib.optional withTemporal "--v8-enable-temporal-support"
++ pkgs.lib.optional (ninja != null) "--ninja"
++ pkgs.lib.optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${builtins.toString ./.}"
++ pkgs.lib.concatMap (name: [
"--shared-${builtins.replaceStrings [ "c-ares" ] [ "cares" ] name}"
"--shared-${builtins.replaceStrings [ "c-ares" ] [ "cares" ] name}-libpath=${
Expand All @@ -86,4 +94,5 @@ pkgs.mkShell {
}/include"
]) (builtins.attrNames sharedLibDeps)
);
NOSQLITE = pkgs.lib.optionalString (!withSQLite) "1";
}
6 changes: 6 additions & 0 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ static void InitConfig(Local<Object> target,
READONLY_FALSE_PROPERTY(target, "hasInspector");
#endif

#if HAVE_SQLITE
READONLY_TRUE_PROPERTY(target, "hasSQLite");
#else
READONLY_FALSE_PROPERTY(target, "hasSQLite");
#endif

// configure --no-browser-globals
#ifdef NODE_NO_BROWSER_GLOBALS
READONLY_TRUE_PROPERTY(target, "noBrowserGlobals");
Expand Down
4 changes: 3 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ const knownGlobals = new Set([
'CompressionStream',
'DecompressionStream',
'Storage',
'sessionStorage',
].forEach((i) => {
if (globalThis[i] !== undefined) {
knownGlobals.add(globalThis[i]);
Expand All @@ -387,6 +386,9 @@ if (hasCrypto) {
if (hasLocalStorage) {
knownGlobals.add(globalThis.localStorage);
}
if (hasSQLite) {
knownGlobals.add(globalThis.sessionStorage);
}

const { Worker } = require('node:worker_threads');
knownGlobals.add(Worker);
Expand Down
5 changes: 4 additions & 1 deletion test/module-hooks/test-module-hooks-builtin-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ const { registerHooks } = require('module');

const schemelessBlockList = new Set([
'sea',
'sqlite',
'test',
'test/reporters',
]);

if (common.hasSQLite) {
schemelessBlockList.add('sqlite');
}

const testModules = [];
for (const mod of schemelessBlockList) {
testModules.push(`node:${mod}`);
Expand Down
5 changes: 4 additions & 1 deletion test/module-hooks/test-module-hooks-load-builtin-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ hook.deregister();
// stripped for internal lookups should not get passed into the hooks.
const schemelessBlockList = new Set([
'sea',
'sqlite',
'test',
'test/reporters',
]);

if (common.hasSQLite) {
schemelessBlockList.add('sqlite');
}

const testModules = [];
for (const mod of schemelessBlockList) {
testModules.push(`node:${mod}`);
Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ for (const moduleName of builtinModules) {
'fetch',
'crypto',
'navigator',
'localStorage',
'sessionStorage',
];
if (common.hasSQLite) {
expected.push('localStorage', 'sessionStorage');
}
assert.deepStrictEqual(new Set(Object.keys(globalThis)), new Set(expected));
expected.forEach((value) => {
const desc = Object.getOwnPropertyDescriptor(globalThis, value);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-sqlite-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
const { skipIfSQLiteMissing } = require('../common/index.mjs');
const { test } = require('node:test');
const assert = require('node:assert');
const { DatabaseSync } = require('node:sqlite');
skipIfSQLiteMissing();
const { DatabaseSync } = require('node:sqlite');

function checkDefensiveMode(db) {
function journalMode() {
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-sqlite-template-tag.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';
require('../common');
const { skipIfSQLiteMissing } = require('../common');
skipIfSQLiteMissing();

const assert = require('assert');
const { DatabaseSync } = require('node:sqlite');
const { test, beforeEach } = require('node:test');
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-webstorage-without-sqlite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

const { hasSQLite } = require('../common');
const assert = require('node:assert');

// Ensuring that `sessionStorage` is not a getter that throws when built without SQLite.
assert.strictEqual(typeof sessionStorage, hasSQLite ? 'object' : 'undefined');

Check failure on line 7 in test/parallel/test-webstorage-without-sqlite.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'sessionStorage' is not defined
assert.strictEqual(Object.hasOwn(globalThis, 'sessionStorage'), hasSQLite);
10 changes: 8 additions & 2 deletions tools/nix/sharedLibDeps.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
pkgs ? import ./pkgs.nix { },
withSQLite ? true,
withSsl ? true,
withTemporal ? false,
}:
{
Expand All @@ -12,7 +14,6 @@
ngtcp2
simdjson
simdutf
sqlite
uvwasi
zlib
zstd
Expand All @@ -28,6 +29,11 @@
})
];
};
}
// (pkgs.lib.optionalAttrs withSQLite {
inherit (pkgs) sqlite;
})
// (pkgs.lib.optionalAttrs withSsl {
openssl = pkgs.openssl.overrideAttrs (old: {
version = "3.5.4";
src = pkgs.fetchurl {
Expand All @@ -45,7 +51,7 @@
"dev"
];
});
}
})
// (pkgs.lib.optionalAttrs withTemporal {
inherit (pkgs) temporal_capi;
})
1 change: 1 addition & 0 deletions typings/internalBinding/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface ConfigBinding {
hasTracing: boolean;
hasNodeOptions: boolean;
hasInspector: boolean;
hasSQLite: boolean;
noBrowserGlobals: boolean;
bits: number;
getDefaultLocale(): string;
Expand Down
Loading