casual-simulation / casualos

Casual Open Simulation for the Web
https://ab1.bot
MIT License
48 stars 9 forks source link

Add the ability to use ES6 imports and exports in scripts #335

Closed KallynGowdy closed 6 months ago

KallynGowdy commented 8 months ago

Currently, the only way to share code between scripts is to use shouts, whispers, or global functions. The JavaScript ecosystem has a solution for structuring code and sharing it across projects, and that is to use ES Modules. Introduced in ES6, ES Modules add special syntax to JavaScript to represent "imports" and "exports". Imports are functions and data that is imported from other scripts, while exports are functions and data that are made available to other scripts.

We want scripts to support imports and exports just like ES Modules. This includes the following features:

There are some expected limitations of this system: