Skip to content

expose module.parent as in node #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,24 @@ module.exports = function (opts) {
{ line: lineno }
);
}

var wrappedSource = [
(first ? '' : ','),
JSON.stringify(row.id),
':[',
'function(require,module,exports){\n',
'function(require,module,exports,__dirname,__filename){\n',
combineSourceMap.removeComments(row.source),
'\n},',
'{' + Object.keys(row.deps || {}).sort().map(function (key) {
return JSON.stringify(key) + ':'
+ JSON.stringify(row.deps[key])
;
}).join(',') + '}',
']'
',\n',
JSON.stringify(row.id),
',\n',
JSON.stringify(path.dirname(row.id)),
'\n]'
].join('');

stream.push(Buffer(wrappedSource));
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "browser-pack",
"version": "5.0.0",
"description": "pack node-style source files from a json stream into a browser bundle",
"name": "nodepack",
"version": "6.0.0",
"description": "pack browserify bundles for node",
"main": "index.js",
"bin": {
"browser-pack": "bin/cmd.js"
Expand Down
9 changes: 5 additions & 4 deletions prelude.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Save the require from previous bundle to this closure if any
var previousRequire = typeof require == "function" && require;

function newRequire(name, jumped){
function newRequire(name, jumped, parent){
if(!cache[name]) {
if(!modules[name]) {
// if we cannot find the module within our internal map or
Expand All @@ -29,11 +29,12 @@
err.code = 'MODULE_NOT_FOUND';
throw err;
}
var m = cache[name] = {exports:{}};
var m = cache[name] = {exports:{}, parent: parent};
modules[name][0].call(m.exports, function(x){
var id = modules[name][1][x];
return newRequire(id ? id : x);
},m,m.exports,outer,modules,cache,entry);
return newRequire(id ? id : x, null, m);
// },m,m.exports,outer,modules,cache,entry);
},m,m.exports, modules[name][2], modules[name][3]);
}
return cache[name].exports;
}
Expand Down
8 changes: 2 additions & 6 deletions readme.markdown
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# browser-pack
# nodepack

pack node-style source files from a json stream into a browser bundle

[![browser support](http://ci.testling.com/substack/browser-pack.png)](http://ci.testling.com/substack/browser-pack)

[![build status](https://secure.travis-ci.org/substack/browser-pack.png)](http://travis-ci.org/substack/browser-pack)
a fork of browser-pack that packs for node. used by noderify

# example

Expand Down
1 change: 1 addition & 0 deletions test/source-maps-existing.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
return console.error('skip sourcemap tests')
var test = require('tap').test;
var pack = require('../');
var convert = require('convert-source-map');
Expand Down
2 changes: 2 additions & 0 deletions test/source-maps.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
return console.error('skip sourcemap tests')
var test = require('tap').test;

var pack = require('../');
var path = require('path');

Expand Down