Skip to content

Commit 75d62eb

Browse files
committed
YuJianrong#3 Make emscripten module build and import browserify-friendly
Solves the "unrar.RarArchive is not a constructor" YuJianrong#3
1 parent 3b9f3df commit 75d62eb

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"prebuildRelease": "npm run tslint",
2121
"buildRelease": "npm run clean && tsc && node ./dist/build/make.js release",
2222
"debug": "npm run test -- --debug-brk --inspect",
23-
2423
"coverage": "tsc --sourceMap --outDir dist_map && istanbul cover node_modules/.bin/_mocha -- dist_map/test/*.spec.js",
2524
"browserify": "mkdir umd; browserify dist/index.js -s array-diff -o umd/array-diff.js"
2625
},
@@ -32,9 +31,10 @@
3231
"devDependencies": {
3332
"@types/mocha": "^2.2.40",
3433
"@types/shelljs": "^0.7.0",
34+
"browserify": "^17.0.0",
3535
"mocha": "^3.2.0",
3636
"shelljs": "^0.7.7",
3737
"tslint": "^5.0.0",
38-
"typescript": "^2.2.2"
38+
"typescript": "^3.5.1"
3939
}
4040
}

src/build/make.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ shjs.exec([
7676
"-std=c++14",
7777
"-s ALLOW_MEMORY_GROWTH=1",
7878
"-s DISABLE_EXCEPTION_CATCHING=0",
79+
"-s MODULARIZE=1",
7980
"--memory-init-file 0",
8081
release ? "-O3" : "-g4",
8182
"--js-library ./src/cpp/bridge/bridge.js",

src/js/dataExtractor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {DataFile} from "./dataFile";
22
import {Extractor, SeekMethod} from "./extractor";
3-
import * as unrar from "./unrar";
3+
import unrar from "./unrarSingleton";
44

55
export class DataExtractor extends Extractor {
66
protected _filePath: string;

src/js/extractor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import { Ext as extIns } from "./extractorCurrent";
3-
import * as unrar from "./unrar";
3+
import unrar from "./unrarSingleton";
44

55
export type SeekMethod = "CUR" | "SET" | "END";
66

src/js/fileExtractor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as fs from "fs";
22
import * as path from "path";
33

44
import { Extractor, SeekMethod } from "./extractor";
5-
import * as unrar from "./unrar";
5+
import unrar from "./unrarSingleton";
66

77
export class FileExtractor extends Extractor {
88
protected _filePath: string;

src/js/unrarSingleton.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as unrarCls from "./unrar";
2+
3+
const unrar = new (<any>unrarCls);
4+
5+
export default unrar;

0 commit comments

Comments
 (0)