Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function (context, opts = {}) {
return {
presets: [
opts.es2015 !== false && [presetES2015.buildPreset, opts.es2015],
opts.es2016 !== false && presetES2016,
opts.es2017 !== false && presetES2017
].filter(Boolean) // filter out falsy values
};
}
callback(headers, body);
return;
}
try {
body = require('babel-core').transform(body.toString(), {
filename : path.join(options.dir, pathname),
filenameRelative: pathname,
compact : false,
ast : false,
comments : false,
moduleIds : true,
plugins : [
babelModuleInner,
].concat(
require('babel-preset-es2015').plugins
.filter(function (_, index, list) {
// Super dirty hack to remove commonjs module formatter
return index !== list.length - 2;
})
).concat(
require('babel-preset-react').plugins
).concat([
babelModuleOuter,
]),
}).code;
headers['Content-Type'] = 'application/javascript';
} catch (err) {
console.error('failed to compile JSX file, ' + pathname);
console.error(err.stack || err.message || err.toString());
if (options.production) {
process.exit(1);
* http://polymer.github.io/PATENTS.txt
*/
import {transform as babelTransform, TransformOptions as BabelTransformOptions} from 'babel-core';
import * as cssSlam from 'css-slam';
import * as gulpif from 'gulp-if';
import {minify as htmlMinify, Options as HTMLMinifierOptions} from 'html-minifier';
import * as logging from 'plylog';
import {Transform} from 'stream';
import * as vinyl from 'vinyl';
import matcher = require('matcher');
const babelPresetES2015 = require('babel-preset-es2015');
const minifyPreset = require('babel-preset-minify');
const babelPresetES2015NoModules =
babelPresetES2015.buildPreset({}, {modules: false});
const externalHelpersPlugin = require('babel-plugin-external-helpers');
const babelObjectRestSpreadPlugin =
require('babel-plugin-transform-object-rest-spread');
const babelPluginSyntaxDynamicImport =
require('babel-plugin-syntax-dynamic-import');
const babelPluginSyntaxObjectRestSpread =
require('babel-plugin-syntax-object-rest-spread');
// TODO(fks) 09-22-2016: Latest npm type declaration resolves to a non-module
// entity. Upgrade to proper JS import once compatible .d.ts file is released,
// or consider writing a custom declaration in the `custom_typings/` folder.
import File = require('vinyl');
const logger = logging.getLogger('cli.build.optimize-streams');
export type FileCB = (error?: any, file?: File) => void;
const del = require('del');
const gulp = require('gulp');
const gulpif = require('gulp-if');
const gulpdebug = require('gulp-debug');
const gulpHelp = require('gulp-help')(gulp);
const gulpfilter = require('gulp-filter');
const mergeStream = require('merge-stream');
const polymerBuild = require('polymer-build');
const babel = require('gulp-babel');
const babelPresetES2015 = require('babel-preset-es2015');
const babiliPreset = require('babel-preset-babili');
const babelPresetES2015NoModules = babelPresetES2015.buildPreset({}, {modules: false});
const cssSlam = require('css-slam').gulp;
const htmlMinifier = require('gulp-html-minifier');
const polymerJson = require('./polymer.json');
const buildRoot = 'build';
const debug = false;
// Waits for the given ReadableStream
function waitFor(stream) {
return new Promise((resolve, reject) => {
stream.on('end', resolve);
stream.on('error', reject);
});
}
// @ts-ignore
const minifyPreset = require('babel-preset-minify');
// @ts-ignore
const presetEs3 = require('babel-preset-es3');
const htmlMinifier = require('html-minifier');
const mergeStream = require('merge-stream');
const ProgressBar = require('progress');
const babelCore = require('babel-core');
const dest = require('vinyl-fs').dest;
// @ts-ignore
const cssSlam = require('css-slam');
const gulpif = require('gulp-if');
const stream = require('stream');
const path = require('path');
const babelTransform = babelCore.transform;
const es2015Preset = babelPreset2015.buildPreset({}, {
modules: false
});
function pipeStreams(streams) {
return Array.prototype.concat.apply([], streams)
.filter(val => val !== null)
.reduce((a, b) => {
return a.pipe(b);
});
}
class GenericOptimizeTransform extends stream.Transform {
constructor(optimizerName, optimizer, optimizerOptions) {
super({objectMode: true});
transform: function(code, streamlineOptions) {
streamlineOptions = streamlineOptions || {};
streamlineOptions.runtime = streamlineOptions.runtime || "callbacks";
var plugins = [[streamline, streamlineOptions]];
// remove regenerator plugin (last one in es2015 preset) if generators mode
es2015.plugins = es2015Plugins.slice(); // restore original plugins list
if (streamlineOptions.runtime === 'generators') es2015.plugins.pop();
return babel.transform(code, {
plugins: plugins,
presets: es2015,
}).code;
},
modules: {
"use strict";
var babel = require('babel-core');
var streamline = require('babel-plugin-streamline');
var es2015 = require('babel-preset-es2015');
var es2015Plugins = es2015.plugins;
window.Streamline = {
transform: function(code, streamlineOptions) {
streamlineOptions = streamlineOptions || {};
streamlineOptions.runtime = streamlineOptions.runtime || "callbacks";
var plugins = [[streamline, streamlineOptions]];
// remove regenerator plugin (last one in es2015 preset) if generators mode
es2015.plugins = es2015Plugins.slice(); // restore original plugins list
if (streamlineOptions.runtime === 'generators') es2015.plugins.pop();
return babel.transform(code, {
plugins: plugins,
presets: es2015,
}).code;
},
modules: {
'streamline-runtime/lib/callbacks/regenerator' : require('streamline-runtime/lib/callbacks/regenerator'),
function webpackBuild(filename, libraryName, version) {
// If this build is part of a pull request, include the pull request number in
// the version number.
if (process.env.CIRCLE_PR_NUMBER) {
version += '+pr.' + process.env.CIRCLE_PR_NUMBER;
}
const typeofPlugin = require("babel-plugin-transform-es2015-typeof-symbol")
.default;
// babel-plugin-transform-es2015-typeof-symbol is not idempotent, and something
// else is already running it, so we need to exclude it from the transform.
const preset2015 = require("babel-preset-es2015").default();
const es2015WithoutTypeof = {
plugins: preset2015.plugins.filter(plugin => plugin !== typeofPlugin),
};
const config = {
module: {
rules: [
{
//exclude: /node_modules/,
test: /\.js$/,
loader: "babel-loader",
options: {
// Some of the node_modules may have their own "babel" section in
// their project.json (or a ".babelrc" file). We need to ignore
// those as we're using our own Babel options.
babelrc: false,
const externalHelpers = require('babel-plugin-external-helpers');
const babelPreset2015 = require('babel-preset-es2015');
const minifyPreset = require('babel-preset-minify');
const presetEs3 = require('babel-preset-es3');
import * as htmlMinifier from 'html-minifier';
import * as babelCore from 'babel-core';
import mergeStream from 'merge-stream';
import ProgressBar from 'progress';
import * as stream from 'stream';
import { dest } from 'vinyl-fs';
import cssSlam from 'css-slam';
import * as path from 'path';
import gulpif from 'gulp-if';
const babelTransform = babelCore.transform;
const es2015Preset = babelPreset2015.buildPreset({}, {
modules: false
});
function pipeStreams(streams: (NodeJS.ReadWriteStream|NodeJS.ReadWriteStream[])[]): NodeJS.ReadWriteStream {
return Array.prototype.concat.apply([], streams)
.filter((val: any) => val !== null)
.reduce((a: NodeJS.ReadWriteStream, b: NodeJS.ReadWriteStream) => {
return a.pipe(b);
});
}
interface StreamFile {
path: string;
contents: Buffer;
}