mambascript 0.5.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/README.md +509 -267
  3. package/bin/mamba +1 -258
  4. package/decision.js +1 -246
  5. package/docs/coverage.md +70 -0
  6. package/docs/features.md +3348 -0
  7. package/docs/perf.md +94 -0
  8. package/docs/reference.md +1295 -0
  9. package/docs/vs-coffeescript.md +1593 -0
  10. package/docs/vs-iced-coffeescript.md +626 -0
  11. package/docs/vs-typescript.md +107 -0
  12. package/esm.js +8 -0
  13. package/jest.js +33 -0
  14. package/lib/black.js +17 -13
  15. package/lib/browser.js +2 -4
  16. package/lib/cli.js +207 -136
  17. package/lib/compiler.js +1162 -93
  18. package/lib/decision.js +10 -10
  19. package/lib/diagnostics.js +219 -0
  20. package/lib/esm-hooks.js +60 -0
  21. package/lib/fast-parser.js +3469 -0
  22. package/lib/functional-helpers.js +26 -9
  23. package/lib/helpers.js +67 -50
  24. package/lib/js-nodes.js +151 -12
  25. package/lib/lexer.js +1499 -0
  26. package/lib/light-module.js +200 -63
  27. package/lib/mamba.js +372 -0
  28. package/lib/module.js +23 -172
  29. package/lib/nodes.js +84 -21
  30. package/lib/optimiser.js +29 -9
  31. package/lib/optparse.js +32 -15
  32. package/lib/parser.js +9433 -4840
  33. package/lib/preprocessor.js +3 -5
  34. package/lib/register.js +49 -56
  35. package/lib/repl.js +28 -9
  36. package/lib/reporter.js +106 -69
  37. package/lib/run.js +3 -5
  38. package/lib/string-scanner.js +94 -0
  39. package/lib/syntax-tables.js +480 -0
  40. package/lib/type-checker.js +258 -44
  41. package/lib/type-helpers.js +28 -10
  42. package/lib/type-resolver.js +256 -34
  43. package/lib/type-scope.js +10 -6
  44. package/lib/type-walker.js +664 -85
  45. package/lib/types.js +17 -7
  46. package/lib/underscore.js +170 -76
  47. package/lib/unicode-classes.js +122 -0
  48. package/mambaview.js +1 -0
  49. package/package.json +49 -46
  50. package/stdlib.js +1 -0
  51. package/vendor/README.md +40 -0
  52. package/vendor/escodegen/LICENSE.BSD +19 -0
  53. package/vendor/escodegen/escodegen.js +2289 -0
  54. package/vendor/estraverse/LICENSE.BSD +19 -0
  55. package/vendor/estraverse/estraverse.js +706 -0
  56. package/vendor/mambacodegen/LICENSE +24 -0
  57. package/vendor/mambacodegen/lib/mscodegen.js +620 -0
  58. package/vendor/patches/escodegen.diff +130 -0
  59. package/vendor/patches/estraverse.diff +51 -0
  60. package/vendor/patches/pegjs.diff +70 -0
  61. package/vendor/patches/source-map.diff +160 -0
  62. package/vendor/source-map/LICENSE +28 -0
  63. package/vendor/source-map/lib/source-map/array-set.js +92 -0
  64. package/vendor/source-map/lib/source-map/base64-vlq.js +140 -0
  65. package/vendor/source-map/lib/source-map/base64.js +38 -0
  66. package/vendor/source-map/lib/source-map/binary-search.js +77 -0
  67. package/vendor/source-map/lib/source-map/source-map-consumer.js +404 -0
  68. package/vendor/source-map/lib/source-map/source-map-generator.js +229 -0
  69. package/vendor/source-map/lib/source-map/source-node.js +201 -0
  70. package/vendor/source-map/lib/source-map/util.js +57 -0
  71. package/vendor/source-map/lib/source-map.js +8 -0
  72. package/bin/fix +0 -17
  73. package/bin/updateImports +0 -46
  74. package/build.js +0 -25
  75. package/lib/module-esm.js +0 -901
  76. package/lib/pegjs-kofu-plugin.js +0 -35
  77. package/lib/pegjs-mamba-plugin.js +0 -35
  78. package/lib/processor-esm.js +0 -507
  79. package/mamba +0 -259
  80. package/msast.js +0 -1
  81. package/utils/gulp-mamba.js +0 -29
  82. /package/{lib/esm.js → vendor/patches/mambacodegen.diff} +0 -0
package/lib/cli.js CHANGED
@@ -1,121 +1,178 @@
1
- // Generated by MambaScript 0.5.2
2
- var present = console.log;
3
- // Generated by MambaScript 0.5.2
4
- var $0, $0, additionalArgs, concat, escodegen, esmangle, foldl, fs, humanReadable, input, input, inputName, inputSource, inspect, knownOpts, MambaScript, mscodegen, nopt, numberLines, optAliases, Optimiser, option, options, output, parameter, path, pkg, positionalArgs, Preprocessor, processInput, Repl, runMain;
1
+ // Generated by MambaScript 2.0.0
2
+ var additionalArgs, BANNER, cache$, count, e, fs, humanReadable, input, inputName, inputSource, inspect, MambaScript, numberLines, Optimiser, OptionParser, options, output, parser, path, positionalArgs, Preprocessor, processInput, Repl, runMain, SWITCHES, typeCheckMode;
5
3
  fs = require('fs');
6
4
  path = require('path');
7
- cache$ = require('./functional-helpers');
8
- concat = cache$.concat;
9
- foldl = cache$.foldl;
10
- cache$1 = require('./helpers');
11
- numberLines = cache$1.numberLines;
12
- humanReadable = cache$1.humanReadable;
13
- Preprocessor = require('./preprocessor').Preprocessor;
14
- Optimiser = require('./optimiser').Optimiser;
15
- runMain = require('./run').runMain;
5
+ inspect = require('util').inspect;
6
+ OptionParser = require('./optparse').OptionParser;
7
+ cache$ = require('./helpers');
8
+ numberLines = cache$.numberLines;
9
+ humanReadable = cache$.humanReadable;
16
10
  MambaScript = require('./module');
11
+ Preprocessor = MambaScript.Preprocessor;
12
+ Optimiser = MambaScript.Optimiser;
17
13
  Repl = require('./repl');
18
- nopt = require('nopt');
19
- mscodegen = function () {
20
- try {
21
- return require('mambacodegen');
22
- } catch (e$) {
23
- return;
24
- }
25
- }.call(this);
26
- escodegen = function () {
27
- try {
28
- return require('escodegen');
29
- } catch (e$1) {
30
- return;
31
- }
32
- }.call(this);
33
- esmangle = function () {
34
- try {
35
- return require('esmangle');
36
- } catch (e$2) {
37
- return;
38
- }
39
- }.call(this);
40
- inspect = function (o) {
41
- return require('util').inspect(o, false, 9e9, true);
42
- };
43
- knownOpts = {};
44
- option = function () {
45
- var o;
46
- for (var i$ = 0, length$ = arguments.length; i$ < length$; ++i$) {
47
- o = arguments[i$];
48
- knownOpts[o] = Boolean;
49
- }
50
- };
51
- parameter = function () {
52
- var p;
53
- for (var i$ = 0, length$ = arguments.length; i$ < length$; ++i$) {
54
- p = arguments[i$];
55
- knownOpts[p] = String;
56
- }
57
- };
58
- optAliases = {
59
- b: '--bare',
60
- c: '--compile',
61
- e: '--eval',
62
- f: '--mscodegen',
63
- I: '--require',
64
- i: '--input',
65
- j: '--js',
66
- l: '--literate',
67
- m: '--minify',
68
- o: '--output',
69
- p: '--parse',
70
- v: '--version',
71
- w: '--watch',
72
- z: '--svelte'
73
- };
74
- option('parse', 'compile', 'optimise', 'debug', 'literate', 'raw', 'version', 'help', 'typed2cs', 'svelte');
75
- parameter('cli', 'input', 'nodejs', 'output', 'watch');
76
- if (null != escodegen) {
77
- option('bare', 'js', 'source-map', 'eval', 'repl');
78
- parameter('source-map-file', 'require');
79
- if (null != esmangle)
80
- option('minify');
14
+ runMain = require('./run').runMain;
15
+ SWITCHES = [
16
+ [
17
+ '-b',
18
+ '--bare',
19
+ 'omit the top-level function wrapper'
20
+ ],
21
+ [
22
+ '-c',
23
+ '--compile',
24
+ 'output the compiled JS AST (JSON)'
25
+ ],
26
+ [
27
+ '-e',
28
+ '--eval',
29
+ 'evaluate compiled JavaScript'
30
+ ],
31
+ [
32
+ '-f',
33
+ '--mscodegen',
34
+ 'output mscodegen-generated MambaScript code'
35
+ ],
36
+ [
37
+ '-i',
38
+ '--input [FILE]',
39
+ 'file to be used as input instead of STDIN'
40
+ ],
41
+ [
42
+ '-I',
43
+ '--require [FILE]',
44
+ 'require a library before a script is executed'
45
+ ],
46
+ [
47
+ '-j',
48
+ '--js',
49
+ 'generate JavaScript output'
50
+ ],
51
+ [
52
+ '-l',
53
+ '--literate',
54
+ 'treat the input as literate MambaScript code'
55
+ ],
56
+ [
57
+ '-o',
58
+ '--output [FILE]',
59
+ 'file to be used as output instead of STDOUT'
60
+ ],
61
+ [
62
+ '-p',
63
+ '--parse',
64
+ 'output a JSON-serialised AST representation of the input'
65
+ ],
66
+ [
67
+ '-v',
68
+ '--version',
69
+ 'display the version number'
70
+ ],
71
+ [
72
+ '--cli [INPUT]',
73
+ 'pass a string from the command line as input'
74
+ ],
75
+ [
76
+ '--debug',
77
+ 'output intermediate representations on stderr for debug'
78
+ ],
79
+ [
80
+ '--help',
81
+ 'display this help message'
82
+ ],
83
+ [
84
+ '--optimise',
85
+ 'enable optimisations (default: on; --no-optimise to disable)'
86
+ ],
87
+ [
88
+ '--raw',
89
+ 'preserve source position and raw parse information'
90
+ ],
91
+ [
92
+ '--repl',
93
+ 'run an interactive MambaScript REPL'
94
+ ],
95
+ [
96
+ '--source-map',
97
+ 'generate source map'
98
+ ],
99
+ [
100
+ '--source-map-file [FILE]',
101
+ 'file used as output for source map when using --js'
102
+ ],
103
+ [
104
+ '--typecheck',
105
+ 'type check the input (default: on, warnings only; --no-typecheck to disable)'
106
+ ],
107
+ [
108
+ '--strict',
109
+ 'fail compilation on type errors'
110
+ ],
111
+ [
112
+ '--parser [NAME]',
113
+ 'parser to use: fast (hand-written) or peg (the previous PEG.js parser)'
114
+ ],
115
+ [
116
+ '--tokens',
117
+ 'output the token stream of the input (fast parser) and exit'
118
+ ]
119
+ ];
120
+ BANNER = 'Usage: mambascript [OPTIONS] [-- ARGS]\n\n mambascript -j -i input.mamba -o output.js compile a file\n mambascript --js < input.mamba compile stdin to stdout\n mambascript script.mamba arg0 arg1 run a script (implies --eval)\n mambascript start the REPL';
121
+ parser = new OptionParser(SWITCHES, BANNER);
122
+ try {
123
+ options = parser.parse(process.argv.slice(2));
124
+ } catch (e$) {
125
+ e = e$;
126
+ console.error('Error: ' + e.message);
127
+ console.error(parser.help());
128
+ process.exit(1);
81
129
  }
82
- if (null != mscodegen)
83
- option('mscodegen');
84
- options = nopt(knownOpts, optAliases, process.argv, 2);
85
- positionalArgs = options.argv.remain;
86
- delete options.argv;
130
+ positionalArgs = options['arguments'];
131
+ additionalArgs = [];
87
132
  if (null != options.optimise)
88
133
  options.optimise;
89
134
  else
90
135
  options.optimise = true;
136
+ if (null != options.typecheck)
137
+ options.typecheck;
138
+ else
139
+ options.typecheck = true;
91
140
  options.sourceMap = options['source-map'];
92
141
  options.sourceMapFile = options['source-map-file'];
93
- if (!(options.compile || options.js || options.sourceMap || options.parse || options['eval'] || options.mscodegen))
94
- if (!(null != escodegen)) {
95
- options.compile = true;
96
- } else if (positionalArgs.length) {
142
+ typeCheckMode = options.typecheck === false ? 'off' : options.strict ? 'error' : 'warn';
143
+ if (!(options.compile || options.js || options.sourceMap || options.parse || options['eval'] || options.mscodegen || options.tokens || options.help || options.version))
144
+ if (positionalArgs.length) {
97
145
  options['eval'] = true;
98
146
  options.input = positionalArgs.shift();
99
147
  additionalArgs = positionalArgs;
100
148
  } else {
101
149
  options.repl = true;
102
150
  }
103
- if (1 !== (null != options.parse ? options.parse : 0) + (null != options.compile ? options.compile : 0) + (null != options.js ? options.js : 0) + (null != options.sourceMap ? options.sourceMap : 0) + (null != options['eval'] ? options['eval'] : 0) + (null != options.mscodegen ? options.mscodegen : 0) + (null != options.repl ? options.repl : 0)) {
104
- console.error('Error: At most one of --parse (-p), --compile (-c), --js (-j), --source-map, --eval (-e), --mscodegen, or --repl may be used.');
151
+ count = function () {
152
+ var o, opts;
153
+ opts = arguments.length > 0 ? [].slice.call(arguments, 0) : [];
154
+ return function (accum$) {
155
+ for (var i$ = 0, length$ = opts.length; i$ < length$; ++i$) {
156
+ o = opts[i$];
157
+ if (!o)
158
+ continue;
159
+ accum$.push(1);
160
+ }
161
+ return accum$;
162
+ }.call(this, []).length;
163
+ };
164
+ if (count(options.parse, options.compile, options.js, options.sourceMap, options['eval'], options.mscodegen, options.tokens, options.repl) > 1) {
165
+ console.error('Error: At most one of --parse (-p), --compile (-c), --js (-j), --source-map, --eval (-e), --mscodegen, --tokens, or --repl may be used.');
105
166
  process.exit(1);
106
167
  }
107
- if (1 < (null != options.input) + (null != options.watch) + (null != options.cli)) {
108
- console.error('Error: At most one of --input (-i), --watch (-w), or --cli may be used.');
168
+ if (count(null != options.input, null != options.cli) > 1) {
169
+ console.error('Error: At most one of --input (-i) or --cli may be used.');
109
170
  process.exit(1);
110
171
  }
111
172
  if (null != options.require && !options['eval']) {
112
173
  console.error('Error: --require (-I) depends on --eval (-e)');
113
174
  process.exit(1);
114
175
  }
115
- if (options.minify && !(options.js || options['eval'])) {
116
- console.error('Error: --minify does not make sense without --js or --eval');
117
- process.exit(1);
118
- }
119
176
  if (options.bare && !(options.compile || options.js || options.sourceMap || options['eval'])) {
120
177
  console.error('Error: --bare does not make sense without --compile, --js, --source-map, or --eval');
121
178
  process.exit(1);
@@ -124,12 +181,12 @@ if (options.sourceMapFile && !options.js) {
124
181
  console.error('Error: --source-map-file depends on --js');
125
182
  process.exit(1);
126
183
  }
127
- if (null != options.input && fs.statSync(options.input).isDirectory() && (!(null != options.output) || (null != (cache$2 = fs.statSync(options.output)) ? cache$2.isFile() : void 0))) {
128
- console.error('Error: when --input is a directory, --output must be provided, and --output must not reference a file');
184
+ if (null != options.input && !fs.existsSync(options.input)) {
185
+ console.error('Error: input file not found: ' + options.input);
129
186
  process.exit(1);
130
187
  }
131
- if (options.mscodegen && !(null != mscodegen)) {
132
- console.error('Error: mscodegen must be installed to use --mscodegen');
188
+ if (null != options.input && fs.statSync(options.input).isDirectory() && (!(null != options.output) || fs.existsSync(options.output) && fs.statSync(options.output).isFile())) {
189
+ console.error('Error: when --input is a directory, --output must be provided, and --output must not reference a file');
133
190
  process.exit(1);
134
191
  }
135
192
  output = function (out) {
@@ -143,12 +200,10 @@ output = function (out) {
143
200
  }
144
201
  };
145
202
  if (options.help) {
146
- $0 = process.argv[0] === 'node' ? process.argv[1] : process.argv[0];
147
- $0 = path.basename($0);
148
- console.log('\n Usage: (OPT is interpreted by ' + $0 + ', ARG is passed to FILE)\n\n ' + $0 + ' OPT* -{p,c,j,f} OPT*\n example: ' + $0 + ' --js --no-optimise <input.mamba >output.js\n ' + $0 + ' [-e] FILE {OPT,ARG}* [-- ARG*]\n example: ' + $0 + ' myfile.mamba arg0 arg1\n ' + $0 + ' OPT* [--repl] OPT*\n example: ' + $0 + '\n\n -b, --bare omit the top-level function wrapper\n -c, --compile compile input .mamba file to js\n -z, --svelte compile input .mamba file to js svelte\n -e, --eval evaluate compiled JavaScript\n -f, --mscodegen output mscodegen-generated MambaScript code\n -i, --input FILE file to be used as input instead of STDIN\n -I, --require FILE require a library before a script is executed\n -j, --js generate JavaScript output\n -l, --literate treat the input as literate MambaScript code\n -m, --minify run compiled javascript output through a JS minifier\n -o, --output FILE file to be used as output instead of STDOUT\n -p, --parse output a JSON-serialised AST representation of the input\n -v, --version display the version number\n -w, --watch FILE watch the given file/directory for changes\n --cli INPUT pass a string from the command line as input\n --debug output intermediate representations on stderr for debug\n --help display this help message\n --nodejs OPTS pass options through to the node binary\n --optimise enable optimisations (default: on)\n --raw preserve source position and raw parse information\n --repl run an interactive TypedMambaScript REPL\n --source-map generate source map\n --source-map-file FILE file used as output for source map when using --js\n\n Unless given --input or --cli flags, `' + $0 + '` will operate on stdin/stdout.\n When none of --{parse,compile,js,source-map,eval,mscodegen,repl} are given,\n If positional arguments were given\n * --eval is implied\n * the first positional argument is used as an input filename\n * additional positional arguments are passed as arguments to the script\n Else --repl is implied\n');
203
+ console.log(parser.help());
204
+ console.log('\nUnless given --input or --cli flags, `mambascript` operates on stdin/stdout.\nWhen none of --{parse,compile,js,source-map,eval,mscodegen,repl} are given,\n If positional arguments were given\n * --eval is implied\n * the first positional argument is used as an input filename\n * additional positional arguments are passed as arguments to the script\n Else --repl is implied\n\nType checking: on by default and reports warnings; --strict turns type errors\ninto a failed compile (exit 1); --no-typecheck turns the checker off.\nEnvironment: MAMBA_TYPECHECK=off|warn|error sets the default for `require` hooks.\nParser: --parser peg selects the previous PEG.js parser; MAMBA_PARSER=peg does\nthe same for the `require` hook and jest.');
149
205
  } else if (options.version) {
150
- pkg = require('./../package.json');
151
- console.log('mambascript version ' + pkg.version);
206
+ console.log('mambascript version ' + MambaScript.VERSION);
152
207
  } else if (options.repl) {
153
208
  MambaScript.register();
154
209
  process.argv.shift();
@@ -158,29 +213,44 @@ if (options.help) {
158
213
  inputName = null != options.input ? options.input : options.cli && 'cli' || 'stdin';
159
214
  inputSource = null != options.input ? fs.realpathSync(options.input) : options.cli && '(cli)' || '(stdin)';
160
215
  processInput = function (err) {
161
- var cache$3, e, js, jsAST, preprocessed, result, sourceMap, sourceMappingUrl;
216
+ var cache$1, js, jsAST, preprocessed, result, sourceMap, sourceMappingUrl;
162
217
  if (null != err)
163
218
  throw err;
164
219
  result = null;
165
220
  input = input.toString();
166
221
  if (65279 === input.charCodeAt(0))
167
222
  input = input.slice(1);
223
+ if (options.tokens) {
224
+ process.stdout.write(require('./lexer').dumpTokens(input) + '\n');
225
+ process.exit(0);
226
+ }
168
227
  if (options.debug)
169
228
  try {
170
- console.error('### PREPROCESSED CS ###');
171
- preprocessed = Preprocessor.process(input, { literate: options.literate });
172
- console.error(numberLines(humanReadable(preprocessed)));
173
- } catch (e$3) {
229
+ if ((null != options.parser ? options.parser : null != process.env.MAMBA_PARSER ? process.env.MAMBA_PARSER : MambaScript.defaultParser) === 'peg') {
230
+ console.error('### PREPROCESSED CS ###');
231
+ preprocessed = Preprocessor.process(input, { literate: options.literate });
232
+ console.error(numberLines(humanReadable(preprocessed)));
233
+ } else {
234
+ console.error('### TOKENS ###');
235
+ console.error(require('./lexer').dumpTokens(input));
236
+ }
237
+ } catch (e$1) {
174
238
  }
175
239
  try {
176
240
  result = MambaScript.parse(input, {
177
241
  optimise: false,
178
242
  raw: options.raw || options.sourceMap || options.sourceMapFile || options['eval'],
179
243
  inputSource: inputSource,
180
- literate: options.literate
244
+ filename: inputName,
245
+ literate: options.literate,
246
+ typeCheck: typeCheckMode,
247
+ parser: options.parser,
248
+ warn: function (msg) {
249
+ return console.error(msg);
250
+ }
181
251
  });
182
- } catch (e$4) {
183
- e = e$4;
252
+ } catch (e$2) {
253
+ e = e$2;
184
254
  console.error(e.message);
185
255
  process.exit(1);
186
256
  }
@@ -192,7 +262,7 @@ if (options.help) {
192
262
  result = Optimiser.optimise(result);
193
263
  if (options.parse)
194
264
  if (null != result) {
195
- output(inspect(result.toBasicObject()));
265
+ output(inspect(result.toBasicObject(), false, null));
196
266
  return;
197
267
  } else {
198
268
  process.exit(1);
@@ -203,9 +273,9 @@ if (options.help) {
203
273
  }
204
274
  if (options.mscodegen) {
205
275
  try {
206
- result = mscodegen.generate(result);
207
- } catch (e$5) {
208
- e = e$5;
276
+ result = MambaScript.compileTypedToCS(result);
277
+ } catch (e$3) {
278
+ e = e$3;
209
279
  console.error(e.stack || e.message);
210
280
  process.exit(1);
211
281
  }
@@ -216,10 +286,19 @@ if (options.help) {
216
286
  process.exit(1);
217
287
  }
218
288
  }
219
- jsAST = MambaScript.compile(result, { bare: options.bare });
289
+ try {
290
+ jsAST = MambaScript.compile(result, {
291
+ bare: options.bare,
292
+ stdlibPath: options['eval'] ? MambaScript.stdlibPath : void 0
293
+ });
294
+ } catch (e$4) {
295
+ e = e$4;
296
+ console.error(e.stack || e.message);
297
+ process.exit(1);
298
+ }
220
299
  if (options.compile)
221
300
  if (null != jsAST) {
222
- output(inspect(jsAST));
301
+ output(inspect(jsAST, false, null));
223
302
  return;
224
303
  } else {
225
304
  process.exit(1);
@@ -228,19 +307,11 @@ if (options.help) {
228
307
  console.error('### COMPILED JS-AST ###');
229
308
  console.error(inspect(jsAST));
230
309
  }
231
- if (options.minify)
232
- try {
233
- jsAST = esmangle.mangle(esmangle.optimize(jsAST), { destructive: true });
234
- } catch (e$6) {
235
- e = e$6;
236
- console.error(e.stack || e.message);
237
- process.exit(1);
238
- }
239
310
  if (options.sourceMap) {
240
311
  try {
241
- sourceMap = MambaScript.sourceMap(jsAST, inputName, { compact: options.minify });
242
- } catch (e$7) {
243
- e = e$7;
312
+ sourceMap = MambaScript.sourceMap(jsAST, inputName);
313
+ } catch (e$5) {
314
+ e = e$5;
244
315
  console.error(e.stack || e.message);
245
316
  process.exit(1);
246
317
  }
@@ -252,12 +323,12 @@ if (options.help) {
252
323
  }
253
324
  }
254
325
  try {
255
- cache$3 = MambaScript.jsWithSourceMap(jsAST, inputName, { compact: options.minify });
256
- js = cache$3.code;
257
- sourceMap = cache$3.map;
258
- cache$3;
259
- } catch (e$8) {
260
- e = e$8;
326
+ cache$1 = MambaScript.jsWithSourceMap(jsAST, inputName);
327
+ js = cache$1.code;
328
+ sourceMap = cache$1.map;
329
+ cache$1;
330
+ } catch (e$6) {
331
+ e = e$6;
261
332
  console.error(e.stack || e.message);
262
333
  process.exit(1);
263
334
  }
@@ -272,6 +343,8 @@ if (options.help) {
272
343
  }
273
344
  if (options['eval']) {
274
345
  MambaScript.register();
346
+ if (null != options.require)
347
+ require(options.require[0] === '.' ? path.resolve(options.require) : options.require);
275
348
  process.argv = [
276
349
  process.argv[1],
277
350
  options.input
@@ -293,8 +366,6 @@ if (options.help) {
293
366
  return processInput();
294
367
  });
295
368
  });
296
- } else if (null != options.watch) {
297
- options.watch;
298
369
  } else if (null != options.cli) {
299
370
  input = options.cli;
300
371
  processInput();
@@ -306,4 +377,4 @@ if (options.help) {
306
377
  process.stdin.setEncoding('utf8');
307
378
  process.stdin.resume();
308
379
  }
309
- }
380
+ }