<commit_before>import { DefinePlugin, DllReferencePlugin, DllPlugin } from "webpack";
import { AureliaDependenciesPlugin } from "./AureliaDependenciesPlugin";
import { ConventionDependenciesPlugin, Convention } from "./ConventionDependenciesPlugin";
import { DistPlugin } from "./DistPlugin";
import { GlobDependenciesPlugin } from "./GlobDependenciesPlugin";
import { HtmlDependenciesPlugin } from "./HtmlDependenciesPlugin";
import { ModuleDependenciesPlugin, ModuleDependenciesPluginOptions } from "./ModuleDependenciesPlugin";
import { PreserveExportsPlugin } from "./PreserveExportsPlugin";
import { PreserveModuleNamePlugin } from "./PreserveModuleNamePlugin";
import { SubFolderPlugin } from "./SubFolderPlugin";

export type Polyfills = "es2015" | "es2016" | "esnext" | "none";

export interface Options {
  includeAll: false | string;
  
  aureliaApp?: string;
  aureliaConfig: string | string[];
  pal?: string;
  dist: string;
  entry?: string | string[];
  features: {
    svg?: boolean;
    unparser?: boolean;
    polyfills?: Polyfills;
  },
  noHtmlLoader: boolean;
  noModulePathResolve: boolean;
  noWebpackLoader: boolean;
  moduleMethods: string[];
  viewsFor: string;
  viewsExtensions: string | Convention | (string|Convention)[];
}

// See comments inside the module to understand why this is used
const emptyEntryModule = "aurelia-webpack-plugin/dist/aurelia-entry";

export class AureliaPlugin {
  options: Options;

  constructor(options: Partial<Options> = {}) {
    this.options = Object.assign({
      includeAll: <false>false,

      aureliaApp: "main",
      aureliaConfig: ["standard", "developmentLogging"],
      dist: "native-modules",
      features: { },
      moduleMethods: [],
      noHtmlLoader: false,
      noModulePathResolve: false,
      noWebpackLoader: false,
      // Ideally we would like _not_ to process conventions in node_modules,
      // because they should be using @useView and not rely in convention in 
      // the first place. Unfortunately at this point many libs do use conventions
      // so it's just more helpful for users to process them.
      // As unlikely as it may seem, a common offender here is tslib, which has
      // matching (yet unrelated) html files in its distribution. So I am making 
      // a quick exception for that.
      viewsFor: "**/!(tslib)*.{ts,js}",
      viewsExtensions: ".html",
    },
    options);

    this.options.features = Object.assign({
      svg: true,
      unparser: true,
      polyfills: <"es2015">"es2015",
    }, options.features);
  }

  apply(compiler: Webpack.Compiler) {
    const opts = this.options;
    const features = opts.features;
    let needsEmptyEntry = false;

    // Make sure the loaders are easy to load at the root like `aurelia-webpack-plugin/html-resource-loader`
    let resolveLoader = compiler.options.resolveLoader;
    let alias = resolveLoader.alias || (resolveLoader.alias = {});
    alias["aurelia-webpack-plugin"] = "aurelia-webpack-plugin/dist";
    // Our async! loader is in fact just bundle-loader!.
    alias["async"] = "bundle-loader";

    // For my own sanity when working on this plugin with `yarn link`,
    // make sure neither webpack nor Node resolve symlinks.
    if ("NODE_PRESERVE_SYMLINKS" in process.env) {
      resolveLoader.symlinks = false;
      compiler.options.resolve.symlinks = false;
    }

    // Uses DefinePlugin to cut out optional features
    const defines: any = {
      AURELIA_WEBPACK_2_0: "true"
    };
    if (!features.svg) defines.FEATURE_NO_SVG = "true";
    if (!features.unparser) defines.FEATURE_NO_UNPARSER = "true";
    definePolyfills(defines, features.polyfills!);

    // Add some dependencies that are not documented with PLATFORM.moduleName
    // because they are determined at build-time.
    const dependencies: ModuleDependenciesPluginOptions = {
      // PAL for target
      "aurelia-bootstrapper": "pal" in opts ? opts.pal : getPAL(compiler.options.target),
      // `aurelia-framework` exposes configuration helpers like `.standardConfiguration()`,
      // that load plugins, but we can't know if they are actually used or not.
      // User indicates what he uses at build time in `aureliaConfig` option.
      // Custom config is performed in use code and can use `.moduleName()` like normal.
      "aurelia-framework": getConfigModules(opts.aureliaConfig),
    };
    let globalDependencies: (string|DependencyOptionsEx)[] = [];

    if (opts.dist) {
      // This plugin enables easy switching to a different module distribution (default for Aurelia is dist/commonjs).
      let resolve = compiler.options.resolve;<commit_msg>feat(build): flag to opt-out of IE support<commit_after>import { DefinePlugin, DllReferencePlugin, DllPlugin } from "webpack";
import { AureliaDependenciesPlugin } from "./AureliaDependenciesPlugin";
import { ConventionDependenciesPlugin, Convention } from "./ConventionDependenciesPlugin";
import { DistPlugin } from "./DistPlugin";
import { GlobDependenciesPlugin } from "./GlobDependenciesPlugin";
import { HtmlDependenciesPlugin } from "./HtmlDependenciesPlugin";
import { ModuleDependenciesPlugin, ModuleDependenciesPluginOptions } from "./ModuleDependenciesPlugin";
import { PreserveExportsPlugin } from "./PreserveExportsPlugin";
import { PreserveModuleNamePlugin } from "./PreserveModuleNamePlugin";
import { SubFolderPlugin } from "./SubFolderPlugin";

export type Polyfills = "es2015" | "es2016" | "esnext" | "none";

export interface Options {
  includeAll: false | string;
  
  aureliaApp?: string;
  aureliaConfig: string | string[];
  pal?: string;
  dist: string;
  entry?: string | string[];
  features: {
    ie?: boolean;
    svg?: boolean;
    unparser?: boolean;
    polyfills?: Polyfills;
  },
  noHtmlLoader: boolean;
  noModulePathResolve: boolean;
  noWebpackLoader: boolean;
  moduleMethods: string[];
  viewsFor: string;
  viewsExtensions: string | Convention | (string|Convention)[];
}

// See comments inside the module to understand why this is used
const emptyEntryModule = "aurelia-webpack-plugin/dist/aurelia-entry";

export class AureliaPlugin {
  options: Options;

  constructor(options: Partial<Options> = {}) {
    this.options = Object.assign({
      includeAll: <false>false,

      aureliaApp: "main",
      aureliaConfig: ["standard", "developmentLogging"],
      dist: "native-modules",
      features: { },
      moduleMethods: [],
      noHtmlLoader: false,
      noModulePathResolve: false,
      noWebpackLoader: false,
      // Ideally we would like _not_ to process conventions in node_modules,
      // because they should be using @useView and not rely in convention in 
      // the first place. Unfortunately at this point many libs do use conventions
      // so it's just more helpful for users to process them.
      // As unlikely as it may seem, a common offender here is tslib, which has
      // matching (yet unrelated) html files in its distribution. So I am making 
      // a quick exception for that.
      viewsFor: "**/!(tslib)*.{ts,js}",
      viewsExtensions: ".html",
    },
    options);

    this.options.features = Object.assign({
      ie: true,
      svg: true,
      unparser: true,
      polyfills: <"es2015">"es2015",
    }, options.features);
  }

  apply(compiler: Webpack.Compiler) {
    const opts = this.options;
    const features = opts.features;
    let needsEmptyEntry = false;

    // Make sure the loaders are easy to load at the root like `aurelia-webpack-plugin/html-resource-loader`
    let resolveLoader = compiler.options.resolveLoader;
    let alias = resolveLoader.alias || (resolveLoader.alias = {});
    alias["aurelia-webpack-plugin"] = "aurelia-webpack-plugin/dist";
    // Our async! loader is in fact just bundle-loader!.
    alias["async"] = "bundle-loader";

    // For my own sanity when working on this plugin with `yarn link`,
    // make sure neither webpack nor Node resolve symlinks.
    if ("NODE_PRESERVE_SYMLINKS" in process.env) {
      resolveLoader.symlinks = false;
      compiler.options.resolve.symlinks = false;
    }

    // Uses DefinePlugin to cut out optional features
    const defines: any = {
      AURELIA_WEBPACK_2_0: "true"
    };
    if (!features.ie) defines.FEATURE_NO_IE = "true";
    if (!features.svg) defines.FEATURE_NO_SVG = "true";
    if (!features.unparser) defines.FEATURE_NO_UNPARSER = "true";
    definePolyfills(defines, features.polyfills!);

    // Add some dependencies that are not documented with PLATFORM.moduleName
    // because they are determined at build-time.
    const dependencies: ModuleDependenciesPluginOptions = {
      // PAL for target
      "aurelia-bootstrapper": "pal" in opts ? opts.pal : getPAL(compiler.options.target),
      // `aurelia-framework` exposes configuration helpers like `.standardConfiguration()`,
      // that load plugins, but we can't know if they are actually used or not.
      // User indicates what he uses at build time in `aureliaConfig` option.
      // Custom config is performed in use code and can use `.moduleName()` like normal.
      "aurelia-framework": getConfigModules(opts.aureliaConfig),
    };
    let globalDependencies: (string|DependencyOptionsEx)[] = [];

    if (opts.dist) {
      // This plugin enables easy switching to a different module distribution (default for Aurelia is dist/commonjs).
      let resolve = compiler.options.resolve;
{'fraction_non_alphanumeric': 0.10716948971982529, 'fraction_numerical': 0.003835091083413231, 'mean_word_length': 3.5418480890179005, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3701744', 'n_tokens_mistral': 2669, 'n_tokens_neox': 2580, 'n_words': 829}