Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Webpack5 #417

Closed
fossamagna opened this issue Sep 3, 2020 · 3 comments · Fixed by #504
Closed

Support Webpack5 #417

fossamagna opened this issue Sep 3, 2020 · 3 comments · Fixed by #504
Assignees

Comments

@fossamagna
Copy link
Owner

No description provided.

@fossamagna fossamagna self-assigned this Feb 26, 2021
fossamagna added a commit that referenced this issue Feb 27, 2021
Change of use some webpack hooks api.
- Use chunkAsset hook instead of deprecated optimizeChunkAssets hook.
- Use buildModule hook instead of parser.hook.

Closes #417
Breaks support only webpack 5.
@labnol
Copy link

labnol commented Mar 2, 2021

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

@fossamagna
Copy link
Owner Author

@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.

@labnol
Copy link

labnol commented Mar 3, 2021

Thank you. You are a star!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants