mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
refactor: remove gulp from the build
Plain npm scripts should be sufficient for our use case.
This commit is contained in:
20
Makefile
20
Makefile
@@ -1,20 +0,0 @@
|
||||
|
||||
help: ## print this message
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
build: ## update the browser builds
|
||||
@./node_modules/.bin/gulp build
|
||||
|
||||
test: ## run tests either in the browser or in Node.js, based on the `BROWSERS` variable
|
||||
@./node_modules/.bin/gulp test
|
||||
|
||||
test-node: ## run tests in Node.js
|
||||
@./node_modules/.bin/gulp test-node
|
||||
|
||||
test-zuul: ## run tests in the browser
|
||||
@./node_modules/.bin/gulp test-zuul
|
||||
|
||||
test-cov: ## run tests with coverage in Node.js
|
||||
@./node_modules/.bin/gulp test-cov
|
||||
|
||||
.PHONY: help test test-node test-zuul test-cov
|
||||
577
dist/socket.io.js
vendored
577
dist/socket.io.js
vendored
File diff suppressed because one or more lines are too long
8
dist/socket.io.min.js
vendored
Normal file
8
dist/socket.io.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
110
gulpfile.js
110
gulpfile.js
@@ -1,110 +0,0 @@
|
||||
const gulp = require('gulp');
|
||||
const mocha = require('gulp-mocha');
|
||||
const istanbul = require('gulp-istanbul');
|
||||
const webpack = require('webpack-stream');
|
||||
const child = require('child_process');
|
||||
const help = require('gulp-task-listing');
|
||||
const eslint = require('gulp-eslint');
|
||||
|
||||
gulp.task('help', help);
|
||||
|
||||
gulp.task('default', ['build']);
|
||||
|
||||
// //////////////////////////////////////
|
||||
// BUILDING
|
||||
// //////////////////////////////////////
|
||||
|
||||
const BUILD_TARGET_DIR = './dist/';
|
||||
|
||||
gulp.task('build', function () {
|
||||
return gulp.src('lib/*.js')
|
||||
.pipe(webpack({
|
||||
config: [
|
||||
require('./support/webpack.config.js'),
|
||||
require('./support/webpack.config.dev.js'),
|
||||
require('./support/webpack.config.slim.js'),
|
||||
require('./support/webpack.config.slim.dev.js')
|
||||
]
|
||||
}))
|
||||
.pipe(gulp.dest(BUILD_TARGET_DIR));
|
||||
});
|
||||
|
||||
// //////////////////////////////////////
|
||||
// TESTING
|
||||
// //////////////////////////////////////
|
||||
|
||||
const REPORTER = 'dot';
|
||||
const TEST_FILE = './test/index.js';
|
||||
const TEST_SUPPORT_SERVER_FILE = './test/support/server.js';
|
||||
|
||||
gulp.task('test', ['lint'], function () {
|
||||
if (process.env.hasOwnProperty('BROWSERS')) {
|
||||
return testZuul();
|
||||
} else {
|
||||
return testNode();
|
||||
}
|
||||
});
|
||||
|
||||
gulp.task('test-node', testNode);
|
||||
gulp.task('test-zuul', testZuul);
|
||||
|
||||
gulp.task('lint', function () {
|
||||
return gulp.src([
|
||||
'*.js',
|
||||
'lib/**/*.js',
|
||||
'test/**/*.js',
|
||||
'support/**/*.js'
|
||||
])
|
||||
.pipe(eslint())
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError());
|
||||
});
|
||||
|
||||
// runs zuul through shell process
|
||||
function testZuul () {
|
||||
const ZUUL_CMD = './node_modules/zuul/bin/zuul';
|
||||
const zuulChild = child.spawn(ZUUL_CMD, [TEST_FILE], { stdio: 'inherit' });
|
||||
zuulChild.on('exit', function (code) { process.exit(code); });
|
||||
return zuulChild;
|
||||
}
|
||||
|
||||
function testNode () {
|
||||
const MOCHA_OPTS = {
|
||||
reporter: REPORTER,
|
||||
require: [TEST_SUPPORT_SERVER_FILE],
|
||||
bail: true
|
||||
};
|
||||
return gulp.src(TEST_FILE, { read: false })
|
||||
.pipe(mocha(MOCHA_OPTS))
|
||||
// following lines to fix gulp-mocha not terminating (see gulp-mocha webpage)
|
||||
.once('error', function (err) {
|
||||
console.error(err.stack);
|
||||
process.exit(1);
|
||||
})
|
||||
.once('end', function () {
|
||||
process.exit();
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task('istanbul-pre-test', function () {
|
||||
return gulp.src(['lib/**/*.js'])
|
||||
// Covering files
|
||||
.pipe(istanbul())
|
||||
// Force `require` to return covered files
|
||||
.pipe(istanbul.hookRequire());
|
||||
});
|
||||
|
||||
gulp.task('test-cov', ['istanbul-pre-test'], function () {
|
||||
gulp.src(['test/*.js', 'test/support/*.js'])
|
||||
.pipe(mocha({
|
||||
reporter: REPORTER
|
||||
}))
|
||||
.pipe(istanbul.writeReports())
|
||||
.once('error', function (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
})
|
||||
.once('end', function () {
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
7107
package-lock.json
generated
7107
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
29
package.json
29
package.json
@@ -28,38 +28,35 @@
|
||||
"to-array": "0.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.24.1",
|
||||
"babel-eslint": "4.1.7",
|
||||
"babel-loader": "7.0.0",
|
||||
"@babel/core": "^7.11.6",
|
||||
"@babel/plugin-transform-object-assign": "^7.10.4",
|
||||
"@babel/preset-env": "^7.11.5",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-loader": "^8.1.0",
|
||||
"babel-preset-es2015": "6.24.1",
|
||||
"base64-arraybuffer": "^0.1.5",
|
||||
"concat-stream": "^1.6.0",
|
||||
"derequire": "^2.0.6",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-standard": "4.4.0",
|
||||
"eslint-plugin-standard": "1.3.1",
|
||||
"expect.js": "0.3.1",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-eslint": "1.1.1",
|
||||
"gulp-file": "^0.3.0",
|
||||
"gulp-istanbul": "^1.1.1",
|
||||
"gulp-mocha": "^4.3.1",
|
||||
"gulp-task-listing": "1.0.1",
|
||||
"has-cors": "^1.1.0",
|
||||
"imports-loader": "^0.7.1",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.3.0",
|
||||
"socket.io": "2.3.0",
|
||||
"socket.io-browsers": "^1.0.0",
|
||||
"strip-loader": "0.1.2",
|
||||
"text-blob-builder": "0.0.1",
|
||||
"webpack-merge": "4.1.2",
|
||||
"webpack-stream": "3.2.0",
|
||||
"webpack": "^4.44.2",
|
||||
"webpack-cli": "^3.3.12",
|
||||
"webpack-remove-debug": "^0.1.0",
|
||||
"zuul": "~3.11.1",
|
||||
"zuul-builder-webpack": "^1.2.0",
|
||||
"zuul-ngrok": "4.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "gulp test"
|
||||
"test": "if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi",
|
||||
"test:node": "mocha --reporter dot --require test/support/server.js test/index.js",
|
||||
"test:browser": "zuul test/index.js",
|
||||
"build": "webpack --config ./support/webpack.config.js --config ./support/prod.config.js"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
module.exports = function () { return function () {}; };
|
||||
19
support/prod.config.js
Normal file
19
support/prod.config.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const config = require("./webpack.config");
|
||||
|
||||
module.exports = {
|
||||
...config,
|
||||
output: {
|
||||
...config.output,
|
||||
filename: "socket.io.min.js"
|
||||
},
|
||||
mode: "production",
|
||||
module: {
|
||||
rules: [
|
||||
...config.module.rules,
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: "webpack-remove-debug"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
module.exports = {
|
||||
name: 'default',
|
||||
entry: './lib/index.js',
|
||||
output: {
|
||||
library: 'io',
|
||||
libraryTarget: 'umd',
|
||||
filename: 'socket.io.dev.js'
|
||||
},
|
||||
externals: {
|
||||
global: glob()
|
||||
},
|
||||
node: {
|
||||
Buffer: false
|
||||
},
|
||||
devtool: 'source-map',
|
||||
module: {
|
||||
loaders: [{
|
||||
test: /\.js$/,
|
||||
include: /debug/,
|
||||
loader: 'babel-loader',
|
||||
query: { presets: ['es2015'] }
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Populates `global`.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function glob () {
|
||||
return 'typeof self !== "undefined" ? self : ' +
|
||||
'typeof window !== "undefined" ? window : ' +
|
||||
'typeof global !== "undefined" ? global : {}';
|
||||
}
|
||||
@@ -1,25 +1,46 @@
|
||||
var webpack = require('webpack');
|
||||
var merge = require('webpack-merge');
|
||||
var baseConfig = require('./webpack.config.dev.js');
|
||||
const { BannerPlugin } = require("webpack");
|
||||
const version = require("../package.json").version;
|
||||
|
||||
module.exports = merge(baseConfig, {
|
||||
const banner = `Socket.IO v${version}
|
||||
(c) 2014-${new Date().getFullYear()} Guillermo Rauch
|
||||
Released under the MIT License.`;
|
||||
|
||||
module.exports = {
|
||||
entry: "./lib/index.js",
|
||||
output: {
|
||||
library: 'io',
|
||||
libraryTarget: 'umd',
|
||||
filename: 'socket.io.js'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
screw_ie8: false
|
||||
},
|
||||
mangle: {
|
||||
screw_ie8: false
|
||||
},
|
||||
output: {
|
||||
screw_ie8: false,
|
||||
beautify: false
|
||||
filename: "socket.io.js",
|
||||
library: "io",
|
||||
libraryTarget: "umd",
|
||||
// see https://github.com/webpack/webpack/issues/6525
|
||||
globalObject: `(() => {
|
||||
if (typeof self !== 'undefined') {
|
||||
return self;
|
||||
} else if (typeof window !== 'undefined') {
|
||||
return window;
|
||||
} else if (typeof global !== 'undefined') {
|
||||
return global;
|
||||
} else {
|
||||
return Function('return this')();
|
||||
}
|
||||
})
|
||||
]
|
||||
});
|
||||
})()`
|
||||
},
|
||||
mode: "development",
|
||||
node: {
|
||||
Buffer: false
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.m?js$/,
|
||||
use: {
|
||||
loader: "babel-loader",
|
||||
options: {
|
||||
presets: ["@babel/preset-env"],
|
||||
plugins: ["@babel/plugin-transform-object-assign"]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [new BannerPlugin(banner)]
|
||||
};
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
|
||||
var webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
name: 'slim',
|
||||
entry: './lib/index.js',
|
||||
output: {
|
||||
library: 'io',
|
||||
libraryTarget: 'umd',
|
||||
filename: 'socket.io.slim.dev.js'
|
||||
},
|
||||
externals: {
|
||||
global: glob()
|
||||
},
|
||||
node: {
|
||||
Buffer: false
|
||||
},
|
||||
devtool: 'source-map',
|
||||
plugins: [
|
||||
new webpack.NormalModuleReplacementPlugin(/debug/, process.cwd() + '/support/noop.js')
|
||||
],
|
||||
module: {
|
||||
loaders: [{
|
||||
test: /\.js$/,
|
||||
exclude: /(node_modules|bower_components)/,
|
||||
loader: 'babel-loader',
|
||||
query: { presets: ['es2015'] }
|
||||
}, {
|
||||
test: /\.js$/,
|
||||
loader: 'strip-loader?strip[]=debug'
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Populates `global`.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function glob () {
|
||||
return 'typeof self !== "undefined" ? self : ' +
|
||||
'typeof window !== "undefined" ? window : ' +
|
||||
'typeof global !== "undefined" ? global : {}';
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
var webpack = require('webpack');
|
||||
var merge = require('webpack-merge');
|
||||
var baseConfig = require('./webpack.config.slim.dev.js');
|
||||
|
||||
module.exports = merge(baseConfig, {
|
||||
output: {
|
||||
library: 'io',
|
||||
libraryTarget: 'umd',
|
||||
filename: 'socket.io.slim.js'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.optimize.UglifyJsPlugin()
|
||||
]
|
||||
});
|
||||
@@ -18,7 +18,7 @@ var zuulConfig = module.exports = {
|
||||
|
||||
server: './test/support/server.js',
|
||||
builder: 'zuul-builder-webpack',
|
||||
webpack: require('./support/webpack.config.dev.js')
|
||||
webpack: require('./support/prod.config.js')
|
||||
};
|
||||
|
||||
if (process.env.CI === 'true') {
|
||||
|
||||
Reference in New Issue
Block a user