Smaller bundle size by removing esprima dep from bundle

This commit is contained in:
Roman Hotsiy 2016-09-02 23:24:51 +03:00
parent a14bde334b
commit 52c2233534
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
7 changed files with 93 additions and 39 deletions

View File

@ -12,13 +12,9 @@ module.exports = {
debug: false, debug: false,
resolve: { resolve: {
extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'], extensions: ['', '.ts', '.js', '.json', '.css'],
root: root('lib'), root: root('lib'),
descriptionFiles: ['package.json'], modulesDirectories: ['node_modules'],
modules: [
'node_modules',
root('lib')
],
alias: { alias: {
'./lib/bootstrap': root('lib/bootstrap.dev'), './lib/bootstrap': root('lib/bootstrap.dev'),
http: 'stream-http', http: 'stream-http',
@ -26,10 +22,17 @@ module.exports = {
} }
}, },
externals: { externals: {
"jquery": "jQuery" "jquery": "jQuery",
'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc
}, },
node: { node: {
fs: "empty" fs: "empty",
crypto: "empty",
global: "window",
process: true,
module: false,
clearImmediate: false,
setImmediate: false
}, },
entry: { entry: {
'redoc': './lib/index.ts', 'redoc': './lib/index.ts',
@ -57,7 +60,10 @@ module.exports = {
module: { module: {
preLoaders: [{ preLoaders: [{
test: /\.js$/, test: /\.js$/,
loader: 'source-map' loader: 'source-map-loader',
exclude: [
/node_modules/
]
}], }],
loaders: [{ loaders: [{
test: /\.ts$/, test: /\.ts$/,

View File

@ -12,26 +12,29 @@ const BANNER =
module.exports = { module.exports = {
context: root(), context: root(),
devtool: 'cheap-module-source-map', devtool: 'source-map',
resolve: { resolve: {
extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'], extensions: ['', '.ts', '.js', '.json', '.css'],
root: root('lib'), root: root('lib'),
descriptionFiles: ['package.json'], modulesDirectories: ['node_modules'],
modules: [
'node_modules',
root('lib')
],
alias: { alias: {
http: 'stream-http', http: 'stream-http',
https: 'stream-http' https: 'stream-http'
} }
}, },
externals: { externals: {
"jquery": "jQuery" 'jquery': 'jQuery',
'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc
}, },
node: { node: {
fs: "empty" fs: "empty",
crypto: "empty",
global: "window",
process: true,
module: false,
clearImmediate: false,
setImmediate: false
}, },
entry: { entry: {
'redoc': ['./lib/polyfills.ts', './lib/vendor.ts', './lib/index.ts'] 'redoc': ['./lib/polyfills.ts', './lib/vendor.ts', './lib/index.ts']
@ -49,7 +52,10 @@ module.exports = {
module: { module: {
preLoaders: [{ preLoaders: [{
test: /\.js$/, test: /\.js$/,
loader: 'source-map' loader: 'source-map-loader',
exclude: [
/node_modules/
]
}], }],
loaders: [{ loaders: [{
test: /\.ts$/, test: /\.ts$/,

View File

@ -8,13 +8,9 @@ module.exports = {
devtool: 'inline-source-map', devtool: 'inline-source-map',
resolve: { resolve: {
extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'], extensions: ['', '.ts', '.js', '.json', '.css'],
root: root('lib'), root: root('lib'),
descriptionFiles: ['package.json'], modulesDirectories: ['node_modules'],
modules: [
'node_modules',
root('lib'),
],
alias: { alias: {
'./lib/bootstrap': root('lib/bootstrap.dev'), './lib/bootstrap': root('lib/bootstrap.dev'),
http: 'stream-http', http: 'stream-http',
@ -22,10 +18,17 @@ module.exports = {
} }
}, },
externals: { externals: {
"jquery": "jQuery" "jquery": "jQuery",
'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc
}, },
node: { node: {
fs: "empty" fs: "empty",
crypto: "empty",
global: "window",
process: true,
module: false,
clearImmediate: false,
setImmediate: false
}, },
output: { output: {
@ -38,7 +41,10 @@ module.exports = {
module: { module: {
preLoaders: [{ preLoaders: [{
test: /\.js$/, test: /\.js$/,
loader: 'source-map' loader: 'source-map-loader',
exclude: [
/node_modules/
]
}], }],
loaders: [ { loaders: [ {
test: /\.ts$/, test: /\.ts$/,

View File

@ -1,4 +1,30 @@
import 'core-js/es6'; import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'core-js/es6/weak-map';
import 'core-js/es6/weak-set';
import 'core-js/es6/typed';
import 'core-js/es6/reflect';
// see issue https://github.com/AngularClass/angular2-webpack-starter/issues/709
// import 'core-js/es6/promise';
import 'core-js/es7/reflect'; import 'core-js/es7/reflect';
import 'ts-helpers';
import 'zone.js/dist/zone'; import 'zone.js/dist/zone';
// Typescript emit helpers polyfill
import 'ts-helpers';
if (!IS_PRODUCTION) {
Error.stackTraceLimit = Infinity;
require('zone.js/dist/long-stack-trace-zone');
}

View File

@ -23,9 +23,12 @@ import 'dropkickjs/build/css/dropkick.css';
import 'prismjs/themes/prism-dark.css'; import 'prismjs/themes/prism-dark.css';
import 'hint.css/hint.base.css'; import 'hint.css/hint.base.css';
import '@angular/common'; if (!IS_PRODUCTION) {
import '@angular/core'; require('@angular/platform-browser');
import '@angular/platform-browser'; require('@angular/platform-browser-dynamic');
require('@angular/core');
require('@angular/common');
// RxJS // RxJS
import 'rxjs/Rx'; require('rxjs/Rx');
}

View File

@ -14,3 +14,8 @@ declare module "*.css" {
declare var LIB_VERSION: any; declare var LIB_VERSION: any;
declare var IS_PRODUCTION: any; declare var IS_PRODUCTION: any;
interface ErrorStackTraceLimit {
stackTraceLimit: number;
}
interface ErrorConstructor extends ErrorStackTraceLimit {}

View File

@ -2,11 +2,11 @@
"compilerOptions": { "compilerOptions": {
"experimentalDecorators": true, "experimentalDecorators": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"module": "es6", "module": "commonjs",
"target": "es5", "target": "es5",
"noImplicitAny": false, "noImplicitAny": false,
"sourceMap": true, "sourceMap": true,
"outDir": ".tmp/lib", "outDir": ".tmp",
"pretty": true, "pretty": true,
"moduleResolution": "node", "moduleResolution": "node",
"types": [ "types": [
@ -21,10 +21,12 @@
"exclude": [ "exclude": [
"node_modules", "node_modules",
".tmp" ".tmp",
"dist"
], ],
"awesomeTypescriptLoaderOptions": { "awesomeTypescriptLoaderOptions": {
"resolveGlobs": true, "resolveGlobs": true,
"forkChecker": true "forkChecker": true,
"useWebpackText": true
} }
} }