init
This commit is contained in:
9
node_modules/browser-pack/.travis.yml
generated
vendored
Normal file
9
node_modules/browser-pack/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "4"
|
||||
- "6"
|
||||
- "8"
|
||||
- "9"
|
||||
- node
|
10
node_modules/browser-pack/CHANGELOG.md
generated
vendored
Normal file
10
node_modules/browser-pack/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# 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.1.0 - 2018-03-30
|
||||
* Add option to define source map root [#74](https://github.com/browserify/browser-pack/pull/74)
|
||||
* Use uglify-js@2 to minify prelude [#87](https://github.com/browserify/browser-pack/pull/87)
|
||||
|
||||
## 6.0.4 - 2018-02-07
|
||||
* Fix prelude compatibility for Opera 10.x [#84](https://github.com/browserify/browser-pack/pull/84)
|
18
node_modules/browser-pack/LICENSE
generated
vendored
Normal file
18
node_modules/browser-pack/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
This 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.
|
1
node_modules/browser-pack/_prelude.js
generated
vendored
Normal file
1
node_modules/browser-pack/_prelude.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()
|
4
node_modules/browser-pack/bin/cmd.js
generated
vendored
Normal file
4
node_modules/browser-pack/bin/cmd.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var pack = require('../')();
|
||||
process.stdin.pipe(pack).pipe(process.stdout);
|
21
node_modules/browser-pack/bin/prepublish.js
generated
vendored
Normal file
21
node_modules/browser-pack/bin/prepublish.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var spawn = require('child_process').spawn;
|
||||
var fs = require('fs');
|
||||
var concat = require('concat-stream');
|
||||
var path = require('path');
|
||||
|
||||
var uglify = spawn(
|
||||
require.resolve('uglify-js/bin/uglifyjs'),
|
||||
['--wrap-iife', '-c', 'side_effects=false,screw_ie8=false', '--verbose', '--ie8', '--passes=5', '-m', '--source-map', '--', '-']
|
||||
);
|
||||
|
||||
fs.createReadStream(path.join(__dirname, '..', 'prelude.js'))
|
||||
.pipe(uglify.stdin)
|
||||
;
|
||||
|
||||
uglify.stdout
|
||||
.pipe(concat({ encoding: 'string' }, function (str) {
|
||||
fs.writeFileSync(path.join(__dirname, '..', '_prelude.js'), str.replace(/;\s*$/, ''));
|
||||
}))
|
||||
;
|
13
node_modules/browser-pack/example/input.json
generated
vendored
Normal file
13
node_modules/browser-pack/example/input.json
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"id": "a1b5af78",
|
||||
"source": "console.log(require('./foo')(5))",
|
||||
"deps": { "./foo": "b8f69fa5" },
|
||||
"entry": true
|
||||
},
|
||||
{
|
||||
"id": "b8f69fa5",
|
||||
"source": "module.exports = function (n) { return n * 111 }",
|
||||
"deps": {}
|
||||
}
|
||||
]
|
1
node_modules/browser-pack/example/output.js
generated
vendored
Normal file
1
node_modules/browser-pack/example/output.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(p,c,e){function r(n){if(!c[n]){c[n]={exports:{}};p[n][0](function(x){return r(p[n][1][x])},c[n],c[n].exports);}return c[n].exports}for(var i=0;i<e.length;i++)r(e[i]);return r})({"a1b5af78":[function(require,module,exports){console.log(require('./foo')(5))},{"./foo":"b8f69fa5"}],"b8f69fa5":[function(require,module,exports){module.exports = function (n) { return n * 111 }},{}]},{},["a1b5af78","b8f69fa5"])
|
15
node_modules/browser-pack/example/sourcemap/input.json
generated
vendored
Normal file
15
node_modules/browser-pack/example/sourcemap/input.json
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
6
node_modules/browser-pack/example/sourcemap/output.js
generated
vendored
Normal file
6
node_modules/browser-pack/example/sourcemap/output.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
(function(e,t,n,r){function i(r){if(!n[r]){if(!t[r]){if(e)return e(r);throw new Error("Cannot find module '"+r+"'")}var s=n[r]={exports:{}};t[r][0](function(e){var n=t[r][1][e];return i(n?n:e)},s,s.exports)}return n[r].exports}for(var s=0;s<r.length;s++)i(r[s]);return i})(typeof require!=="undefined"&&require,{"a1b5af78":[function(require,module,exports){
|
||||
console.log(require('./foo')(5))
|
||||
},{"./foo":"b8f69fa5"}],"b8f69fa5":[function(require,module,exports){
|
||||
module.exports = function (n) { return n * 111 }
|
||||
},{}]},{},["a1b5af78"])
|
||||
//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJ3dW5kZXIvYmFyLmpzIiwiZm9vLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7QUNBQSJ9
|
127
node_modules/browser-pack/index.js
generated
vendored
Normal file
127
node_modules/browser-pack/index.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
var 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(null, opts.sourceRoot);
|
||||
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);
|
||||
}
|
||||
};
|
63
node_modules/browser-pack/package.json
generated
vendored
Normal file
63
node_modules/browser-pack/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "browser-pack",
|
||||
"version": "6.1.0",
|
||||
"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": {
|
||||
"concat-stream": "~1.5.1",
|
||||
"convert-source-map": "~1.1.0",
|
||||
"parse-base64vlq-mappings": "~0.1.1",
|
||||
"tap": "^10.7.2",
|
||||
"uglify-js": "^2.8.29"
|
||||
},
|
||||
"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"
|
||||
}
|
50
node_modules/browser-pack/prelude.js
generated
vendored
Normal file
50
node_modules/browser-pack/prelude.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
// 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<entry.length;i++) newRequire(entry[i]);
|
||||
|
||||
// Override the current require with this new one
|
||||
return newRequire;
|
||||
}
|
||||
|
||||
return outer;
|
||||
|
||||
})()
|
97
node_modules/browser-pack/readme.markdown
generated
vendored
Normal file
97
node_modules/browser-pack/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
# browser-pack
|
||||
|
||||
pack node-style source files from a json stream into a browser bundle
|
||||
|
||||
[](http://travis-ci.org/browserify/browser-pack)
|
||||
|
||||
# example
|
||||
|
||||
json input:
|
||||
|
||||
``` json
|
||||
[
|
||||
{
|
||||
"id": "a1b5af78",
|
||||
"source": "console.log(require('./foo')(5))",
|
||||
"deps": { "./foo": "b8f69fa5" },
|
||||
"entry": true
|
||||
},
|
||||
{
|
||||
"id": "b8f69fa5",
|
||||
"source": "module.exports = function (n) { return n * 111 }",
|
||||
"deps": {}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
bundle script:
|
||||
|
||||
``` js
|
||||
var pack = require('browser-pack')();
|
||||
process.stdin.pipe(pack).pipe(process.stdout);
|
||||
process.stdin.resume();
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
```
|
||||
$ browser-pack < input.json
|
||||
(function(p,c,e){function r(n){if(!c[n]){c[n]={exports:{}};p[n][0](function(x){return r(p[n][1][x])},c[n],c[n].exports);}return c[n].exports}for(var i=0;i<e.length;i++)r(e[i]);return r})({"a1b5af78":[function(require,module,exports){console.log(require('./foo')(5))},{"./foo":"b8f69fa5"}],"b8f69fa5":[function(require,module,exports){module.exports = function (n) { return n * 111 }},{}]},{},["a1b5af78","b8f69fa5"])
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var pack = require('browser-pack');
|
||||
```
|
||||
|
||||
## pack(opts)
|
||||
|
||||
Return a through stream that takes a stream of json input and produces a stream
|
||||
of javascript output. This module does not export its internal `require()`
|
||||
function but you can prepend `'var require='` to the stream contents to get the
|
||||
require function. `require()` will return `undefined` when a module hasn't been
|
||||
defined to support splitting up modules across several bundles with custom
|
||||
fallback logic.
|
||||
|
||||
If `opts.raw` is given, the writable end of the stream will expect objects to be
|
||||
written to it instead of expecting a stream of json text it will need to parse.
|
||||
|
||||
If `opts.sourceMapPrefix` is given and source maps are computed, the
|
||||
`opts.sourceMapPrefix` string will be used instead of `//#`.
|
||||
|
||||
If `opts.sourceRoot` is given and source maps are computed, the root for the
|
||||
output source map will be defined. (default is no root)
|
||||
|
||||
Additionally, rows with a truthy `entry` may have an `order` field that
|
||||
determines the numeric index to execute the entries in.
|
||||
|
||||
You can specify a custom prelude with `opts.prelude` but you should really know
|
||||
what you're doing first. See the `prelude.js` file in this repo for the default
|
||||
prelude. If you specify a custom prelude, you must also specify a valid
|
||||
`opts.preludePath` to the prelude source file for sourcemaps to work.
|
||||
|
||||
`opts.standalone` external string name to use for umd
|
||||
|
||||
`opts.standaloneModule` sets the internal module name to export for standalone
|
||||
|
||||
`opts.hasExports` whether the bundle should include `require=` (or the
|
||||
`opts.externalRequireName`) so that `require()` is available outside the bundle
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org), to get the library do:
|
||||
|
||||
```
|
||||
npm install browser-pack
|
||||
```
|
||||
|
||||
and to get the command-line tool do:
|
||||
|
||||
```
|
||||
npm install -g browser-pack
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
33
node_modules/browser-pack/test/comment.js
generated
vendored
Normal file
33
node_modules/browser-pack/test/comment.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
|
||||
test('trailing comment', function (t) {
|
||||
t.plan(5);
|
||||
|
||||
var p = pack({ raw: true });
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var r = Function(['T'], 'return ' + src)(t);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.throws(function() {
|
||||
r('zzz');
|
||||
}, /Cannot find module 'zzz'/);
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'abc',
|
||||
source: 'T.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' }
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'xyz',
|
||||
source: 'T.ok(true); module.exports=function(n){return n*111}'
|
||||
+ ' // trailing comment'
|
||||
});
|
||||
|
||||
p.end();
|
||||
});
|
33
node_modules/browser-pack/test/empty.js
generated
vendored
Normal file
33
node_modules/browser-pack/test/empty.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
var vm = require('vm');
|
||||
|
||||
test('empty', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var p = pack();
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
t.doesNotThrow(function() {
|
||||
vm.runInNewContext(src, {});
|
||||
});
|
||||
});
|
||||
|
||||
p.end();
|
||||
});
|
||||
|
||||
test('empty with standalone', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var p = pack({standalone: 'ABC'});
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
t.doesNotThrow(function() {
|
||||
vm.runInNewContext(src, {});
|
||||
});
|
||||
});
|
||||
|
||||
p.end();
|
||||
});
|
34
node_modules/browser-pack/test/not_found.js
generated
vendored
Normal file
34
node_modules/browser-pack/test/not_found.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
var concat = require('concat-stream');
|
||||
|
||||
test('not found', function (t) {
|
||||
t.plan(6);
|
||||
|
||||
var p = pack({ raw: true, hasExports: true });
|
||||
var src = '';
|
||||
p.pipe(concat(function (src) {
|
||||
var r = Function(['T'], 'return ' + src)(t);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.throws(function() {
|
||||
r('zzz');
|
||||
}, /Cannot find module 'zzz'/);
|
||||
try { r('zzz') }
|
||||
catch (err) { t.equal(err.code, 'MODULE_NOT_FOUND') }
|
||||
}));
|
||||
|
||||
p.write({
|
||||
id: 'abc',
|
||||
source: 'T.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' }
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'xyz',
|
||||
source: 'T.ok(true); module.exports=function(n){return n*111}'
|
||||
});
|
||||
|
||||
p.end();
|
||||
});
|
26
node_modules/browser-pack/test/only_execute_entries.js
generated
vendored
Normal file
26
node_modules/browser-pack/test/only_execute_entries.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
|
||||
test('raw', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var p = pack({ raw: true });
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var r = Function(['T'], 'return ' + src)(t);
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'abc',
|
||||
source: 'T.ok(true)',
|
||||
entry: true,
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'xyz',
|
||||
source: 'T.fail("non-entry files should not execute")'
|
||||
});
|
||||
|
||||
p.end();
|
||||
});
|
38
node_modules/browser-pack/test/order.js
generated
vendored
Normal file
38
node_modules/browser-pack/test/order.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
|
||||
test('raw', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var p = pack({ raw: true });
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var order = [];
|
||||
var r = Function(['order'], 'return ' + src)(order);
|
||||
t.same(order, [ 'abc', 'def', 'hij' ]);
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'def',
|
||||
order: 1,
|
||||
entry: true,
|
||||
source: 'order.push("def")'
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'hij',
|
||||
entry: true,
|
||||
order: 2,
|
||||
source: 'order.push("hij")'
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'abc',
|
||||
entry: true,
|
||||
order: 0,
|
||||
source: 'order.push("abc")'
|
||||
});
|
||||
|
||||
p.end();
|
||||
});
|
28
node_modules/browser-pack/test/pack.js
generated
vendored
Normal file
28
node_modules/browser-pack/test/pack.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
|
||||
test('pack', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var p = pack();
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var r = Function(['T'], 'return ' + src)(t);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
});
|
||||
|
||||
p.end(JSON.stringify([
|
||||
{
|
||||
id: 'abc',
|
||||
source: 'T.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' }
|
||||
},
|
||||
{
|
||||
id: 'xyz',
|
||||
source: 'T.ok(true); module.exports=function(n){return n*111}'
|
||||
}
|
||||
]));
|
||||
});
|
32
node_modules/browser-pack/test/raw.js
generated
vendored
Normal file
32
node_modules/browser-pack/test/raw.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
|
||||
test('raw', function (t) {
|
||||
t.plan(5);
|
||||
|
||||
var p = pack({ raw: true });
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var r = Function(['T'], 'return ' + src)(t);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.throws(function() {
|
||||
r('zzz');
|
||||
}, /Cannot find module 'zzz'/);
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'abc',
|
||||
source: 'T.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' }
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'xyz',
|
||||
source: 'T.ok(true); module.exports=function(n){return n*111}'
|
||||
});
|
||||
|
||||
p.end();
|
||||
});
|
59
node_modules/browser-pack/test/source-maps-existing.js
generated
vendored
Normal file
59
node_modules/browser-pack/test/source-maps-existing.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
var convert = require('convert-source-map');
|
||||
var parse = require('parse-base64vlq-mappings');
|
||||
|
||||
var foo = {
|
||||
version: 3,
|
||||
file: 'foo.js',
|
||||
sourceRoot: '',
|
||||
sources: [ 'foo.coffee' ],
|
||||
names: [],
|
||||
mappings: ';AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ',
|
||||
sourcesContent: [ 'console.log(require \'./bar.js\')\n' ] };
|
||||
|
||||
test('pack one file with source file field and existing sourcemap', function (t) {
|
||||
t.plan(7);
|
||||
|
||||
var mapComment = convert.fromObject(foo).toComment();
|
||||
var fooMappings = parse(foo.mappings);
|
||||
|
||||
var p = pack();
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
|
||||
var sm = convert.fromSource(src).toObject();
|
||||
var mappings = parse(sm.mappings);
|
||||
|
||||
var remainingMaps = src.match(convert.commentRegex);
|
||||
|
||||
// remove map for _prelude.js
|
||||
mappings.shift();
|
||||
|
||||
var fstMap = mappings[0];
|
||||
var fstFooMap = fooMappings[0];
|
||||
var lstMap = mappings.pop();
|
||||
var lstFooMap = fooMappings.pop();
|
||||
|
||||
t.deepEqual(fstMap.original, fstFooMap.original, 'first original mappings are same');
|
||||
t.deepEqual(lstMap.original, lstFooMap.original, 'last original mappings are same');
|
||||
|
||||
t.equal(fstMap.generated.column, fstFooMap.generated.column, 'first generated columns are same');
|
||||
t.equal(lstMap.generated.column, lstFooMap.generated.column, 'last generated columns are same');
|
||||
|
||||
t.equal(fstMap.generated.line, fstFooMap.generated.line + 1, 'first generated line is offset by 1');
|
||||
t.equal(lstMap.generated.line, lstFooMap.generated.line + 1, 'last generated line is offset by 1');
|
||||
|
||||
t.equal(remainingMaps.length, 1, 'removes orinal source maps');
|
||||
});
|
||||
|
||||
p.end(JSON.stringify([
|
||||
{
|
||||
id: 'xyz',
|
||||
source: '(function() {\n\n console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + mapComment,
|
||||
sourceFile: 'foo.js'
|
||||
}
|
||||
]));
|
||||
});
|
||||
|
221
node_modules/browser-pack/test/source-maps.js
generated
vendored
Normal file
221
node_modules/browser-pack/test/source-maps.js
generated
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
var path = require('path');
|
||||
|
||||
function decode(base64) {
|
||||
return new Buffer(base64, 'base64').toString();
|
||||
}
|
||||
|
||||
function unmountPrelude(sources) {
|
||||
return sources.map(function (x) {
|
||||
var basename = path.basename(x);
|
||||
return basename === '_prelude.js' ? basename : x;
|
||||
});
|
||||
}
|
||||
|
||||
function grabSourceMap(lastLine) {
|
||||
var base64 = lastLine.split(',').pop();
|
||||
var sm = JSON.parse(decode(base64));
|
||||
sm.sources = unmountPrelude(sm.sources);
|
||||
return sm;
|
||||
}
|
||||
|
||||
function grabLastLine(src) {
|
||||
return src.split('\n').slice(-2)[0];
|
||||
}
|
||||
|
||||
test('pack one file with source file field and one without', function (t) {
|
||||
t.plan(7);
|
||||
|
||||
var p = pack();
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var r = Function(['T'], 'return ' + src)(t);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
|
||||
var lastLine = grabLastLine(src);
|
||||
var sm = grabSourceMap(lastLine);
|
||||
|
||||
t.ok(/^\/\/# sourceMappingURL/.test(lastLine), 'contains source mapping url as last line');
|
||||
t.deepEqual(sm.sources, [ '_prelude.js', 'foo.js' ], 'includes mappings for sourceFile and prelude only');
|
||||
t.equal(sm.mappings, 'AAAA;;;ACAA;AACA;AACA;AACA', 'adds offset mapping for each line' );
|
||||
});
|
||||
|
||||
p.end(JSON.stringify([
|
||||
{
|
||||
id: 'abc',
|
||||
source: 'T.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' }
|
||||
},
|
||||
{
|
||||
id: 'xyz',
|
||||
source: 'T.ok(true);\nmodule.exports=function(n){\n return n*111 \n}',
|
||||
sourceFile: 'foo.js'
|
||||
}
|
||||
]));
|
||||
});
|
||||
|
||||
test('pack two files with source file field', function (t) {
|
||||
t.plan(7);
|
||||
|
||||
var p = pack();
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var r = Function(['T'], 'return ' + src)(t);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
|
||||
var lastLine = grabLastLine(src);
|
||||
var sm = grabSourceMap(lastLine);
|
||||
|
||||
t.ok(/^\/\/# sourceMappingURL/.test(lastLine), 'contains source mapping url as last line');
|
||||
t.deepEqual(sm.sources, [ '_prelude.js', 'wunder/bar.js', 'foo.js' ], 'includes mappings for both files and prelude');
|
||||
t.equal(sm.mappings, 'AAAA;ACAA;;ACAA;AACA;AACA;AACA', 'adds offset mapping for each line' );
|
||||
});
|
||||
|
||||
p.end(JSON.stringify([
|
||||
{
|
||||
id: 'abc',
|
||||
source: 'T.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' },
|
||||
sourceFile: 'wunder/bar.js'
|
||||
},
|
||||
{
|
||||
id: 'xyz',
|
||||
source: 'T.ok(true);\nmodule.exports=function(n){\n return n*111 \n}',
|
||||
sourceFile: 'foo.js'
|
||||
}
|
||||
]));
|
||||
});
|
||||
|
||||
test('pack two files without source file field', function (t) {
|
||||
t.plan(5);
|
||||
|
||||
var p = pack();
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var r = Function(['T'], 'return ' + src)(t);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
|
||||
var lastLine = grabLastLine(src);
|
||||
t.notOk(/^\/\/# sourceMappingURL/.test(lastLine), 'contains no source mapping url');
|
||||
});
|
||||
|
||||
p.end(JSON.stringify([
|
||||
{
|
||||
id: 'abc',
|
||||
source: 'T.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' }
|
||||
},
|
||||
{
|
||||
id: 'xyz',
|
||||
source: 'T.ok(true);\nmodule.exports=function(n){\n return n*111 \n}'
|
||||
}
|
||||
]));
|
||||
});
|
||||
|
||||
test('pack two files with source file field, one with nomap flag', function (t) {
|
||||
t.plan(7);
|
||||
|
||||
var p = pack();
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var r = Function(['T'], 'return ' + src)(t);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
|
||||
var lastLine = grabLastLine(src);
|
||||
var sm = grabSourceMap(lastLine);
|
||||
|
||||
t.ok(/^\/\/# sourceMappingURL/.test(lastLine), 'contains source mapping url as last line');
|
||||
t.deepEqual(sm.sources, [ '_prelude.js', 'wunder/bar.js' ], 'includes mappings for only the file without the "nomap" flag and prelude');
|
||||
t.equal(sm.mappings, 'AAAA;ACAA', 'adds offset mapping for each line of mapped file' );
|
||||
t.end()
|
||||
});
|
||||
|
||||
p.end(JSON.stringify([
|
||||
{
|
||||
id: 'abc',
|
||||
source: 'T.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' },
|
||||
sourceFile: 'wunder/bar.js'
|
||||
},
|
||||
{
|
||||
id: 'xyz',
|
||||
source: 'T.ok(true);\nmodule.exports=function(n){\n return n*111 \n}',
|
||||
sourceFile: 'foo.js',
|
||||
nomap: true
|
||||
}
|
||||
]));
|
||||
});
|
||||
|
||||
test('custom sourceMapPrefix for //@', function (t) {
|
||||
t.plan(7);
|
||||
|
||||
var p = pack({ sourceMapPrefix: '//@' });
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var r = Function(['T'], 'return ' + src)(t);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
|
||||
var lastLine = grabLastLine(src);
|
||||
var sm = grabSourceMap(lastLine);
|
||||
|
||||
t.ok(/^\/\/@ sourceMappingURL/.test(lastLine), 'contains source mapping url as last line');
|
||||
t.deepEqual(sm.sources, [ '_prelude.js', 'foo.js' ], 'includes mappings for sourceFile and prelude only');
|
||||
t.equal(sm.mappings, 'AAAA;;;ACAA;AACA;AACA;AACA', 'adds offset mapping for each line' );
|
||||
});
|
||||
|
||||
p.end(JSON.stringify([
|
||||
{
|
||||
id: 'abc',
|
||||
source: 'T.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' }
|
||||
},
|
||||
{
|
||||
id: 'xyz',
|
||||
source: 'T.ok(true);\nmodule.exports=function(n){\n return n*111 \n}',
|
||||
sourceFile: 'foo.js'
|
||||
}
|
||||
]));
|
||||
});
|
||||
|
||||
test('custom sourceRoot', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var p = pack({ sourceRoot: '/custom-root' });
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var lastLine = grabLastLine(src);
|
||||
var sm = grabSourceMap(lastLine);
|
||||
t.equal(sm.sourceRoot, '/custom-root', 'sets a custom source root' );
|
||||
});
|
||||
|
||||
p.end(JSON.stringify([
|
||||
{
|
||||
id: 'abc',
|
||||
source: 'T.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' }
|
||||
},
|
||||
{
|
||||
id: 'xyz',
|
||||
source: 'T.ok(true);\nmodule.exports=function(n){\n return n*111 \n}',
|
||||
sourceFile: 'foo.js'
|
||||
}
|
||||
]));
|
||||
});
|
24
node_modules/browser-pack/test/this.js
generated
vendored
Normal file
24
node_modules/browser-pack/test/this.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* In node.js `this` on the module root is the same as `exports`. Browser-pack
|
||||
* should act like it too.
|
||||
**/
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
|
||||
test('this', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var p = pack();
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf; });
|
||||
p.on('end', function () {
|
||||
var r = Function([], 'return ' + src)();
|
||||
t.deepEqual(r("abc"), { foo: "bar" });
|
||||
});
|
||||
|
||||
p.end(JSON.stringify([{
|
||||
id: 'abc',
|
||||
source: 'this.foo = "bar"'
|
||||
}]));
|
||||
|
||||
});
|
32
node_modules/browser-pack/test/unicode.js
generated
vendored
Normal file
32
node_modules/browser-pack/test/unicode.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
var test = require('tap').test;
|
||||
var pack = require('../');
|
||||
|
||||
test('unicode', function (t) {
|
||||
t.plan(5);
|
||||
|
||||
var p = pack({ raw: true });
|
||||
var src = '';
|
||||
p.on('data', function (buf) { src += buf });
|
||||
p.on('end', function () {
|
||||
var r = Function(['Ṫ'], 'return ' + src)(t);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.equal(r('xyz')(5), 555);
|
||||
t.throws(function() {
|
||||
r('zzz');
|
||||
}, /Cannot find module 'zzz'/);
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'abc',
|
||||
source: 'Ṫ.equal(require("./xyz")(3), 333)',
|
||||
entry: true,
|
||||
deps: { './xyz': 'xyz' }
|
||||
});
|
||||
|
||||
p.write({
|
||||
id: 'xyz',
|
||||
source: 'Ṫ.ok(true); module.exports=function(ñ){return ñ*111}'
|
||||
});
|
||||
|
||||
p.end();
|
||||
});
|
Reference in New Issue
Block a user