Skip to content

Bundle specific shims with asc instead of relying on defaults #1405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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