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

View File

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

View File

@ -8,13 +8,9 @@ module.exports = {
devtool: 'inline-source-map',
resolve: {
extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'],
extensions: ['', '.ts', '.js', '.json', '.css'],
root: root('lib'),
descriptionFiles: ['package.json'],
modules: [
'node_modules',
root('lib'),
],
modulesDirectories: ['node_modules'],
alias: {
'./lib/bootstrap': root('lib/bootstrap.dev'),
http: 'stream-http',
@ -22,10 +18,17 @@ module.exports = {
}
},
externals: {
"jquery": "jQuery"
"jquery": "jQuery",
'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc
},
node: {
fs: "empty"
fs: "empty",
crypto: "empty",
global: "window",
process: true,
module: false,
clearImmediate: false,
setImmediate: false
},
output: {
@ -38,7 +41,10 @@ module.exports = {
module: {
preLoaders: [{
test: /\.js$/,
loader: 'source-map'
loader: 'source-map-loader',
exclude: [
/node_modules/
]
}],
loaders: [ {
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 'ts-helpers';
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 'hint.css/hint.base.css';
import '@angular/common';
import '@angular/core';
import '@angular/platform-browser';
if (!IS_PRODUCTION) {
require('@angular/platform-browser');
require('@angular/platform-browser-dynamic');
require('@angular/core');
require('@angular/common');
// RxJS
import 'rxjs/Rx';
require('rxjs/Rx');
}

View File

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

View File

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