browser-pack-6.0.4/000077500000000000000000000000001323654320700141255ustar00rootroot00000000000000browser-pack-6.0.4/.gitignore000066400000000000000000000000151323654320700161110ustar00rootroot00000000000000node_modules browser-pack-6.0.4/.travis.yml000066400000000000000000000001321323654320700162320ustar00rootroot00000000000000language: node_js node_js: - "0.10" - "0.12" - "4" - "6" - "8" - "9" - node browser-pack-6.0.4/CHANGELOG.md000066400000000000000000000004371323654320700157420ustar00rootroot00000000000000# browser-pack Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## 6.0.4 - 2018-02-07 * Fix prelude compatibility for Opera 10.x [#84](https://github.com/browserify/browser-pack/pull/84) browser-pack-6.0.4/LICENSE000066400000000000000000000020611323654320700151310ustar00rootroot00000000000000This software is released under the MIT license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. browser-pack-6.0.4/bin/000077500000000000000000000000001323654320700146755ustar00rootroot00000000000000browser-pack-6.0.4/bin/cmd.js000077500000000000000000000001411323654320700157750ustar00rootroot00000000000000#!/usr/bin/env node var pack = require('../')(); process.stdin.pipe(pack).pipe(process.stdout); browser-pack-6.0.4/bin/prepublish.js000077500000000000000000000004041323654320700174110ustar00rootroot00000000000000#!/usr/bin/env node var uglify = require('uglify-js'); var fs = require('fs'); var path = require('path'); var src = fs.readFileSync(path.join(__dirname, '..', 'prelude.js'), 'utf8'); fs.writeFileSync(path.join(__dirname, '..', '_prelude.js'), uglify(src)); browser-pack-6.0.4/example/000077500000000000000000000000001323654320700155605ustar00rootroot00000000000000browser-pack-6.0.4/example/input.json000066400000000000000000000003731323654320700176150ustar00rootroot00000000000000[ { "id": "a1b5af78", "source": "console.log(require('./foo')(5))", "deps": { "./foo": "b8f69fa5" }, "entry": true }, { "id": "b8f69fa5", "source": "module.exports = function (n) { return n * 111 }", "deps": {} } ] browser-pack-6.0.4/example/sourcemap/000077500000000000000000000000001323654320700175565ustar00rootroot00000000000000browser-pack-6.0.4/example/sourcemap/input.json000066400000000000000000000004721323654320700216130ustar00rootroot00000000000000[ { "id": "a1b5af78", "source": "console.log(require('./foo')(5))", "deps": { "./foo": "b8f69fa5" }, "entry": true, "sourceFile": "wunder/bar.js" }, { "id": "b8f69fa5", "source": "module.exports = function (n) { return n * 111 }", "deps": {}, "sourceFile": "foo.js" } ] browser-pack-6.0.4/index.js000066400000000000000000000077661323654320700156120ustar00rootroot00000000000000var JSONStream = require('JSONStream'); var defined = require('defined'); var through = require('through2'); var umd = require('umd'); var Buffer = require('safe-buffer').Buffer; var fs = require('fs'); var path = require('path'); var combineSourceMap = require('combine-source-map'); var defaultPreludePath = path.join(__dirname, '_prelude.js'); var defaultPrelude = fs.readFileSync(defaultPreludePath, 'utf8'); function newlinesIn(src) { if (!src) return 0; var newlines = src.match(/\n/g); return newlines ? newlines.length : 0; } module.exports = function (opts) { if (!opts) opts = {}; var parser = opts.raw ? through.obj() : JSONStream.parse([ true ]); var stream = through.obj( function (buf, enc, next) { parser.write(buf); next() }, function () { parser.end() } ); parser.pipe(through.obj(write, end)); stream.standaloneModule = opts.standaloneModule; stream.hasExports = opts.hasExports; var first = true; var entries = []; var basedir = defined(opts.basedir, process.cwd()); var prelude = opts.prelude || defaultPrelude; var preludePath = opts.preludePath || path.relative(basedir, defaultPreludePath).replace(/\\/g, '/'); var lineno = 1 + newlinesIn(prelude); var sourcemap; return stream; function write (row, enc, next) { if (first && opts.standalone) { var pre = umd.prelude(opts.standalone).trim(); stream.push(Buffer.from(pre + 'return ', 'utf8')); } else if (first && stream.hasExports) { var pre = opts.externalRequireName || 'require'; stream.push(Buffer.from(pre + '=', 'utf8')); } if (first) stream.push(Buffer.from(prelude + '({', 'utf8')); if (row.sourceFile && !row.nomap) { if (!sourcemap) { sourcemap = combineSourceMap.create(); sourcemap.addFile( { sourceFile: preludePath, source: prelude }, { line: 0 } ); } sourcemap.addFile( { sourceFile: row.sourceFile, source: row.source }, { line: lineno } ); } var wrappedSource = [ (first ? '' : ','), JSON.stringify(row.id), ':[', 'function(require,module,exports){\n', combineSourceMap.removeComments(row.source), '\n},', '{' + Object.keys(row.deps || {}).sort().map(function (key) { return JSON.stringify(key) + ':' + JSON.stringify(row.deps[key]) ; }).join(',') + '}', ']' ].join(''); stream.push(Buffer.from(wrappedSource, 'utf8')); lineno += newlinesIn(wrappedSource); first = false; if (row.entry && row.order !== undefined) { entries[row.order] = row.id; } else if (row.entry) entries.push(row.id); next(); } function end () { if (first) stream.push(Buffer.from(prelude + '({', 'utf8')); entries = entries.filter(function (x) { return x !== undefined }); stream.push( Buffer.from('},{},' + JSON.stringify(entries) + ')', 'utf8') ); if (opts.standalone && !first) { stream.push(Buffer.from( '(' + JSON.stringify(stream.standaloneModule) + ')' + umd.postlude(opts.standalone), 'utf8' )); } if (sourcemap) { var comment = sourcemap.comment(); if (opts.sourceMapPrefix) { comment = comment.replace( /^\/\/#/, function () { return opts.sourceMapPrefix } ) } stream.push(Buffer.from('\n' + comment + '\n', 'utf8')); } if (!sourcemap && !opts.standalone) { stream.push(Buffer.from(';\n', 'utf8')); } stream.push(null); } }; browser-pack-6.0.4/package.json000066400000000000000000000025351323654320700164200ustar00rootroot00000000000000{ "name": "browser-pack", "version": "6.0.4", "description": "pack node-style source files from a json stream into a browser bundle", "main": "index.js", "bin": { "browser-pack": "bin/cmd.js" }, "dependencies": { "JSONStream": "^1.0.3", "combine-source-map": "~0.8.0", "defined": "^1.0.0", "safe-buffer": "^5.1.1", "through2": "^2.0.0", "umd": "^3.0.0" }, "devDependencies": { "tap": "^10.7.2", "uglify-js": "1.3.5", "concat-stream": "~1.5.1", "convert-source-map": "~1.1.0", "parse-base64vlq-mappings": "~0.1.1" }, "scripts": { "test": "tap test/*.js", "prepublish": "node bin/prepublish.js" }, "testling": { "files": "test/*.js", "browsers": [ "ie/8", "ie/9", "ie/10", "chrome/15", "chrome/latest", "firefox/10", "firefox/latest", "safari/latest", "opera/10", "opera/latest" ] }, "repository": { "type": "git", "url": "git://github.com/browserify/browser-pack.git" }, "homepage": "https://github.com/browserify/browser-pack", "keywords": [ "browser", "bundle", "commonjs", "commonj-esque", "exports", "module.exports", "require" ], "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, "license": "MIT" } browser-pack-6.0.4/prelude.js000066400000000000000000000035731323654320700161330ustar00rootroot00000000000000 // modules are defined as an array // [ module function, map of requireuires ] // // map of requireuires is short require name -> numeric require // // anything defined in a previous bundle is accessed via the // orig method which is the requireuire for previous bundles (function() { function outer(modules, cache, entry) { // Save the require from previous bundle to this closure if any var previousRequire = typeof require == "function" && require; function newRequire(name, jumped){ if(!cache[name]) { if(!modules[name]) { // if we cannot find the module within our internal map or // cache jump to the current global require ie. the last bundle // that was added to the page. var currentRequire = typeof require == "function" && require; if (!jumped && currentRequire) return currentRequire(name, true); // If there are other bundles on this page the require from the // previous one is saved to 'previousRequire'. Repeat this as // many times as there are bundles until the module is found or // we exhaust the require chain. if (previousRequire) return previousRequire(name, true); var err = new Error('Cannot find module \'' + name + '\''); err.code = 'MODULE_NOT_FOUND'; throw err; } var m = cache[name] = {exports:{}}; 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 cache[name].exports; } for(var i=0;i