Browse Source

Webpack: use library option

master
Futago-za Ryuu 2 years ago
parent
commit
f7a52c70a4
  1. 2
      docs/.vuepress/public/benchmark-bundle.min.js
  2. 2
      docs/.vuepress/public/test-bundle.min.js
  3. 7
      tools/bundler/target.js
  4. 3
      webpack.config.js

2
docs/.vuepress/public/benchmark-bundle.min.js
File diff suppressed because it is too large
View File

2
docs/.vuepress/public/test-bundle.min.js

@ -1,4 +1,4 @@
!function(l,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e=n();for(var u in e)("object"==typeof exports?exports:l)[u]=e[u]}}("undefined"!=typeof self?self:window,function(){return function(l){var n={};function e(u){if(n[u])return n[u].exports;var t=n[u]={i:u,l:!1,exports:{}};return l[u].call(t.exports,t,t.exports,e),t.l=!0,t.exports}return e.m=l,e.c=n,e.d=function(l,n,u){e.o(l,n)||Object.defineProperty(l,n,{enumerable:!0,get:u})},e.r=function(l){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(l,"__esModule",{value:!0})},e.t=function(l,n){if(1&n&&(l=e(l)),8&n)return l;if(4&n&&"object"==typeof l&&l&&l.__esModule)return l;var u=Object.create(null);if(e.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:l}),2&n&&"string"!=typeof l)for(var t in l)e.d(u,t,function(n){return l[n]}.bind(null,t));return u},e.n=function(l){var n=l&&l.__esModule?function(){return l.default}:function(){return l};return e.d(n,"a",n),n},e.o=function(l,n){return Object.prototype.hasOwnProperty.call(l,n)},e.p="",e(e.s=51)}([function(l,n,e){"use strict";var u=e(9),t=e(5),r=e(23),o=e(14),a=e(1),i={VERSION:e(13).version,GrammarError:u,ast:t,parser:o,compiler:r,util:a,generate:function(l){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=new r.Session({passes:a.convertPasses(r.passes)});return Array.isArray(n.plugins)&&n.plugins.forEach(function(l){"function"==typeof l.use&&l.use(e,n)}),r.compile(e.parse(l,n.parser||{}),e,n)}};l.exports=i},function(l,n,e){"use strict";var u=e(19),t=e(20),r=e(21),o=e(11),a=function(){function l(l){return Array.isArray(l)?l:r.values(l)}return function(n){return r.map(n,l)}}();l.exports={find:u.find,findIndex:u.findIndex,stringEscape:t.stringEscape,regexpEscape:t.regexpEscape,reservedWords:t.reservedWords,clone:r.clone,each:r.each,extend:r.extend,map:r.map,values:r.values,enforceFastProperties:r.enforceFastProperties,evalModule:o.evalModule,convertPasses:a,processOptions:function(l,n){var e={};return r.extend(e,l),r.extend(e,n),e},noop:function(){}}},function(l,n,e){l.exports=e(6)},function(l,n){
!function(l,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("test",[],n):"object"==typeof exports?exports.test=n():(l.peg=l.peg||{},l.peg.test=n())}("undefined"!=typeof self?self:window,function(){return function(l){var n={};function e(u){if(n[u])return n[u].exports;var t=n[u]={i:u,l:!1,exports:{}};return l[u].call(t.exports,t,t.exports,e),t.l=!0,t.exports}return e.m=l,e.c=n,e.d=function(l,n,u){e.o(l,n)||Object.defineProperty(l,n,{enumerable:!0,get:u})},e.r=function(l){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(l,"__esModule",{value:!0})},e.t=function(l,n){if(1&n&&(l=e(l)),8&n)return l;if(4&n&&"object"==typeof l&&l&&l.__esModule)return l;var u=Object.create(null);if(e.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:l}),2&n&&"string"!=typeof l)for(var t in l)e.d(u,t,function(n){return l[n]}.bind(null,t));return u},e.n=function(l){var n=l&&l.__esModule?function(){return l.default}:function(){return l};return e.d(n,"a",n),n},e.o=function(l,n){return Object.prototype.hasOwnProperty.call(l,n)},e.p="",e(e.s=51)}([function(l,n,e){"use strict";var u=e(9),t=e(5),r=e(23),o=e(14),a=e(1),i={VERSION:e(13).version,GrammarError:u,ast:t,parser:o,compiler:r,util:a,generate:function(l){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=new r.Session({passes:a.convertPasses(r.passes)});return Array.isArray(n.plugins)&&n.plugins.forEach(function(l){"function"==typeof l.use&&l.use(e,n)}),r.compile(e.parse(l,n.parser||{}),e,n)}};l.exports=i},function(l,n,e){"use strict";var u=e(19),t=e(20),r=e(21),o=e(11),a=function(){function l(l){return Array.isArray(l)?l:r.values(l)}return function(n){return r.map(n,l)}}();l.exports={find:u.find,findIndex:u.findIndex,stringEscape:t.stringEscape,regexpEscape:t.regexpEscape,reservedWords:t.reservedWords,clone:r.clone,each:r.each,extend:r.extend,map:r.map,values:r.values,enforceFastProperties:r.enforceFastProperties,evalModule:o.evalModule,convertPasses:a,processOptions:function(l,n){var e={};return r.extend(e,l),r.extend(e,n),e},noop:function(){}}},function(l,n,e){l.exports=e(6)},function(l,n){
/*!
* Chai - flag utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>

7
tools/bundler/target.js

@ -27,13 +27,11 @@ const HEADER = dedent`
* @param {{ entry: string|{}, output: string }} param0
*/
function target( { entry, output } ) {
if ( typeof entry !== "object" ) entry = [ entry ];
function target( { entry, library, output } ) {
const cwd = process.cwd();
Object
if ( typeof entry === "object" ) Object
.keys( entry )
.forEach( name => {
@ -54,6 +52,7 @@ function target( { entry, output } ) {
output: {
path: path.dirname( path.resolve( cwd, output ) ),
filename: path.basename( output ),
library: library,
libraryTarget: "umd",
umdNamedDefine: true,
sourcePrefix: " ",

3
webpack.config.js

@ -8,6 +8,7 @@ module.exports = [
target( {
entry: require.resolve( "pegjs" ),
library: "peg",
output: "packages/pegjs/dist/peg.js",
} ),
@ -16,6 +17,7 @@ module.exports = [
target( {
entry: require.resolve( "pegjs" ),
library: "peg",
output: "packages/pegjs/dist/peg.min.js",
} ),
@ -27,6 +29,7 @@ module.exports = [
"benchmark": require.resolve( "@pegjs/benchmark-suite/browser.js" ),
"test": "test/**/*.+(spec|test).js",
},
library: [ "peg", "[name]" ],
output: "docs/.vuepress/public/[name]-bundle.min.js",
} ),

Loading…
Cancel
Save