Skip to content

Commit 6c289b3

Browse files
committed
Fallback to use fs if webpack is not detected, should work on any other bundler that supports Node.js fs API
1 parent f0805e7 commit 6c289b3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ global.mpjsPrintStdout = stdout_print;
1717
global.formatString = (object) => object !== undefined ? JSON.stringify(object) : null
1818

1919
const mp = require('./lib/micropython.js');
20-
if (typeof window === 'undefined' && typeof importScripts === 'undefined') {
20+
if (typeof webpackJsonp !== 'object') {
2121
browser = false;
2222
pyjs = require('fs').readFileSync(__dirname + '/js.py').toString();
2323
}

lib/micropython.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ var mainProgram = function()
7676

7777
Module["onRuntimeInitialized"] = mainProgram;
7878

79-
if (typeof window === 'undefined' && typeof importScripts === 'undefined') {
79+
if (typeof webpackJsonp !== 'object') {
8080
const file = require('fs').readFileSync(__dirname + '/micropython.binary');
8181
Module.emterpreterFile = file.buffer.slice(file.byteOffset, file.byteOffset + file.byteLength);
8282
}
8383
else {
84-
Module.emterpreterFile = require('arraybuffer!./micropython.binary');
84+
Module.emterpreterFile = require('!arraybuffer-loader!./micropython.binary');
8585
}
8686
// Copyright 2010 The Emscripten Authors. All rights reserved.
8787
// Emscripten is available under two separate licenses, the MIT license and the

0 commit comments

Comments
 (0)