{"id":13599455,"url":"https://github.com/fossamagna/gas-webpack-plugin","last_synced_at":"2025-04-07T18:10:54.208Z","repository":{"id":13337247,"uuid":"74210633","full_name":"fossamagna/gas-webpack-plugin","owner":"fossamagna","description":"Webpack plugin for Google Apps Script","archived":false,"fork":false,"pushed_at":"2024-12-31T14:35:29.000Z","size":2292,"stargazers_count":172,"open_issues_count":11,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-04T14:52:52.834Z","etag":null,"topics":["apps-script","google-apps-script","webpack","webpack-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fossamagna.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-19T13:37:58.000Z","updated_at":"2024-12-31T14:35:26.000Z","dependencies_parsed_at":"2024-01-14T04:42:02.282Z","dependency_job_id":"90972846-bc86-42b3-8ec6-e480e2e8a32b","html_url":"https://github.com/fossamagna/gas-webpack-plugin","commit_stats":{"total_commits":528,"total_committers":10,"mean_commits":52.8,"dds":0.7196969696969697,"last_synced_commit":"b5d560a3ca8826f9ae2d7e2acafa4b109eefba15"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fossamagna%2Fgas-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fossamagna%2Fgas-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fossamagna%2Fgas-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fossamagna%2Fgas-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fossamagna","download_url":"https://codeload.github.com/fossamagna/gas-webpack-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247704569,"owners_count":20982298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apps-script","google-apps-script","webpack","webpack-plugin"],"created_at":"2024-08-01T17:01:04.415Z","updated_at":"2025-04-07T18:10:54.160Z","avatar_url":"https://github.com/fossamagna.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Development"],"sub_categories":["Lists \u0026 collections"],"readme":"# gas-webpack-plugin [![NPM version][npm-image]][npm-url] [![Build Status][github-actions-image]][github-actions-url] [![Coverage percentage][coveralls-image]][coveralls-url]\n\n[Webpack](https://webpack.js.org/) plugin for Google Apps Script.\n\n## About\n\nIn Google Apps Script, an entry point called from [google.script.run](https://developers.google.com/apps-script/guides/html/reference/run) must be a top level function declaration on the server side.\n`gas-webpack-plugin` detects function assignment expressions to `global` object and generate a corresponding top level function declaration statement.\n\n## example\n\nmain.js:\n```js\nvar echo = require('./echo');\n/**\n * Return write arguments.\n */\nglobal.echo = echo;\n```\n\necho.js:\n```js\nmodule.exports = function(message) {\n  return message;\n}\n```\n\nwebpack.config.js:\n```js\nconst GasPlugin = require(\"gas-webpack-plugin\");\nmodule.exports = {\n  context: __dirname,\n  entry: \"./main.js\",\n  output: {\n    path: __dirname ,\n    filename: 'Code.gs'\n  },\n  plugins: [\n    new GasPlugin()\n  ]\n}\n```\n\nbuild:\n```\n$ webpack --mode production\n```\n\nCode.gs\n```js\n/**\n * Return write arguments.\n */\nfunction echo() {\n}/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module \u0026\u0026 module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports) {\n\nvar g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\n} catch(e) {\n\t// This works if the window reference is available\n\tif(typeof window === \"object\")\n\t\tg = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\nmodule.exports = function(message) {\n  return message;\n};\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n/* WEBPACK VAR INJECTION */(function(global) {var echo = __webpack_require__(1);\nglobal.echo = echo;\n\n/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))\n\n/***/ })\n/******/ ]);\n```\n\n## Installation\n\n```sh\n$ npm install gas-webpack-plugin --save-dev\n```\n\n## Usage\n\n### CLI\n\n```sh\n$ webpack --mode production\n```\n\n### Options\n\nYou can pass a hash of configuration options to gas-webpack-plugin. Allowed values are as follows\n\n| Name | Type | Default | Description |\n-------|------|---------|-------------|\n| comment | `{Boolean}` | `true` | If true then generate a top level function declaration statement with comment. |\n| autoGlobalExportsFiles | `{Array\u003cString\u003e}` | `[]` | Array of source file paths that to generate global assignments expression from exports.* statements. |\n| include | `{Array\u003cString\u003e}` | `[**/*]` | Array of path patterns to detect functions to generate top level function definitions. accept glob pattern. |\n\n## Geranate global assignment expressions from exports.*\n\nAssignments expression to global object is automatically generated from named exports (`exports.*`) Included in the file specified by the autoGlobalExportsFiles option.\n\nmain.ts:\n```ts\nimport './echo';\n```\n\necho.ts:\n```ts\n// geranate global assignment expressions from named export\nexport const echo = (message) =\u003e message;\n```\n\nwebpack.config.js:\n```js\nconst GasPlugin = require(\"gas-webpack-plugin\");\nmodule.exports = {\n  context: __dirname,\n  entry: \"./main.ts\",\n  module: {\n    rules: [\n      {\n        test: /(\\.ts)$/,\n        loader: 'ts-loader',\n      },\n    ],\n  },\n  resolve: {\n    extensions: [\".ts\"],\n  },\n  output: {\n    path: __dirname ,\n    filename: 'Code.js'\n  },\n  plugins: [\n    new GasPlugin({\n      autoGlobalExportsFiles: ['**/*.ts']\n    })\n  ]\n}\n```\n\n### Webpack version support\n\ngas-webpack-plugin is support for Webpack@5.x\n\n[npm-image]: https://badge.fury.io/js/gas-webpack-plugin.svg\n[npm-url]: https://npmjs.org/package/gas-webpack-plugin\n[github-actions-image]: https://github.com/fossamagna/gas-webpack-plugin/actions/workflows/test.yml/badge.svg?branch=master\n[github-actions-url]: https://github.com/fossamagna/gas-webpack-plugin/actions/workflows/test.yml?branch=master\n[coveralls-image]: https://coveralls.io/repos/github/fossamagna/gas-webpack-plugin/badge.svg?branch=master\n[coveralls-url]: https://coveralls.io/github/fossamagna/gas-webpack-plugin?branch=master\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffossamagna%2Fgas-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffossamagna%2Fgas-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffossamagna%2Fgas-webpack-plugin/lists"}