fossamagna / gas-webpack-plugin

Webpack plugin for Google Apps Script

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Webpack5

fossamagna opened this issue · comments

Thank you so much.

Can I point a little issue here. The generated output uses arrow functions in the build and this fails if the Google Apps Script project is using DEPRECATED_ES5 as the runtime.

image

@labnol
You can tell webpack what kind of ES-features may be used in the generated runtime-code with output.environment.

Example webpack.config.js for project using DEPRECATED_ES5 as the runtime:

module.exports = {
  mode: 'production',
  entry: "./main.js",
  output: {
    path: __dirname + "/output",
    filename: "bundle.js",
    environment: {
      // The environment supports arrow functions ('() => { ... }').
      arrowFunction: false,
      // The environment supports BigInt as literal (123n).
      bigIntLiteral: false,
      // The environment supports const and let for variable declarations.
      const: false,
      // The environment supports destructuring ('{ a, b } = obj').
      destructuring: false,
      // The environment supports an async import() function to import EcmaScript modules.
      dynamicImport: false,
      // The environment supports 'for of' iteration ('for (const x of array) { ... }').
      forOf: false,
      // The environment supports ECMAScript Module syntax to import ECMAScript modules (import ... from '...').
      module: false,
    }
  },
  plugins: [
    new GasPlugin({ autoGlobalExportsFiles: ["./main.js"] })
  ],
  optimization: {
    minimize: true,
  }
};

Please see for detail https://webpack.js.org/configuration/output/#outputenvironment.

Thank you. You are a star!