Skip to content

Commit

Permalink
Merge pull request IdentityModel#913 from legaev-stas/lib-version-of-…
Browse files Browse the repository at this point in the history
…rsa256

lib version of rsa256 js bundle was added
  • Loading branch information
brockallen authored Aug 7, 2019
2 parents 2b31a04 + 1ad5b4a commit 7abedbc
Showing 1 changed file with 78 additions and 41 deletions.
119 changes: 78 additions & 41 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ var UglifyJsPlugin = require('uglifyjs-webpack-plugin');
var npmEntry ='./index.js';
var classicEntry = ['babel-polyfill', npmEntry];

const optimization = {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
compress: {
keep_fnames: true
}
}
})
]
};

const swapCryptoWithRSAImpl = new webpack.NormalModuleReplacementPlugin(
/(.*)JoseUtil(\.js)?$/,
(resource) => {
resource.request = resource.request.replace(/JoseUtil/, 'JoseUtilRsa');
}
)

// npm compliant build with source-maps
function build_lib_sourcemap(){
// run webpack
Expand All @@ -30,9 +49,27 @@ function build_lib_sourcemap(){
.pipe(gulp.dest('lib/'));
}

// npm compliant build with source-maps
function build_lib_rsa_sourcemap(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'development',
entry: npmEntry,
output: {
filename:'oidc-client.rsa256.js',
libraryTarget:'umd',
// Workaround for https://github.com/webpack/webpack/issues/6642
globalObject: 'this'
},
plugins: [swapCryptoWithRSAImpl],
devtool:'inline-source-map'
}), webpack))
.pipe(gulp.dest('lib/'));
}

// npm compliant build without source-maps & minified
function build_lib_min(){
// run webpack
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'production',
entry: npmEntry,
Expand All @@ -44,15 +81,26 @@ function build_lib_min(){
},
plugins: [],
devtool: false,
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
keep_fnames: true
}
})
]
}
optimization
}), webpack))
.pipe(gulp.dest('lib/'));
}

// npm compliant build without source-maps & minified
function build_lib_rsa_min(){
// run webpack
return gulp.src('index.js').pipe(webpackStream(createWebpackConfig({
mode: 'production',
entry: npmEntry,
output: {
filename:'oidc-client.rsa256.min.js',
libraryTarget:'umd',
// Workaround for https://github.com/webpack/webpack/issues/6642
globalObject: 'this'
},
plugins: [swapCryptoWithRSAImpl],
devtool: false,
optimization
}), webpack))
.pipe(gulp.dest('lib/'));
}
Expand Down Expand Up @@ -87,15 +135,7 @@ function build_dist_min(){
},
plugins: [],
devtool: false,
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
keep_fnames: true
}
})
]
}
optimization
}), webpack))
.pipe(gulp.dest('dist/'));
}
Expand Down Expand Up @@ -186,17 +226,7 @@ function slimBuildTarget() {
library: 'Oidc'
},
plugins: [],
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
compress: {
keep_fnames: true
}
}
})
]
}
optimization
};
}
function slimBuildTargetSourceMap() {
Expand Down Expand Up @@ -233,11 +263,7 @@ function build_dist_slim_rsa() {
conf.output.filename = 'oidc-client.rsa256.slim.min.js';

// This plugin should always be first in the chain
conf.plugins.unshift(
new webpack.NormalModuleReplacementPlugin(/(.*)JoseUtil(\.js)?$/, (resource) => {
resource.request = resource.request.replace(/JoseUtil/, 'JoseUtilRsa');
})
);
conf.plugins.unshift(swapCryptoWithRSAImpl);

return gulp.src('index.js')
.pipe(webpackStream(createWebpackConfig(conf), webpack))
Expand All @@ -248,11 +274,7 @@ function build_dist_slim_rsa_sourcemap() {
conf.output.filename = 'oidc-client.rsa256.slim.js';

// This plugin should always be first in the chain
conf.plugins.unshift(
new webpack.NormalModuleReplacementPlugin(/(.*)JoseUtil(\.js)?$/, (resource) => {
resource.request = resource.request.replace(/JoseUtil/, 'JoseUtilRsa');
})
);
conf.plugins.unshift(swapCryptoWithRSAImpl);

return gulp.src('index.js')
.pipe(webpackStream(createWebpackConfig(conf), webpack))
Expand All @@ -263,6 +285,21 @@ function build_dist_slim_rsa_sourcemap() {
exports.default = gulp.series(
add_version,
build_jsrsasign,
gulp.parallel(build_lib_sourcemap, build_lib_min, build_dist_sourcemap, build_dist_min, build_dist_slim, build_dist_slim_rsa, build_dist_slim_sourcemap, build_dist_slim_rsa_sourcemap),
gulp.parallel(
build_lib_sourcemap,
build_lib_min,

build_lib_rsa_sourcemap,
build_lib_rsa_min,

build_dist_sourcemap,
build_dist_min,

build_dist_slim_sourcemap,
build_dist_slim,

build_dist_slim_rsa_sourcemap,
build_dist_slim_rsa
),
copy_ts
);

0 comments on commit 7abedbc

Please sign in to comment.