-
Notifications
You must be signed in to change notification settings - Fork 29
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
Improvements to the Module System 2 #153
Conversation
Fixed README.md not being copied
Also removed gulp because getting it to work with typescript is way too painful
In accordance with rollup best practices, call the close function after rollup build is completed
Tabs are now rebuild when their parent bundle was rebuilt
(I edited my previous comment while you happened to be composing a reply. Please also refer to the added text.)
I don't know if something has since changed, however it is worth pointing out bug source-academy/frontend#2136 where I discovered this while working with the older version of module contexts, when developing CSG. I have a |
I see, it it fitting for this PR to bump its js-slang version now that the associated Source PR has been merged?
It's great that the string matching is no longer hardcoded on the receiving end. When I resume work on CSG, I will monitor the build times. As much as I prefer elegant solutions like dynamically removing the function call, the speed increase may be worth taking the "dumb" approach (I don't think the matching would need frequent/complex updating). Unless there are now other edits the AST method is making? I am not sure how to proceed with the documentation issue. The error message doesn't reveal a lot. I've reinstalled packages, and my software has all been recently updated. For reference, I'm on Windows. Side note, is one of the "file modified" logs misfiring?
About ESLint, I'll probably take a look at the configs in detail down the line. If not now then I'll likely make some tweaks when I resume work on CSG.
So from the earlier edit, do you think it's just a result of the extra work (AST) that rollup as a whole is now doing during the build process? |
Passing one option would not pass that option as an array
It wasn't the AST, actually that part is almost inconsequential in my testing. I'll go do some benchmarking tests. I usually build this stuff using my M1 MBP which takes me 2 mins tops with documentation, and that felt reasonable to me, so I never thought to try on another machine. Lesson learned, will definitely keep this in mind in the future. |
Let's aim for merging and deploying for September 29. There is a week in CS1101S when modules are not used. |
I ran a few no-documentation builds on the new version. This was the fastest one: The new For comparison, I ran one full build on the previous rollup build system (around current master 46c7513). It took just I noticed that edits to the As it looks like a window for merging is coming soon, I'll compile some of the earlier points:
|
JSONS will be properly built if its parent bundle is being rebuilt
…/modules into module_contexts_2
Added explanations for build command system
This PR is a follow up to #148. motivated by the idea to streamline the existing module system.
Refer to this and this for changes required to the frontend and js-slang.
Primary Change
Currently, modules are written with the following format:
New Export Syntax
Under this new PR, modules are written following the ESM syntax
If desired, modules can use a default export to export an object containing all its exports:
Mixing default and named exports will cause the default export to become hidden, so this is not recommended.
Accessing
context
The
context
object is now available as an import:js-slang
doesn't actually export the context object, but a type declaration has been added for Rollup to convert to an external parameter when the bundles get transpiled to iife.Secondary Changes
moduleParams
The
moduleParams
object has been removed since it was only being used by thegame
module, and the functionality it requires can be achieved using module contexts.Module Context Guarantees
In a source program, it is perfectly valid to have multiple imports on different lines to the same module so long as they are at the top level:
js-slang
guarantees that no matter how many import calls to a module is made, each module file is only evaluated once per code evaluation, meaning that module states are only created once per evaluation.This means that checking if the module context and state have been initialized is unnecessary:
If your module code only initializes state information within module code, you can simply write:
For modules that initialize their state object outside of module code, the state object can be used in the following manner:
Similarly, tabs can also follow the same guidelines:
Build Script Changes
package.json
with themax-old-space-size
option as necessary: