From 03acb2ba63350933c3636f4f9b058f25a1a2bc86 Mon Sep 17 00:00:00 2001 From: Hyppoprogramm <65360617+GulgDev@users.noreply.github.com> Date: Thu, 13 Jun 2024 17:33:04 +0500 Subject: [PATCH] Add NodeJS compatibility & mod function --- README.md | 16 +++- package-lock.json | 137 +++++++++++++++++++++++++++++- package.json | 9 +- src/bin.ts | 48 +++++++++++ src/runtimes/browser.ts | 22 +++++ src/runtimes/node.ts | 20 +++++ src/sigmascript/index.ts | 7 +- src/sigmascript/lib/js-browser.ts | 7 ++ src/sigmascript/lib/js-node.ts | 7 ++ src/sigmascript/lib/js.ts | 5 +- src/sigmascript/lib/math.ts | 1 + src/sigmascript/sigmascript.ts | 20 ----- src/sigmascriptx/index.ts | 6 +- tsconfig.json | 2 +- webpack.prod.js | 46 +++++++++- 15 files changed, 316 insertions(+), 37 deletions(-) create mode 100644 src/bin.ts create mode 100644 src/runtimes/browser.ts create mode 100644 src/runtimes/node.ts create mode 100644 src/sigmascript/lib/js-browser.ts create mode 100644 src/sigmascript/lib/js-node.ts diff --git a/README.md b/README.md index 75629ce..9e7f6a3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # SigmaScript -![Logo](demo/logo.png) +![Logo](https://gulgdev.github.io/SigmaScript/demo/logo.png) Programming language made for sigma males. @@ -88,7 +88,7 @@ print "lambda = " @ lambda; ``` ### Libraries -There's 7 default libs in SigmaScript: `js`, `dom`, `fn`, `ref`, `string`, `struct`, `array`, `math`. To use a lib in your program simply add `use` header: +There's 8 default libs in SigmaScript: `js`, `dom`, `fn`, `ref`, `string`, `struct`, `array`, `math`. To use a lib in your program simply add `use` header: ```ss use js; @@ -124,7 +124,7 @@ Struct lib allows you to create and modify structures. Use `struct` to create a Array lib allows you to create and modify arrays. Use `array` to create a new array. Use `array_add` and `array_remove` to add/remove elements of array. Use `array_at` to access elements of array. Use `array_set` to modify elements of array. Use `array_length` to get length of array. Use `array_find` to find index of specific element in array. #### Math -Math lib allows you to use math functions. It supports `abs`, `sign`, `sqrt`, `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, `exp`, `round`, `floor`, `ceil`, `random`, `randint`. +Math lib allows you to use math functions. It supports `abs`, `sign`, `sqrt`, `mod`, `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, `exp`, `round`, `floor`, `ceil`, `random`, `randint`. #### Native libraries You can create your own JS libs and then use them in SS. See [this article](native-libs.md) to learn how to do it. @@ -145,6 +145,16 @@ See [this article](ssx.md) to learn more about SSX. ## Best practices See [this article](best-practices.md) to be a good sigma-scripter! +## NodeJS +You can also run scripts in NodeJS environment by installing SigmaScript globally: +``` +npm i -g sigmascript +``` +And then: +``` +npx sigmascript lib1.ss lib2.ss main.ss +``` + ## More info Browse the source code if you want to know more about how this project works. diff --git a/package-lock.json b/package-lock.json index d10734c..ac61947 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,21 @@ { - "name": "customscript", + "name": "sigmascript", "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "customscript", + "name": "sigmascript", "version": "1.0.0", "license": "ISC", + "dependencies": { + "node-fetch": "^3.3.2" + }, + "bin": { + "sigmascript": "dist/bin.js" + }, "devDependencies": { + "terser-webpack-plugin": "^5.3.10", "ts-loader": "^9.5.1", "typescript": "^5.4.5", "webpack": "^5.91.0", @@ -1123,6 +1130,14 @@ "node": ">= 8" } }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "engines": { + "node": ">= 12" + } + }, "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -1503,6 +1518,28 @@ "node": ">=0.8.0" } }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -1603,6 +1640,17 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -2434,6 +2482,41 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, "node_modules/node-forge": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", @@ -3743,6 +3826,14 @@ "minimalistic-assert": "^1.0.0" } }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "engines": { + "node": ">= 8" + } + }, "node_modules/webpack": { "version": "5.91.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.91.0.tgz", @@ -5099,6 +5190,11 @@ "which": "^2.0.1" } }, + "data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==" + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -5390,6 +5486,15 @@ "websocket-driver": ">=0.5.1" } }, + "fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "requires": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + } + }, "fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -5454,6 +5559,14 @@ } } }, + "formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "requires": { + "fetch-blob": "^3.1.2" + } + }, "forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -6037,6 +6150,21 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==" + }, + "node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "requires": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + } + }, "node-forge": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", @@ -6973,6 +7101,11 @@ "minimalistic-assert": "^1.0.0" } }, + "web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==" + }, "webpack": { "version": "5.91.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.91.0.tgz", diff --git a/package.json b/package.json index c323bf2..a77766a 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,26 @@ { "name": "sigmascript", "version": "1.0.0", - "description": "", + "description": "Programming language made for sigma males", "main": "index.js", "scripts": { "build": "webpack --config webpack.prod.js", "start": "webpack --watch --config webpack.dev.js" }, + "bin": "bin/sigmascript.js", "keywords": [], - "author": "", + "author": "Gulg", "license": "ISC", "devDependencies": { + "terser-webpack-plugin": "^5.3.10", "ts-loader": "^9.5.1", "typescript": "^5.4.5", "webpack": "^5.91.0", "webpack-cli": "^5.1.4", "webpack-dev-server": "^5.0.4", "webpack-merge": "^5.10.0" + }, + "dependencies": { + "node-fetch": "^3.3.2" } } diff --git a/src/bin.ts b/src/bin.ts new file mode 100644 index 0000000..7035840 --- /dev/null +++ b/src/bin.ts @@ -0,0 +1,48 @@ +import { NodeRuntime } from "./runtimes/node"; +import { SigmaScript } from "./sigmascript/sigmascript"; +import fetch from "node-fetch"; +import { readFile } from "fs/promises"; + +function isURL(path: string) { + let url; + try { + url = new URL(path); + } catch { + return false; + } + return true; +} + +const sigmaScript = new SigmaScript(); +NodeRuntime.addLibraries(sigmaScript); + +for (const path of process.argv.slice(2)) { + let source; + if (isURL(path)) { + let response; + try { + response = await fetch(path); + } catch (err) { + console.error(`${path} - ${err.message}`); + continue; + } + if (!response.ok) { + console.error(`${path} - ${response.status} (${response.statusText})`); + continue; + } + try { + source = await response.text(); + } catch (err) { + console.error(`${path} - ${err.message}`); + continue; + } + } else { + try { + source = await readFile(path, { encoding: "utf8" }); + } catch (err) { + console.error(`${path} - ${err.message}`); + continue; + } + } + sigmaScript.load(source); +} \ No newline at end of file diff --git a/src/runtimes/browser.ts b/src/runtimes/browser.ts new file mode 100644 index 0000000..d696ce7 --- /dev/null +++ b/src/runtimes/browser.ts @@ -0,0 +1,22 @@ +import { SigmaScript } from "../sigmascript/sigmascript"; +import { DOMLib } from "../sigmascript/lib/dom"; +import { FnLib } from "../sigmascript/lib/fn"; +import { BrowserJSLib } from "../sigmascript/lib/js-browser"; +import { RefLib } from "../sigmascript/lib/ref"; +import { StringLib } from "../sigmascript/lib/string"; +import { StructLib } from "../sigmascript/lib/struct"; +import { ArrayLib } from "../sigmascript/lib/array"; +import { MathLib } from "../sigmascript/lib/math"; + +export namespace BrowserRuntime { + export function addLibraries(sigmaScript: SigmaScript) { + sigmaScript.addLib("dom", new DOMLib(sigmaScript)); + sigmaScript.addLib("fn", new FnLib(sigmaScript)); + sigmaScript.addLib("js", new BrowserJSLib(sigmaScript)); + sigmaScript.addLib("ref", new RefLib(sigmaScript)); + sigmaScript.addLib("string", new StringLib(sigmaScript)); + sigmaScript.addLib("struct", new StructLib(sigmaScript)); + sigmaScript.addLib("array", new ArrayLib(sigmaScript)); + sigmaScript.addLib("math", new MathLib(sigmaScript)); + } +} \ No newline at end of file diff --git a/src/runtimes/node.ts b/src/runtimes/node.ts new file mode 100644 index 0000000..cc274ce --- /dev/null +++ b/src/runtimes/node.ts @@ -0,0 +1,20 @@ +import { SigmaScript } from "../sigmascript/sigmascript"; +import { FnLib } from "../sigmascript/lib/fn"; +import { NodeJSLib } from "../sigmascript/lib/js-node"; +import { RefLib } from "../sigmascript/lib/ref"; +import { StringLib } from "../sigmascript/lib/string"; +import { StructLib } from "../sigmascript/lib/struct"; +import { ArrayLib } from "../sigmascript/lib/array"; +import { MathLib } from "../sigmascript/lib/math"; + +export namespace NodeRuntime { + export function addLibraries(sigmaScript: SigmaScript) { + sigmaScript.addLib("fn", new FnLib(sigmaScript)); + sigmaScript.addLib("js", new NodeJSLib(sigmaScript)); + sigmaScript.addLib("ref", new RefLib(sigmaScript)); + sigmaScript.addLib("string", new StringLib(sigmaScript)); + sigmaScript.addLib("struct", new StructLib(sigmaScript)); + sigmaScript.addLib("array", new ArrayLib(sigmaScript)); + sigmaScript.addLib("math", new MathLib(sigmaScript)); + } +} \ No newline at end of file diff --git a/src/sigmascript/index.ts b/src/sigmascript/index.ts index 4323c9a..f868fda 100644 --- a/src/sigmascript/index.ts +++ b/src/sigmascript/index.ts @@ -1,5 +1,7 @@ +import { initLoader } from "../loader"; +import { BrowserRuntime } from "../runtimes/browser"; import { NativeLib } from "./lib"; -import { SigmaScript } from "./sigmascript"; +import { MIME_TYPE, SigmaScript } from "./sigmascript"; declare global { interface Window { @@ -11,4 +13,5 @@ declare global { window.NativeLib = NativeLib; window.sigmaScript = new SigmaScript(); -window.sigmaScript.initLoader(); \ No newline at end of file +BrowserRuntime.addLibraries(window.sigmaScript); +initLoader(MIME_TYPE, (source) => window.sigmaScript.load(source)); \ No newline at end of file diff --git a/src/sigmascript/lib/js-browser.ts b/src/sigmascript/lib/js-browser.ts new file mode 100644 index 0000000..fe1d4d4 --- /dev/null +++ b/src/sigmascript/lib/js-browser.ts @@ -0,0 +1,7 @@ +import { JSLib } from "./js"; + +export class BrowserJSLib extends JSLib { + readonly variables: Readonly<{ [key: string]: string }> = { + js_window: this.registry.add(window) + }; +} \ No newline at end of file diff --git a/src/sigmascript/lib/js-node.ts b/src/sigmascript/lib/js-node.ts new file mode 100644 index 0000000..8323d5c --- /dev/null +++ b/src/sigmascript/lib/js-node.ts @@ -0,0 +1,7 @@ +import { JSLib } from "./js"; + +export class NodeJSLib extends JSLib { + readonly variables: Readonly<{ [key: string]: string }> = { + js_global: this.registry.add(globalThis) + }; +} \ No newline at end of file diff --git a/src/sigmascript/lib/js.ts b/src/sigmascript/lib/js.ts index e73f043..8978bd8 100644 --- a/src/sigmascript/lib/js.ts +++ b/src/sigmascript/lib/js.ts @@ -10,11 +10,8 @@ import { StructLib } from "./struct"; const ssSymbol = Symbol("ss"); export class JSLib extends NativeLib { - private readonly registry = new Registry("js"); + protected readonly registry = new Registry("js"); - readonly variables: Readonly<{ [key: string]: string }> = { - js_window: this.registry.add(window) - }; readonly functions: Readonly<{ [key: string]: SSFunction }> = { js: ([ code ]) => this.js(code), js_get: ([ handle, property ]) => this.get(handle, property), diff --git a/src/sigmascript/lib/math.ts b/src/sigmascript/lib/math.ts index 288cb3d..ee6885b 100644 --- a/src/sigmascript/lib/math.ts +++ b/src/sigmascript/lib/math.ts @@ -17,6 +17,7 @@ export class MathLib extends NativeLib { abs: mathfn((x) => Math.abs(x)), sign: mathfn((x) => Math.sign(x)), sqrt: mathfn((x) => Math.sqrt(x)), + mod: mathfn((x, y) => x % y), sin: mathfn((x) => Math.sin(x)), cos: mathfn((x) => Math.cos(x)), tan: mathfn((x) => Math.tan(x)), diff --git a/src/sigmascript/sigmascript.ts b/src/sigmascript/sigmascript.ts index f129e36..b9d325c 100644 --- a/src/sigmascript/sigmascript.ts +++ b/src/sigmascript/sigmascript.ts @@ -1,15 +1,8 @@ import { ASTElement, Grammar, Parser, inherit } from "../parser"; import { Lib, SigmaScriptLib } from "./lib"; -import { DOMLib } from "./lib/dom"; import { FnLib } from "./lib/fn"; import { JSLib } from "./lib/js"; -import { RefLib } from "./lib/ref"; -import { StringLib } from "./lib/string"; -import { StructLib } from "./lib/struct"; -import { ArrayLib } from "./lib/array"; -import { MathLib } from "./lib/math"; import { grammar } from "./grammar"; -import { initLoader } from "../loader"; export const MIME_TYPE = "text/sigmascript"; @@ -39,15 +32,6 @@ export class SigmaScript { constructor(mergeGrammar: Partial = {}) { this.parser = new Parser(inherit(grammar, mergeGrammar)); - - this.addLib("dom", new DOMLib(this)); - this.addLib("fn", new FnLib(this)); - this.addLib("js", new JSLib(this)); - this.addLib("ref", new RefLib(this)); - this.addLib("string", new StringLib(this)); - this.addLib("struct", new StructLib(this)); - this.addLib("array", new ArrayLib(this)); - this.addLib("math", new MathLib(this)); } private fnScope(scope: Scope, args: string[], params: string[]) { @@ -256,8 +240,4 @@ export class SigmaScript { else return this.execute(program); } - - initLoader() { - initLoader(MIME_TYPE, (source) => this.load(source)); - } } \ No newline at end of file diff --git a/src/sigmascriptx/index.ts b/src/sigmascriptx/index.ts index d826103..a79a090 100644 --- a/src/sigmascriptx/index.ts +++ b/src/sigmascriptx/index.ts @@ -1,7 +1,11 @@ +import { initLoader } from "../loader"; +import { BrowserRuntime } from "../runtimes/browser"; import { NativeLib } from "../sigmascript/lib"; +import { MIME_TYPE } from "../sigmascript/sigmascript"; import { SigmaScriptX } from "./sigmascriptx"; window.NativeLib = NativeLib; window.sigmaScript = new SigmaScriptX(); -window.sigmaScript.initLoader(); \ No newline at end of file +BrowserRuntime.addLibraries(window.sigmaScript); +initLoader(MIME_TYPE, (source) => window.sigmaScript.load(source)); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 2a4d568..4a3dbd2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "outDir": "./dist/", "noImplicitAny": true, - "module": "es6", + "module": "es2022", "target": "es2021", "jsx": "react", "allowJs": true, diff --git a/webpack.prod.js b/webpack.prod.js index 7cc0172..d8a510d 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -1,7 +1,9 @@ +const webpack = require("webpack"); const { merge } = require("webpack-merge"); const common = require("./webpack.common.js"); +const TerserPlugin = require("terser-webpack-plugin"); -module.exports = merge(common, { +const browserConfig = merge(common, { mode: "production", module: { rules: [ @@ -12,4 +14,44 @@ module.exports = merge(common, { } ] } -}); \ No newline at end of file +}); + +const nodeConfig = { + mode: "production", + target: "node", + entry: "./src/bin.ts", + module: { + rules: [ + { + test: /\.tsx?$/, + use: "ts-loader", + exclude: /node_modules/ + } + ] + }, + resolve: { + extensions: [".tsx", ".ts", ".js"] + }, + output: { + filename: "bin/sigmascript.js", + path: __dirname + }, + optimization: { + minimizer: [ + new TerserPlugin({ + extractComments: false + }) + ] + }, + plugins: [ + new webpack.BannerPlugin({ + banner: "#!/usr/bin/env node", + raw: true + }), + new webpack.optimize.LimitChunkCountPlugin({ + maxChunks: 1 + }) + ] +}; + +module.exports = [nodeConfig, browserConfig]; \ No newline at end of file