Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Babel preserveFormat integration for endo#2444 #10781

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ const computeSha256 = bytes => {
const run = async () => {
fs.mkdirSync(path.dirname(bundlePaths.supervisor), { recursive: true });
const format = 'nestedEvaluate';
const bundle = await bundleSource(entryPaths.supervisor, { format });
const bundle = await bundleSource(entryPaths.supervisor, {
format,
conditions: new Set(['development']),
});
const bundleString = JSON.stringify(bundle);
const sha256 = computeSha256(bundleString);
fs.writeFileSync(bundlePaths.supervisor, bundleString);
Expand Down
19 changes: 3 additions & 16 deletions packages/xsnap-lockdown/lib/confined-object-inspect.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
import objectInspectSources from '../dist/src-object-inspect.js';
import objectInspectSources from '../dist/object-inspect.js';

// Ensure the object inspector is confined.
const c = new Compartment();
harden(c.globalThis);

// Transform the imported inspector module source string into an evaluable
// string. We could have played more games with bundlers to do something less
// fragile, but even so, SES should fail-safe if this replacement doesn't match.
//
// The goal (presuming the file ends with a single export default statement):
// `...\n export default harden(inspect0);`
// becomes:
// `...\n /* export default */ harden(inspect0);`
// and we can evaluate it to obtain the completion value as the object inspector.
const src = objectInspectSources.replace(
/(^|\s)(export\s+default)(\s+)/g,
'$1/* $2 */$3',
);
const objectInspect = c.evaluate(
`${src}\n//# sourceURL=xsnap-lockdown/lib/object-inspect.js\n`,
);
`(${objectInspectSources.source})`,
)().default;

export default objectInspect;
6 changes: 1 addition & 5 deletions packages/xsnap-lockdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"type": "module",
"main": "./src/index.js",
"scripts": {
"build:bundle-rollup": "rollup --config rollup.config.js",
"build:bundle-source": "node scripts/build-bundle.js",
"build": "yarn build:bundle-rollup && yarn build:bundle-source",
"build": "node scripts/build-bundle.js",
"clean": "rm -rf dist",
"lint": "run-s --continue-on-error lint:*",
"lint:js": "eslint 'src/**/*.js' 'lib/**/*.js' 'scripts/**/*.js' 'test/**/*.js'",
Expand All @@ -24,8 +22,6 @@
"@endo/init": "^1.1.7",
"ava": "^5.3.0",
"c8": "^10.1.2",
"rollup": "^4.24.0",
"rollup-plugin-string": "^3.0.0",
"source-map": "^0.7.4"
},
"files": [
Expand Down
12 changes: 0 additions & 12 deletions packages/xsnap-lockdown/rollup.config.js

This file was deleted.

13 changes: 13 additions & 0 deletions packages/xsnap-lockdown/scripts/build-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ const make = async name => {
return { length: bundleString.length, sha256, where: spec };
};

/**
* @param {string} name
*/
const makeObjectInspect = async name => {
const spec = bundlePaths[name];
const entryPath = entryPaths[name];
await fsp.mkdir(path.dirname(spec), { recursive: true });
const bundle = await bundleSource(entryPath, { format: 'getExport' });
const bundleString = JSON.stringify(bundle);
await fsp.writeFile(spec, `export default ${bundleString};\n`);
};

const run = async () => {
await makeObjectInspect('objectInspect');
const ld = await make('lockdown');
console.log(`wrote ${ld.where}: ${ld.length} bytes`);
console.log(`lockdown.bundle SHA256: ${ld.sha256}`);
Expand Down
2 changes: 2 additions & 0 deletions packages/xsnap-lockdown/src/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const bundlePaths = {
lockdown: new URL('../dist/lockdown.bundle', import.meta.url).pathname,
lockdownDebug: new URL('../dist/lockdown-debug.bundle', import.meta.url)
.pathname,
objectInspect: new URL('../dist/object-inspect.js', import.meta.url).pathname,
};

export const hashPaths = {
Expand All @@ -18,4 +19,5 @@ export const hashPaths = {
export const entryPaths = {
lockdown: new URL('../lib/ses-boot.js', import.meta.url).pathname,
lockdownDebug: new URL('../lib/ses-boot-debug.js', import.meta.url).pathname,
objectInspect: new URL('../lib/object-inspect.js', import.meta.url).pathname,
};
126 changes: 1 addition & 125 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3450,86 +3450,6 @@
estree-walker "^2.0.2"
picomatch "^2.3.1"

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz#1661ff5ea9beb362795304cb916049aba7ac9c54"
integrity sha512-Q6HJd7Y6xdB48x8ZNVDOqsbh2uByBhgK8PiQgPhwkIw/HC/YX5Ghq2mQY5sRMZWHb3VsFkWooUVOZHKr7DmDIA==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.24.0.tgz#2ffaa91f1b55a0082b8a722525741aadcbd3971e"
integrity sha512-ijLnS1qFId8xhKjT81uBHuuJp2lU4x2yxa4ctFPtG+MqEE6+C5f/+X/bStmxapgmwLwiL3ih122xv8kVARNAZA==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.24.0.tgz#627007221b24b8cc3063703eee0b9177edf49c1f"
integrity sha512-bIv+X9xeSs1XCk6DVvkO+S/z8/2AMt/2lMqdQbMrmVpgFvXlmde9mLcbQpztXm1tajC3raFDqegsH18HQPMYtA==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.24.0.tgz#0605506142b9e796c370d59c5984ae95b9758724"
integrity sha512-X6/nOwoFN7RT2svEQWUsW/5C/fYMBe4fnLK9DQk4SX4mgVBiTA9h64kjUYPvGQ0F/9xwJ5U5UfTbl6BEjaQdBQ==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.24.0.tgz#62dfd196d4b10c0c2db833897164d2d319ee0cbb"
integrity sha512-0KXvIJQMOImLCVCz9uvvdPgfyWo93aHHp8ui3FrtOP57svqrF/roSSR5pjqL2hcMp0ljeGlU4q9o/rQaAQ3AYA==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.24.0.tgz#53ce72aeb982f1f34b58b380baafaf6a240fddb3"
integrity sha512-it2BW6kKFVh8xk/BnHfakEeoLPv8STIISekpoF+nBgWM4d55CZKc7T4Dx1pEbTnYm/xEKMgy1MNtYuoA8RFIWw==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.24.0.tgz#1632990f62a75c74f43e4b14ab3597d7ed416496"
integrity sha512-i0xTLXjqap2eRfulFVlSnM5dEbTVque/3Pi4g2y7cxrs7+a9De42z4XxKLYJ7+OhE3IgxvfQM7vQc43bwTgPwA==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.24.0.tgz#8c03a996efb41e257b414b2e0560b7a21f2d9065"
integrity sha512-9E6MKUJhDuDh604Qco5yP/3qn3y7SLXYuiC0Rpr89aMScS2UAmK1wHP2b7KAa1nSjWJc/f/Lc0Wl1L47qjiyQw==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.24.0.tgz#5b98729628d5bcc8f7f37b58b04d6845f85c7b5d"
integrity sha512-2XFFPJ2XMEiF5Zi2EBf4h73oR1V/lycirxZxHZNc93SqDN/IWhYYSYj8I9381ikUFXZrz2v7r2tOVk2NBwxrWw==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.24.0.tgz#48e42e41f4cabf3573cfefcb448599c512e22983"
integrity sha512-M3Dg4hlwuntUCdzU7KjYqbbd+BLq3JMAOhCKdBE3TcMGMZbKkDdJ5ivNdehOssMCIokNHFOsv7DO4rlEOfyKpg==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.24.0.tgz#e0b4f9a966872cb7d3e21b9e412a4b7efd7f0b58"
integrity sha512-mjBaoo4ocxJppTorZVKWFpy1bfFj9FeCMJqzlMQGjpNPY9JwQi7OuS1axzNIk0nMX6jSgy6ZURDZ2w0QW6D56g==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.24.0.tgz#78144741993100f47bd3da72fce215e077ae036b"
integrity sha512-ZXFk7M72R0YYFN5q13niV0B7G8/5dcQ9JDp8keJSfr3GoZeXEoMHP/HlvqROA3OMbMdfr19IjCeNAnPUG93b6A==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.24.0.tgz#d9fe32971883cd1bd858336bd33a1c3ca6146127"
integrity sha512-w1i+L7kAXZNdYl+vFvzSZy8Y1arS7vMgIy8wusXJzRrPyof5LAb02KGr1PD2EkRcl73kHulIID0M501lN+vobQ==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.24.0.tgz#71fa3ea369316db703a909c790743972e98afae5"
integrity sha512-VXBrnPWgBpVDCVY6XF3LEW0pOU51KbaHhccHw6AS6vBWIC60eqsH19DAeeObl+g8nKAz04QFdl/Cefta0xQtUQ==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.24.0.tgz#653f5989a60658e17d7576a3996deb3902e342e2"
integrity sha512-xrNcGDU0OxVcPTH/8n/ShH4UevZxKIO6HJFK0e15XItZP2UcaiLFd5kiX7hJnqCbSztUF8Qot+JWBC/QXRPYWQ==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.24.0.tgz#0574d7e87b44ee8511d08cc7f914bcb802b70818"
integrity sha512-fbMkAF7fufku0N2dE5TBXcNlg0pt0cJue4xBRE2Qc5Vqikxr4VCgKj/ht6SMdFcOacVA9rqF70APJ8RN/4vMJw==

"@rtsao/scc@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@rtsao/scc/-/scc-1.1.0.tgz#927dd2fae9bc3361403ac2c7a00c32ddce9ad7e8"
Expand Down Expand Up @@ -3630,7 +3550,7 @@
"@types/estree" "*"
"@types/json-schema" "*"

"@types/estree@*", "@types/[email protected]", "@types/estree@1.0.6", "@types/estree@^1.0.0", "@types/estree@^1.0.5":
"@types/estree@*", "@types/[email protected]", "@types/estree@^1.0.0", "@types/estree@^1.0.5":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"
integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==
Expand Down Expand Up @@ -6446,11 +6366,6 @@ estraverse@^5.1.0, estraverse@^5.2.0:
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123"
integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==

estree-walker@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362"
integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==

estree-walker@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
Expand Down Expand Up @@ -11082,52 +10997,13 @@ rimraf@^5.0.0:
dependencies:
glob "^10.3.7"

rollup-plugin-string@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-string/-/rollup-plugin-string-3.0.0.tgz#fed2d6301fae1e59eb610957df757ef13fada3f0"
integrity sha512-vqyzgn9QefAgeKi+Y4A7jETeIAU1zQmS6VotH6bzm/zmUQEnYkpIGRaOBPY41oiWYV4JyBoGAaBjYMYuv+6wVw==
dependencies:
rollup-pluginutils "^2.4.1"

rollup-pluginutils@^2.4.1:
version "2.8.2"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==
dependencies:
estree-walker "^0.6.1"

rollup@^2.79.1:
version "2.79.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.1.tgz#bedee8faef7c9f93a2647ac0108748f497f081c7"
integrity sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==
optionalDependencies:
fsevents "~2.3.2"

rollup@^4.24.0:
version "4.24.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.24.0.tgz#c14a3576f20622ea6a5c9cad7caca5e6e9555d05"
integrity sha512-DOmrlGSXNk1DM0ljiQA+i+o0rSLhtii1je5wgk60j49d1jHT5YYttBv1iWOnYSTG+fZZESUOSNiAl89SIet+Cg==
dependencies:
"@types/estree" "1.0.6"
optionalDependencies:
"@rollup/rollup-android-arm-eabi" "4.24.0"
"@rollup/rollup-android-arm64" "4.24.0"
"@rollup/rollup-darwin-arm64" "4.24.0"
"@rollup/rollup-darwin-x64" "4.24.0"
"@rollup/rollup-linux-arm-gnueabihf" "4.24.0"
"@rollup/rollup-linux-arm-musleabihf" "4.24.0"
"@rollup/rollup-linux-arm64-gnu" "4.24.0"
"@rollup/rollup-linux-arm64-musl" "4.24.0"
"@rollup/rollup-linux-powerpc64le-gnu" "4.24.0"
"@rollup/rollup-linux-riscv64-gnu" "4.24.0"
"@rollup/rollup-linux-s390x-gnu" "4.24.0"
"@rollup/rollup-linux-x64-gnu" "4.24.0"
"@rollup/rollup-linux-x64-musl" "4.24.0"
"@rollup/rollup-win32-arm64-msvc" "4.24.0"
"@rollup/rollup-win32-ia32-msvc" "4.24.0"
"@rollup/rollup-win32-x64-msvc" "4.24.0"
fsevents "~2.3.2"

router@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/router/-/router-2.0.0.tgz#8692720b95de83876870d7bc638dd3c7e1ae8a27"
Expand Down
Loading