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

General cleanup #2757

Merged
merged 10 commits into from Nov 7, 2023
Merged

General cleanup #2757

merged 10 commits into from Nov 7, 2023

Conversation

CountBleck
Copy link
Member

@CountBleck CountBleck commented Oct 1, 2023

Changes proposed in this pull request:
⯈ Skip fixture comparisons in tests if compiling them failed
⯈ Update esbuild
⯈ Clean up the DTS generator
⯈ Update glob
⯈ Marginally clean up the web build thingy
⯈ Add a coverage job to CI; maybe Codecov can be used on it in the future?

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@CountBleck CountBleck marked this pull request as draft October 1, 2023 22:30
@CountBleck CountBleck force-pushed the general-cleanup branch 21 times, most recently from 785763f to f1fe26e Compare October 7, 2023 22:20
@CountBleck
Copy link
Member Author

I gave up on trying to make the DTS generator faster. :(

@CountBleck CountBleck force-pushed the general-cleanup branch 2 times, most recently from 3b945ad to 5fc8a8f Compare October 7, 2023 22:54
@CountBleck CountBleck marked this pull request as ready for review October 8, 2023 23:06
scripts/build-web.js Outdated Show resolved Hide resolved
@HerrCai0907
Copy link
Member

Can this PR be merged now, or you still want to update it? @CountBleck

@CountBleck
Copy link
Member Author

I'm not entirely sure.

@CountBleck
Copy link
Member Author

CountBleck commented Oct 24, 2023

@dcodeIO do you have any interest in using Codecov? (I've noticed it being used in Binaryen.)

CountBleck and others added 9 commits November 3, 2023 07:40
If the test is supposed to compile, but compilation fails instead,
there's no point in diffing fixtures (unless you like a wall of red in
your terminal). It also turns out that execution never reaches the
diffing section, since writing the non-existent debug Wasm binary fails.
I don't know, this is probably a good idea.
These changes aim to make the code somewhat simpler, although it seems
that the DTS generator will forever remain a mess of some sort. This
commit has no effect on the contents of assemblyscript.generated.d.ts
and asc.generated.d.ts.

Moreover, "wrapper" files generated by the DTS generator (asc.d.ts,
assemblyscript.d.ts, transform.d.ts, transform.cjs, transform.js) are
now included in the tree instead of being generated, since they will
never change. The transform.{c,}js files also use ES6 classes instead of
functions (why not?).

Also, the build.js script now imports build-dts.js instead of spawning
it as a separate process.

The following changes to the generator have been made:
  * `options.stdout` is now just a plain array
  * `options.main` is assumed nonexistent
  * `options.verbose` is assumed true
  * `options.sendMessage` is assumed `util.debuglog("dts")`
    * use `NODE_DEBUG=dts` to view the logs
  * `options.types` is assumed nonexistent
  * `options.out` is assumed nonexistent
  * `options.resolveModuleId` is assumed nonexistent
  * `options.prefix` is assumed to exist
  * the use of `new Promise(...)` is now removed
  * `import ... = require(...)` statements are assumed to never exist
  * double quotes are now used instead of single quotes
  * `else` is now on the same line as the ending brace of `if`
  * other style changes have been made while I'm at it
  * `DTS` is a constant just like `DTSLEN`
  * `excludesMap` is now a set called `exclusions`
  * `transformTypes` uses `context.factory` to create identifiers
  * a duplicate `currentModuleId` variable is now removed
  * unneeded merging of `compilerOptions` and `options` is now removed
  * `pathUtil.relative()` is used instead of slicing
  * arrow functions are used more often
  * (and some other things I likely forgot about)
Keeping (dev) dependencies up to date is likely a good idea, especially
if later versions are (ever so slightly) faster. glob v10 removed its
default export, so the `globSync` named export is now used in scripts.
Since the platform path separator is now used starting from glob v9, the
`posix` option is enabled to fix the resulting breakage. glob v9 also
removed the sorting of results, which caused one test to fail, as the
bundled standard library object had differently ordered fields, which in
turn affected the order in `Program#elementsByName`. `.sort()` is used
on the standard library glob in build.js to alleviate this issue (I am
unsure if glob returns deterministic results).
This was my fault, and I only noticed it when cleaning up the web build,
since the web build silently failed before my changes to it.
The previous commit explains why I missed this bug.
Just like the DTS build, the web build now exports functions instead of
being spawned as a child process. Also, the web build no longer fails
silently upon error.
This new job is very barebones at the moment. It only outputs a summary
of the coverage in the terminal, since the entire coverage is a bit long
and unwieldy. Perhaps Codecov or similar can be used in the future.
This was an error on my (@CountBleck) part.

Co-authored-by: Congcong Cai <congcongcai0907@163.com>
@CountBleck CountBleck force-pushed the general-cleanup branch 3 times, most recently from 50a15c5 to 16e4dc5 Compare November 3, 2023 23:29
The latest packages that were added to the lockfile when resolving a
rebase conflict might not have survived the rest of the rebase, so
another bump is provided here instead.

This bump also caused TypeScript to emit an error related to an
undici-types package due to this bump, and that is also fixed here.
Copy link
Member

@HerrCai0907 HerrCai0907 left a comment

Choose a reason for hiding this comment

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

LGTM

@CountBleck CountBleck merged commit a7e168b into AssemblyScript:main Nov 7, 2023
13 checks passed
@ia0
Copy link

ia0 commented Nov 9, 2023

I'm not sure why (not familiar with assemblyscript) but I suspect this PR broke my workflow:

cd "examples/assemblyscript" && "/home/runner/work/wasefire/wasefire/scripts/wrapper.sh" "npm" "install" "--no-save" "assemblyscript"

added 3 packages in 1s

1 package is looking for funding
  run `npm fund` for details
cd "examples/assemblyscript" && "./node_modules/.bin/asc" "-o" "../../target/wasefire/applet.wasm" "-O3" "--lowMemoryLimit" "--stackSize" "16384" "--use" "abort=hello/main/abort" "--debug" "hello/main.ts"
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/runner/work/wasefire/wasefire/examples/assemblyscript/node_modules/assemblyscript/dist/asc.js' imported from /home/runner/work/wasefire/wasefire/examples/assemblyscript/node_modules/assemblyscript/bin/asc.js
    at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:327:11)
    at moduleResolve (node:internal/modules/esm/resolve:946:10)
    at defaultResolve (node:internal/modules/esm/resolve:1132:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ESMLoader.import (node:internal/modules/esm/loader:524:22)
    at importModuleDynamically (node:internal/modules/esm/translators:110:35)
    at importModuleDynamicallyCallback (node:internal/process/esm_loader:36:14)
    at file:///home/runner/work/wasefire/wasefire/examples/assemblyscript/node_modules/assemblyscript/bin/asc.js:29:21
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.18.2

Notice how it's complaining about dist/asc.js which indeed doesn't exist, only dist/asc.d.ts does.

You can reproduce this with the following steps:

npm install --no-save assemblyscript
./node_modules/.bin/asc foo.ts

CountBleck added a commit to CountBleck/assemblyscript that referenced this pull request Nov 9, 2023
This allows AssemblyScript#2786 (which fixes the regression from AssemblyScript#2757) to be
published as soon as possible. Note that the main branch is the only
branch that can be published, since `ref: main` is passed to
actions/checkout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants