Skip to content

Commit 5eb99ee

Browse files
authored
fix: Bundle specific shims with asc instead of relying on defaults (#1405)
1 parent 46c06da commit 5eb99ee

File tree

9 files changed

+610
-18
lines changed

9 files changed

+610
-18
lines changed

Diff for: cli/asc.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@
3030

3131
/* global BUNDLE_VERSION, BUNDLE_LIBRARY, BUNDLE_DEFINITIONS */
3232

33-
// Use "." instead of "/" as cwd in browsers
34-
if (process.browser) process.cwd = function() { return "."; };
35-
3633
const fs = require("fs");
3734
const path = require("path");
35+
const process = require("process"); // ensure shim
36+
3837
const utf8 = require("./util/utf8");
3938
const colorsUtil = require("./util/colors");
4039
const optionsUtil = require("./util/options");
4140
const mkdirp = require("./util/mkdirp");
4241
const find = require("./util/find");
42+
const binaryen = global.binaryen || (global.binaryen = require("binaryen"));
43+
4344
const EOL = process.platform === "win32" ? "\r\n" : "\n";
4445
const SEP = process.platform === "win32" ? "\\" : "/";
45-
const binaryen = global.binaryen || (global.binaryen = require("binaryen"));
4646

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

352352
// returns a relative path from baseDir
353353
function makeRelative(arg) {
354-
// FIXME: see https://github.com/AssemblyScript/assemblyscript/issues/1398
355-
if (baseDir === ".") return arg;
356354
return path.relative(baseDir, arg);
357355
}
358356

@@ -1109,8 +1107,6 @@ function createStats() {
11091107

11101108
exports.createStats = createStats;
11111109

1112-
if (!process.hrtime) process.hrtime = require("browser-process-hrtime");
1113-
11141110
/** Measures the execution time of the specified function. */
11151111
function measure(fn) {
11161112
const start = process.hrtime();

Diff for: cli/shim/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Shims used when bundling asc for browser usage.

Diff for: cli/shim/fs.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {};

0 commit comments

Comments
 (0)