Skip to content

Commit

Permalink
fix: Bundle specific shims with asc instead of relying on defaults (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO authored Jul 22, 2020
1 parent 46c06da commit 5eb99ee
Show file tree
Hide file tree
Showing 9 changed files with 610 additions and 18 deletions.
12 changes: 4 additions & 8 deletions cli/asc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@

/* global BUNDLE_VERSION, BUNDLE_LIBRARY, BUNDLE_DEFINITIONS */

// Use "." instead of "/" as cwd in browsers
if (process.browser) process.cwd = function() { return "."; };

const fs = require("fs");
const path = require("path");
const process = require("process"); // ensure shim

const utf8 = require("./util/utf8");
const colorsUtil = require("./util/colors");
const optionsUtil = require("./util/options");
const mkdirp = require("./util/mkdirp");
const find = require("./util/find");
const binaryen = global.binaryen || (global.binaryen = require("binaryen"));

const EOL = process.platform === "win32" ? "\r\n" : "\n";
const SEP = process.platform === "win32" ? "\\" : "/";
const binaryen = global.binaryen || (global.binaryen = require("binaryen"));

// Sets up an extension with its definition counterpart and relevant regexes.
function setupExtension(extension) {
Expand Down Expand Up @@ -351,8 +351,6 @@ exports.main = function main(argv, options, callback) {

// returns a relative path from baseDir
function makeRelative(arg) {
// FIXME: see https://github.com/AssemblyScript/assemblyscript/issues/1398
if (baseDir === ".") return arg;
return path.relative(baseDir, arg);
}

Expand Down Expand Up @@ -1109,8 +1107,6 @@ function createStats() {

exports.createStats = createStats;

if (!process.hrtime) process.hrtime = require("browser-process-hrtime");

/** Measures the execution time of the specified function. */
function measure(fn) {
const start = process.hrtime();
Expand Down
1 change: 1 addition & 0 deletions cli/shim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Shims used when bundling asc for browser usage.
1 change: 1 addition & 0 deletions cli/shim/fs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
Loading

0 comments on commit 5eb99ee

Please sign in to comment.