Skip to content
Open
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 bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ function start_txes {
for i in $(seq 0 $((NUM_TXES-1))); do
port=$((txe_base_port + i))
kill_port $port
dump_fail "LOG_LEVEL=info TXE_PORT=$port retry 'node --no-warnings ./yarn-project/txe/dest/bin/index.js'" &
dump_fail "LOG_LEVEL=info TXE_PORT=$port retry 'node --no-warnings ./yarn-project/txe/dest/bin/index.bundle.js'" &

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one doesn't go through yarn start, so it misses the rebundle you added. After a root-only yarn build it runs whatever the last esbuild left behind, and after a yarn clean the file isn't there at all. Should start_txes bundle first too?

txe_pids+="$! "
done

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/accounts/src/ecdsa/ecdsa_k/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { EcdsaKBaseAccountContract } from './account_contract.js';
* @returns The contract artifact for the ecdsa K account contract
*/
export async function getEcdsaKAccountContractArtifact() {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/accounts/src/ecdsa/ecdsa_r/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { EcdsaRBaseAccountContract } from './account_contract.js';
* @returns The contract artifact for the ecdsa K account contract
*/
export async function getEcdsaRAccountContractArtifact() {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
5 changes: 4 additions & 1 deletion yarn-project/accounts/src/ecdsa/stub/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js
* Lazily loads the ECDSA stub contract artifact (browser-compatible).
*/
export async function getStubEcdsaAccountContractArtifact() {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
const { default: json } = await import('../../../artifacts/SimulatedEcdsaAccount.json');
return loadContractArtifact(json);
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/accounts/src/schnorr/initializerless/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { SchnorrBaseAccountContract } from '../account_contract.js';
* @returns The contract artifact for the schnorr account contract
*/
export async function getSchnorrInitializerlessAccountContractArtifact() {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { SchnorrBaseAccountContract } from '../account_contract.js';
* @returns The contract artifact for the schnorr account contract
*/
export async function getSchnorrAccountContractArtifact() {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
5 changes: 4 additions & 1 deletion yarn-project/accounts/src/schnorr/stub/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js
* Lazily loads the Schnorr stub contract artifact (browser-compatible).
*/
export async function getStubSchnorrAccountContractArtifact() {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the generator that emits this same block was missed — generate_client_artifacts_helper.ts:100 and :150 still say "Cannot assert this import". They're the last two copies of the old wording left.

// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aztec/noir-protocol-circuits-types is external, so its client/lazy JSON imports still reach Node's loader unbundled — same error, just not called today. Should the generator emit with { type: 'json' }? One change covers ~150 sites.

const { default: json } = await import('../../../artifacts/SimulatedSchnorrAccount.json');
return loadContractArtifact(json);
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/protocol-contracts/src/class-registry/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let protocolContractArtifact: ContractArtifact;

export async function getContractClassRegistryArtifact(): Promise<ContractArtifact> {
if (!protocolContractArtifact) {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/protocol-contracts/src/fee-juice/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let protocolContractArtifact: ContractArtifact;

export async function getFeeJuiceArtifact(): Promise<ContractArtifact> {
if (!protocolContractArtifact) {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let protocolContractArtifact: ContractArtifact;

export async function getContractInstanceRegistryArtifact(): Promise<ContractArtifact> {
if (!protocolContractArtifact) {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/standard-contracts/src/auth-registry/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let standardContractArtifact: ContractArtifact;

export async function getAuthRegistryArtifact(): Promise<ContractArtifact> {
if (!standardContractArtifact) {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let standardContractArtifact: ContractArtifact;

export async function getHandshakeRegistryArtifact(): Promise<ContractArtifact> {
if (!standardContractArtifact) {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let standardContractArtifact: ContractArtifact;

export async function getMultiCallEntrypointArtifact(): Promise<ContractArtifact> {
if (!standardContractArtifact) {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/standard-contracts/src/public-checks/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let standardContractArtifact: ContractArtifact;

export async function getPublicChecksArtifact(): Promise<ContractArtifact> {
if (!standardContractArtifact) {
// Cannot assert this import as it's incompatible with bundlers like vite
// Cannot add `with { type: 'json' }` to this import as it's incompatible with bundlers like vite
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
// Even if now supported by all major browsers, the MIME type is replaced with
// "text/javascript"
Expand Down
8 changes: 6 additions & 2 deletions yarn-project/txe/esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ const redirects = [
];

const entryPoints = {
// src/bin/index.ts → dest/bin/index.js (overwrites the tsc-emitted file).
'bin/index': 'src/bin/index.ts',
// src/bin/index.ts → dest/bin/index.bundle.js. The `.bundle` suffix (like worker/server below)
// keeps the output at a path tsc never emits: a tsc-only rebuild (e.g. `yarn build` at the
// yarn-project root) must not be able to replace a bundle with unbundled output, because the
// unbundled tree reaches dynamic JSON imports that Node's ESM loader rejects
// (ERR_IMPORT_ATTRIBUTE_MISSING) — TXE only runs correctly from the bundles.
'bin/index.bundle': 'src/bin/index.ts',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that esbuild stops overwriting it, swc's dest/bin/index.js sticks around as a broken copy of the CLI. Should we stop emitting it, so the old path fails as a missing file instead of a confusing crash?

// src/worker.ts → dest/worker.bundle.js (the file the pool spawns).
'worker.bundle': 'src/worker.ts',
// src/rpc_server.ts → dest/server.bundle.js (the entry the parent `@aztec/aztec`
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/txe/esbuild/plugins/size_guard.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const sizeLimits = [
{ pattern: /^dest\/[A-Z][A-Za-z]+-[A-Z0-9]+\.js$/, maxKB: 800, description: 'contract artifact chunk' },
// Tiny entry stubs that just re-export from the shared chunks.
{ pattern: /^dest\/(worker|server)\.bundle\.js$/, maxKB: 8, description: 'entrypoint stub' },
{ pattern: /^dest\/bin\/index\.js$/, maxKB: 8, description: 'CLI entrypoint stub' },
{ pattern: /^dest\/bin\/index\.bundle\.js$/, maxKB: 8, description: 'CLI entrypoint stub' },
];

export const totalLimitMiB = 14.5;
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/txe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"import": "./dest/server.bundle.js"
}
},
"bin": "./dest/bin/index.js",
"bin": "./dest/bin/index.bundle.js",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn.lock still has txe: ./dest/bin/index.js. Should we commit the regenerated lockfile? yarn install is immutable in CI, so it'd fail on the first node_modules cache miss rather than here.

"typedocOptions": {
"entryPoints": [
"./src/index.ts"
Expand All @@ -21,8 +21,8 @@
"build:dev": "../scripts/tsc.sh --watch",
"clean": "rm -rf ./dest .tsbuildinfo",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
"dev": "LOG_LEVEL=\"debug; trace: simulator:state_manager; info: json-rpc:proxy\" node ./dest/bin/index.js",
"start": "node --no-warnings ./dest/bin/index.js",
"dev": "node ./esbuild.config.mjs && LOG_LEVEL=\"debug; trace: simulator:state_manager; info: json-rpc:proxy\" node ./dest/bin/index.bundle.js",
"start": "node ./esbuild.config.mjs && node --no-warnings ./dest/bin/index.bundle.js",
"start:oracle-test-resolver": "node --no-warnings ./dest/bin/oracle_test_server.js",
"check_txe_oracle_version": "node ./dest/bin/check_txe_oracle_version.js"
},
Expand Down Expand Up @@ -100,7 +100,7 @@
"typescript": "^5.3.3"
},
"files": [
"dest/bin/index.js",
"dest/bin/index.bundle.js",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"dest" on line 109 already publishes the whole directory. Should we drop the redundant entries rather than keep renaming them?

"dest/worker.bundle.js",
"dest/server.bundle.js",
"dest/chunk-*.js",
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/txe/src/dispatcher_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export async function buildSharedContractStore(): Promise<{ dataDir: string; sch

/**
* Resolves `worker.bundle.js` whether this code is running unbundled (next to dispatcher_pool.js
* inside `dest/`) or bundled into `dest/bin/index.js` (one directory deeper). `import.meta.url`
* refers to whichever module the calling code actually lives in; we try both relative locations
* and use whichever exists.
* inside `dest/`) or bundled into `dest/bin/index.bundle.js` (one directory deeper).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With splitting on, this code ends up in a dest/chunk-*.js at the dest/ root rather than dest/bin/, so the ../worker.bundle.js candidate never wins. Is it still needed?

* `import.meta.url` refers to whichever module the calling code actually lives in; we try both
* relative locations and use whichever exists.
*/
// worker.bundle.js is esbuild's bundling of src/worker.ts (see esbuild.config.mjs).
// @dependency ./worker.ts
Expand Down
Loading