Comparing version 1.2.5 to 1.2.6
@@ -1,2 +0,1 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
@@ -3,0 +2,0 @@ var __importDefault = (this && this.__importDefault) || function (mod) { |
@@ -141,3 +141,3 @@ var assert = require("assert"); | ||
var magicBindings = moduleWrapper.params.map(scan.getBinding); | ||
var magicNames = ["module", "exports", "require"]; | ||
var magicNames = ["module", "exports", "$$dprequire$$"]; | ||
var edit = source ? multisplice(source) : null; | ||
@@ -154,3 +154,7 @@ magicBindings.forEach(function (binding, i) { | ||
}); | ||
return edit ? edit.toString() : null; | ||
return edit | ||
? edit.toString() | ||
.replace(/\$\$dprequire\$\$\((\d+)\)/g, 'require("./$1.js")') | ||
.replace(/\$\$dprequire\$\$/g, "require") | ||
: null; | ||
} | ||
@@ -157,0 +161,0 @@ function getDependencies(moduleWrapper) { |
{ | ||
"name": "dpacker", | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -38,1 +38,9 @@ # DPacker | ||
The files will be written into an `out` folder :) | ||
## Features | ||
Splits large webpack bundle files into their individual modules. Has de-duplication built in, but can be disabled with the `-d` flag. | ||
Converts requires and module.exports to correct form, rather than webpack's (e, t, n) format | ||
`require`s that point to a module ID will be mapped to `require("./moduleId.js")` for IDE compatibility, and should help with recompilation. |
// webpack-unpack | ||
// obtained from https://github.com/goto-bus-stop/webpack-unpack | ||
// modified to allow for arrow functions & "use-strict" declarations | ||
// modified to allow for arrow functions, "use-strict" declarations, & mapping require(123) to require("./123.js") | ||
@@ -196,3 +196,3 @@ var assert = require("assert"); | ||
var magicBindings = moduleWrapper.params.map(scan.getBinding); | ||
var magicNames = ["module", "exports", "require"]; | ||
var magicNames = ["module", "exports", "$$dprequire$$"]; | ||
var edit = source ? multisplice(source) : null; | ||
@@ -204,3 +204,2 @@ | ||
if (ref === binding.definition) return; | ||
ref.name = name; | ||
@@ -211,3 +210,9 @@ if (edit) edit.splice(ref.start - offset, ref.end - offset, name); | ||
return edit ? edit.toString() : null; | ||
return edit | ||
? edit.toString() | ||
// replace $$dprequire$$(id) with require("./id.js") | ||
.replace(/\$\$dprequire\$\$\((\d+)\)/g, 'require("./$1.js")') | ||
// some requires are in a require.x = "..." format, so just turn these back to require | ||
.replace(/\$\$dprequire\$\$/g, "require") | ||
: null; | ||
} | ||
@@ -214,0 +219,0 @@ |
30368
815
46