Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/z0w0/grain-loader
An experimental Webpack loader for the Grain programming language
https://github.com/z0w0/grain-loader
grain webpack
Last synced: about 2 months ago
JSON representation
An experimental Webpack loader for the Grain programming language
- Host: GitHub
- URL: https://github.com/z0w0/grain-loader
- Owner: z0w0
- License: mit
- Created: 2020-10-23T11:54:31.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-28T11:57:01.000Z (almost 4 years ago)
- Last Synced: 2024-01-27T12:52:23.496Z (8 months ago)
- Topics: grain, webpack
- Language: TypeScript
- Homepage:
- Size: 71.3 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-list - grain-loader
README
# Grain Webpack Loader
## Introduction
This is an experiment with loading the Grain programming language in Webpack.
The loader packs `.gr` files into runnable JS functions that return a promise that resolves with a string containing the result from running the Grain program.This loader is extremely rough and mostly serves as a exploration into what compiler/runtime/lib changes are required for this to work eventually.
## Caveats
- The Grain runtime is injected with every `.gr` file that gets loaded at the moment.
- All dependencies of a single Grain file are included in the bundled code rather than required separately.## Alternative implementations
Since static linking doesn't exist in Grain yet, the way this loader works (turning `.gr` files directly into runnable JS) requires hackily finding
dependencies by parsing out the module imports of the compiled Grain WASM and then recursively injecting all module imports required as part of the outputted JS code.Some other ideas that might work better:
1. The loader could be setup to require `wasm-loader`, and then `grain-loader` would only compile the Grain files and then `wasm-loader` would be used to load the `.wasm`.
This should allow the URL locator built into the Grain's runtime browser to load modules properly as long as all of the wasm files are outputted to the build directory.
2. The existing implementation would probably be fine if Grain had some sort of linking metadata and then we could confidently inject those modules rather than the hacky "linking" done by this load.