Skip to content

Commit

Permalink
Merge remote-tracking branch 'fork-origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kusapan committed Feb 28, 2019
2 parents f3bf739 + bc9faeb commit 4aabe19
Show file tree
Hide file tree
Showing 402 changed files with 23,900 additions and 10,288 deletions.
19 changes: 0 additions & 19 deletions .babelrc

This file was deleted.

34 changes: 34 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

let path = require('path');

function useLocal(module) {
return require.resolve(module, {
paths: [
__dirname
]
})
}

module.exports = {
"presets": [
[
useLocal('@babel/preset-env'),
{
"targets": {
"browsers": [
"chrome >= 61",
"safari >=8",
"edge >= 14",
"ff >= 57",
"ie >= 10",
"ios >= 8"
]
}
}
]
],
"plugins": [
path.resolve(__dirname, './plugins/pbjsGlobals.js'),
useLocal('babel-plugin-transform-object-assign')
]
};
87 changes: 85 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,94 @@ Working examples can be found in [the developer docs](http://prebid.org/dev-docs

**Table of Contents**

- [Usage](#Usage)
- [Install](#Install)
- [Build](#Build)
- [Run](#Run)
- [Contribute](#Contribute)

<a name="Usage"></a>

## Usage (as a npm dependency)

*Note:* Requires Prebid.js v1.38.0+

Prebid.js depends on Babel and some Babel Plugins in order to run correctly in the browser. Here are some examples for
configuring webpack to work with Prebid.js.

With Babel 7:
```javascript
// webpack.conf.js
let path = require('path');
module.exports = {
mode: 'production',
module: {
rules: [

// this rule can be excluded if you don't require babel-loader for your other application files
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
}
},

// this separate rule is required to make sure that the Prebid.js files are babel-ified. this rule will
// override the regular exclusion from above (for being inside node_modules).
{
test: /.js$/,
include: new RegExp(`\\${path.sep}prebid\.js`),
use: {
loader: 'babel-loader',
// presets and plugins for Prebid.js must be manually specified separate from your other babel rule.
// this can be accomplished by requiring prebid's .babelrc.js file (requires Babel 7 and Node v8.9.0+)
options: require('prebid.js/.babelrc.js')
}
}
]
}
}
```

Or for Babel 6 and/or Node v8.6.0 and less:
```javascript
// you must manually install and specify the presets and plugins yourself
options: {
plugins: [
"transform-object-assign", // required (for IE support) and "babel-plugin-transform-object-assign"
// must be installed as part of your package.
require('prebid.js/plugins/pbjsGlobals.js') // required!
],
presets: [
["env", { // you can use other presets if you wish.
"targets": { // this example is using "babel-presets-env", which must be installed if you
"browsers": [ // follow this example.
... // your browser targets. they should probably match the targets you're using for the rest
// of your application
]
}
}]
]
}
```

Then you can use Prebid.js as any other npm depedendency

```javascript
import prebid from 'prebid.js';
import 'prebid.js/modules/rubiconBidAdapter'; // imported modules will register themselves automatically with prebid
import 'prebid.js/modules/appnexusBidAdapter';
prebid.processQueue(); // required to process existing pbjs.queue blocks and setup any further pbjs.queue execution

prebid.requestBids({
...
})

```



<a name="Install"></a>

## Install
Expand All @@ -29,7 +112,7 @@ Working examples can be found in [the developer docs](http://prebid.org/dev-docs
$ cd Prebid.js
$ npm install

*Note:* You need to have `NodeJS` 4.x or greater installed.
*Note:* You need to have `NodeJS` 6.x or greater installed.

*Note:* In the 1.24.0 release of Prebid.js we have transitioned to using gulp 4.0 from using gulp 3.9.1. To compily with gulp's recommended setup for 4.0, you'll need to have `gulp-cli` installed globally prior to running the general `npm install`. This shouldn't impact any other projects you may work on that use an earlier version of gulp in it's setup.

Expand Down Expand Up @@ -217,7 +300,7 @@ For instructions on writing tests for Prebid.js, see [Testing Prebid.js](http://

### Supported Browsers

Prebid.js is supported on IE10+ and modern browsers.
Prebid.js is supported on IE11 and modern browsers.

### Governance
Review our governance model [here](https://github.com/prebid/Prebid.js/tree/master/governance.md).
4 changes: 2 additions & 2 deletions RELEASE_SCHEDULE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Release Schedule

We push a new release of Prebid.js every other week on Tuesday. During the adoption phase for 1.x, we are releasing updates for 1.x and 0.x at the same time.
We aim to push a new release of Prebid.js every week on Tuesday.

While the releases will be available immediately for those using direct Git access,
it will be about a week before the Prebid Org [Download Page](http://prebid.org/download.html) will be updated.
Expand Down Expand Up @@ -128,7 +128,7 @@ Characteristics of a `GA` release:

## FAQs

**1. Is there flexibility in the 2-week schedule?**
**1. Is there flexibility in the schedule?**

If a major bug is found in the current release, a maintenance patch will be done as soon as possible.

Expand Down
31 changes: 25 additions & 6 deletions gulpHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const gutil = require('gulp-util');
const MODULE_PATH = './modules';
const BUILD_PATH = './build/dist';
const DEV_PATH = './build/dev';
const ANALYTICS_PATH = '../analytics';


// get only subdirectories that contain package.json with 'main' property
Expand Down Expand Up @@ -66,7 +67,7 @@ module.exports = {
try {
var absoluteModulePath = path.join(__dirname, MODULE_PATH);
internalModules = fs.readdirSync(absoluteModulePath)
.filter(file => !(/(^|\/)\.[^\/\.]/g).test(file))
.filter(file => (/^[^\.]+(\.js)?$/).test(file))
.reduce((memo, file) => {
var moduleName = file.split(new RegExp('[.\\' + path.sep + ']'))[0];
var modulePath = path.join(absoluteModulePath, file);
Expand Down Expand Up @@ -126,18 +127,36 @@ module.exports = {
* Invoke with gulp <task> --analytics
* Returns an array of source files for inclusion in build process
*/
getAnalyticsSources: function(directory) {
getAnalyticsSources: function() {
if (!argv.analytics) {return [];} // empty arrays won't affect a standard build

const directoryContents = fs.readdirSync(directory);
const directoryContents = fs.readdirSync(ANALYTICS_PATH);
return directoryContents
.filter(file => isModuleDirectory(path.join(directory, file)))
.filter(file => isModuleDirectory(path.join(ANALYTICS_PATH, file)))
.map(moduleDirectory => {
const module = require(path.join(directory, moduleDirectory, MANIFEST));
return path.join(directory, moduleDirectory, module.main);
const module = require(path.join(ANALYTICS_PATH, moduleDirectory, MANIFEST));
return path.join(ANALYTICS_PATH, moduleDirectory, module.main);
});
},

/*
* Returns the babel options object necessary for allowing analytics packages
* to have their own configs. Gets added to prebid's webpack config with the
* flag --analytics
*/
getAnalyticsOptions: function() {
let options;

if (argv.analytics) {
// https://babeljs.io/docs/en/options#babelrcroots
options = {
babelrcRoots: ['.', ANALYTICS_PATH],
}
}

return options;
},

createEnd2EndTestReport : function(targetDestinationDir) {
var browsers = require('./browsers.json');
var env = [];
Expand Down
67 changes: 33 additions & 34 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ var _ = require('lodash');
var argv = require('yargs').argv;
var gulp = require('gulp');
var gutil = require('gulp-util');
var webserver = require('gulp-webserver');
var connect = require('gulp-connect');
var webpack = require('webpack');
var webpackStream = require('webpack-stream');
var uglify = require('gulp-uglify');
var gulpClean = require('gulp-clean');
var KarmaServer = require('karma').Server;
var karmaConfMaker = require('./karma.conf.maker');
var opens = require('open');
var opens = require('opn');
var webpackConfig = require('./webpack.conf');
var helpers = require('./gulpHelpers');
var concat = require('gulp-concat');
Expand All @@ -30,7 +30,6 @@ var jsEscape = require('gulp-js-escape');
var prebid = require('./package.json');
var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10);
var banner = '/* <%= prebid.name %> v<%= prebid.version %>\n' + dateString + ' */\n';
var analyticsDirectory = '../analytics';
var port = 9999;

// these modules must be explicitly listed in --modules to be included in the build, won't be part of "all" modules
Expand All @@ -56,12 +55,11 @@ function e2etestReport() {
var reportPort = 9010;
var targetDestinationDir = './e2etest-report';
helpers.createEnd2EndTestReport(targetDestinationDir);
gulp.src('./')
.pipe(webserver({
port: reportPort,
directoryListing: true,
livereload: true
}));
connect.server({
port: reportPort,
root: './',
livereload: true
});

setTimeout(function() {
opens('http://localhost:' + reportPort + '/' + targetDestinationDir.slice(2) + '/results.html');
Expand All @@ -81,25 +79,29 @@ function lint(done) {
if (argv.nolint) {
return done();
}
return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'])
.pipe(eslint())
const isFixed = function(file) {
return file.eslint != null && file.eslint.fixed;
}
return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'], {base: './'})
.pipe(eslint({fix: true}))
.pipe(eslint.format('stylish'))
.pipe(eslint.failAfterError());
.pipe(eslint.failAfterError())
.pipe(gulpif(isFixed, gulp.dest('./')));
};

// View the code coverage report in the browser.
function viewCoverage(done) {
var coveragePort = 1999;

var stream = gulp.src('./')
.pipe(webserver({
port: coveragePort,
directoryListing: true,
livereload: false,
open: 'build/coverage/karma_html/index.html'
}));
stream.on('finish', done);
connect.server({
port: coveragePort,
root: 'build/coverage/karma_html',
livereload: false
});
opens('http://localhost:' + coveragePort);
done();
};

viewCoverage.displayName = 'view-coverage';

// Watch Task with Live Reload
Expand All @@ -115,48 +117,45 @@ function watch(done) {
'test/spec/loaders/**/*.js'
]);

var stream = gulp.src('./')
.pipe(webserver({
https: argv.https,
port: port,
directoryListing: true,
livereload: true
}));
connect.server({
https: argv.https,
port: port,
root: './',
livereload: true
});

mainWatcher.on('all', gulp.series(clean, gulp.parallel(lint, 'build-bundle-dev', test)));
loaderWatcher.on('all', gulp.series(lint));
stream.on('finish', done);
done();
};

function makeDevpackPkg() {
var cloned = _.cloneDeep(webpackConfig);
cloned.devtool = 'source-map';
var externalModules = helpers.getArgModules();

const analyticsSources = helpers.getAnalyticsSources(analyticsDirectory);
const analyticsSources = helpers.getAnalyticsSources();
const moduleSources = helpers.getModulePaths(externalModules);

return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
.pipe(helpers.nameModules(externalModules))
.pipe(webpackStream(cloned, webpack))
.pipe(replace('$prebid.version$', prebid.version))
.pipe(gulp.dest('build/dev'));
.pipe(gulp.dest('build/dev'))
.pipe(connect.reload());
}

function makeWebpackPkg() {
var cloned = _.cloneDeep(webpackConfig);

delete cloned.devtool;

var externalModules = helpers.getArgModules();

const analyticsSources = helpers.getAnalyticsSources(analyticsDirectory);
const analyticsSources = helpers.getAnalyticsSources();
const moduleSources = helpers.getModulePaths(externalModules);

return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js'))
.pipe(helpers.nameModules(externalModules))
.pipe(webpackStream(cloned, webpack))
.pipe(replace('$prebid.version$', prebid.version))
.pipe(uglify())
.pipe(gulpif(file => file.basename === 'prebid-core.js', header(banner, { prebid: prebid })))
.pipe(optimizejs())
Expand Down
Loading

0 comments on commit 4aabe19

Please sign in to comment.