Skip to content

Commit

Permalink
YuJianrong#3 Make emscripten module build and import browserify-friendly
Browse files Browse the repository at this point in the history
Solves the "unrar.RarArchive is not a constructor"

YuJianrong#3
  • Loading branch information
klesun committed Dec 26, 2020
1 parent 3b9f3df commit 75d62eb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"prebuildRelease": "npm run tslint",
"buildRelease": "npm run clean && tsc && node ./dist/build/make.js release",
"debug": "npm run test -- --debug-brk --inspect",

"coverage": "tsc --sourceMap --outDir dist_map && istanbul cover node_modules/.bin/_mocha -- dist_map/test/*.spec.js",
"browserify": "mkdir umd; browserify dist/index.js -s array-diff -o umd/array-diff.js"
},
Expand All @@ -32,9 +31,10 @@
"devDependencies": {
"@types/mocha": "^2.2.40",
"@types/shelljs": "^0.7.0",
"browserify": "^17.0.0",
"mocha": "^3.2.0",
"shelljs": "^0.7.7",
"tslint": "^5.0.0",
"typescript": "^2.2.2"
"typescript": "^3.5.1"
}
}
1 change: 1 addition & 0 deletions src/build/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ shjs.exec([
"-std=c++14",
"-s ALLOW_MEMORY_GROWTH=1",
"-s DISABLE_EXCEPTION_CATCHING=0",
"-s MODULARIZE=1",
"--memory-init-file 0",
release ? "-O3" : "-g4",
"--js-library ./src/cpp/bridge/bridge.js",
Expand Down
2 changes: 1 addition & 1 deletion src/js/dataExtractor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {DataFile} from "./dataFile";
import {Extractor, SeekMethod} from "./extractor";
import * as unrar from "./unrar";
import unrar from "./unrarSingleton";

export class DataExtractor extends Extractor {
protected _filePath: string;
Expand Down
2 changes: 1 addition & 1 deletion src/js/extractor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { Ext as extIns } from "./extractorCurrent";
import * as unrar from "./unrar";
import unrar from "./unrarSingleton";

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

Expand Down
2 changes: 1 addition & 1 deletion src/js/fileExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from "fs";
import * as path from "path";

import { Extractor, SeekMethod } from "./extractor";
import * as unrar from "./unrar";
import unrar from "./unrarSingleton";

export class FileExtractor extends Extractor {
protected _filePath: string;
Expand Down
5 changes: 5 additions & 0 deletions src/js/unrarSingleton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as unrarCls from "./unrar";

const unrar = new (<any>unrarCls);

export default unrar;

0 comments on commit 75d62eb

Please sign in to comment.