endojs / endo

Endo is a distributed secure JavaScript sandbox, based on SES
Apache License 2.0
804 stars 71 forks source link

bundle-source strips comments from type.js files? #1816

Open dckc opened 11 months ago

dckc commented 11 months ago

Describe the bug

bundle-source reduces several types.js files to more or less an empty module.

@endo/marshal-v0.8.5/src/types.js @endo/pass-style-v0.1.3/src/types.js @endo/patterns-v0.2.2/src/types.js @endo/promise-kit-v0.2.56/src/types.js @endo/zip-v0.2.31/src/types.js

Steps to reproduce

  1. bundle a file such as marshal/src/types.js using yarn bundle-source --cache-json /tmp/bx src/types.js x
  2. Note that it has non-trivial type declarations in it: grep EncodingUnion src/types.js
  3. Note that the bundled version does not:
    1. jq -r .endoZipBase64 /tmp/bx/bundle-x.json| base64 -d >,x.zip
    2. unzip ,x.zip
    3. grep EncodingUnion @endo/marshal-v0.8.8/src/types.js

Expected behavior

Contents of source files should be substantially preserved, including comments.

Platform environment

ubuntu linux 22.04.3 LTS node v18.17.1 endo version 1e2be8eaa @endo/base64@0.2.34-129-g1e2be8eaa which is the same as c2b39056c except for some unrelated files

also tested on master 877be984d

Additional context

contents of the file as well as length (308 bytes) and sha512:

$ cat @endo/marshal-v0.8.8/src/types.js 
{"imports":[],"exports":[],"reexports":[],"__syncModuleProgram__":"(({   imports: $h‍_imports,   liveVar: $h‍_live,   onceVar: $h‍_once,   importMeta: $h‍____meta,  }) => {   $h‍_imports([]);   \n})\n","__liveExportMap__":{},"__reexportMap__":{},"__fixedExportMap__":{},"__needsImportMeta__":false}

$ wc -c @endo/marshal-v0.8.8/src/types.js 
308 @endo/marshal-v0.8.8/src/types.js

$ sha512sum @endo/marshal-v0.8.8/src/types.js 
98a851bdbf2f4dd09a13b521130e299f9d1955ae19291627cd28df4fb5d4878ecdf7ce2b22a5670b4397bf490b80d8982481db5ceb224b10afdefe5c44506265  @endo/marshal-v0.8.8/src/types.js
dckc commented 11 months ago

a bit more context: I'm prototyping bundleParts.js, a tool to exclude already-loaded parts of a bundle, as an exploration into...

See also: