Goldfish
A CLI based compiler to convert ES6 Javascript to ASP Classic pages with dynamic polyfilling and dependency management.
As of 2.2.x Goldfish now supports nested folders/file structures, so if you were using it flatly before 2.2.x bear that in mind.
Updates
- Goldfish Compiler now uses Babel loosely to fix problems in the JScript environment - 2.4.2
- Bugfixes - 2.4.1
- Changed temp use, faster by ~50%+ - 2.4.0
- Added use of
.goldfish.json
- 2.3.0 - Add support for nested folders/file structures - 2.2.0
Features
- Automatic and dynamic polyfilling from ES6 to ES3
- Custom ASP include system
- Not as fishy as it sounds
Getting Started
You must have Nodejs installed
npm install -g goldfish-compiler
Now, in any directory enter goldfish
to build!
Default & Dev
Protip: Arguments like
--in
,--out
and--ext
are universal.
Types
goldfish
- classic once-offgoldfish dev
- hot-compiling on-save for development
Information
Command | Parameters | Default |
---|---|---|
goldfish |
All (see below) | See below. |
goldfish dev |
--min , --in , --out , --ext , --nolog , --nodeps , --host |
See below. |
Parameters
All parameters are prefixed with double dash (i.e
goldfish --min
)
Argument | Description | Example | Default |
---|---|---|---|
min |
Minify the compiled files. Slower than the default pretty-printed files. | na. | disabled |
out |
The output location for the compiled files. | goldfish --out api will output the files to a folder called "api". |
--out dist |
in |
The file location of the files to compile. | goldfish --in src will build the files inside the folder "src". |
Current directory. |
ext |
The file extension of the files to compile. ("." emitted.) | goldfish --ext js will output the files in a folder called "api". |
--ext es6 |
nodeps |
Don't include the default included depedencies (i.e JSON2) | na. | disabled |
nolog |
Don't replace Javascript's console.log with Response.Write |
na. | enabled |
host |
ip and port for polyfill service API. | 192.168.0.1:5858 | https://polyfill.io/ |
v |
Log the current version. | na. | na. |
All these arguments can be used in a .goldfish.json
file in your working directory. So:
{"ext": "js","host": "192.168.100.1:3000","in": "./apis"}
Order of importance is: command arguments > .goldfish.json
> defaults
ASP Specific Methods
Here's an example of an ASM:
const user = "Shaggy"= user;console
Since that's invalid javascript, the compilers break and explode and nobody's happy.
To fix this, add //*
before JS breaking ASMs. The correct way to do this is:
const user = "Shaggy"//* Session("user") = user;console
And viola!
Compiled File Structure
Let's say we have a ES6 file like this:
// example.es6console;
...after goldfish
is done, that becomes example.asp
inside dist/
:
<!--#include file="_pf.asp"--><!--#include file="_mpf.asp"-->
Three files were created
- The
_pf.asp
file, which has all of the ES3 polyfills (in this caseArray.prototype.map
) - The
dependency
filejson.asp
(which has JSON2 inside, as ASP Classic doesn't natively support JSON) - The compiled file itself, minified and polyfilled all ready to go! (also replacing
console.log
withResponse.Write
). This file is wrapped with the appropriate Includes (see below) and wrapped in atry/catch
function and wrapped with<script language="javascript" runat="server">...</script>
.
Include System
Typically in ASP Classic you include other ASP files like this:
<!--#include file="./mypage.asp"-->
But, of course, when writing Javascript this doesn't work... so:
Including ASP Pages in ES6
// page1.asp; // woah, js magic...const shaggy = "cool stuff, scoobs!"...
...will become
<!--#include file="./mypage.asp"-->...var shaggy = "cool stuff, scoobs!";...
License
Copyright (c) 2017, pxljoy.io (MIT License)
See LICENSE for more info.
Coded with ♥️ by pxljoy.io