fossamagna / gas-webpack-plugin Goto Github PK
View Code? Open in Web Editor NEWWebpack plugin for Google Apps Script
Webpack plugin for Google Apps Script
Vulnerabilities
DepShield reports that this application's usage of q:1.5.1 results in the following vulnerability(s):
Occurrences
q:1.5.1 is a transitive dependency introduced by the following direct dependency(s):
• conventional-changelog-cli:2.0.21
└─ conventional-changelog:3.1.8
└─ conventional-changelog-angular:5.0.3
└─ q:1.5.1
└─ conventional-changelog-atom:2.0.1
└─ q:1.5.1
└─ conventional-changelog-codemirror:2.0.1
└─ q:1.5.1
└─ conventional-changelog-conventionalcommits:3.0.2
└─ q:1.5.1
└─ conventional-changelog-core:3.2.2
└─ q:1.5.1
└─ conventional-changelog-ember:2.0.2
└─ q:1.5.1
└─ conventional-changelog-eslint:3.0.2
└─ q:1.5.1
└─ conventional-changelog-express:2.0.1
└─ q:1.5.1
└─ conventional-changelog-jquery:3.0.4
└─ q:1.5.1
└─ conventional-changelog-jshint:2.0.1
└─ q:1.5.1
This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.
I tried using this to write some custom functions for Spreadsheet
/**
* Test Function
* @param {any} input
* @return "From test Function"
* @customfunction
*/
global.testCustomFunction = (input) =>
{
return `From test function: ${input}`
}
In the output
function testCustomFunction() {
}/******/ (function(modules) { // webpackBootstrap
// Webpack stuffs
"use strict";
/* WEBPACK VAR INJECTION */(function(global) {
/**
* Test Func
* @param {any} input
* @return "From test Func"
* @customfunction
*/
global.testCustomFunction = function (input) {
return "From test function: " + input;
};
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
// Webpack stuffs
It works but the JS Doc as well as the function parameters are not brought over to the exposed function and therefore can't be detected by spreadsheet for auto completion.
I will be able to set it as follows.
new GasPlugin({
include: ["src/**/*.ts"]
})
Originally posted by @fossamagna in #685 (comment)
Hi. Thank you for great plugin! With your plugin I tried to make a library but I got this error when I push the script produced by gas-webpack-plugin with @google/clasp.
For more detail you can see:
Push failed. Errors:
Syntax error: Missing name after . operator. line: 151 file: index
Files to push were:
└─ dist/appsscript.json
└─ dist/index.js
Whole code is here. Please don't forget change scriptId in clasp to try to push.
Thank you.
I am trying to use this template: https://github.com/iansan5653/gas-ts-template
But exports in build/index.js after typescript compilation do not expose to global object even after adding path in autoGlobalExportsFiles
array.
Hello,
Today I was trying to make this plugin work with the autoGlobalExportsFiles
settings. I tend to always use the "latest and greatest" version of any packages; and this may be my pitfall here.
Anyway, here a code that is working fine in GAS; but the autoGlobalExportsFiles
do nothing (I still need to put the global.[fct] = fct
in my code). I created a repo that replicate this: https://github.com/sharky98/es2022-gas-webpack-plugin-bug.
In there you'll see in dist folder the three output I got. You'll also have the webpack config, and tsconfig.
Note: I am using TypeScript 5, with array extends; which mean I need to use the current main for ts-node; the tgz is included in the repo, with the right config from package.json.
Note 2: I am not too familiar with webpack config and tsconfig... Just enough to make it work for me. So, feel free to tell me what I miss.
Note 3: I added you as collaborators on that repo; feel free to commit to it for any correction/test/etc.
Thanks
Vulnerabilities
DepShield reports that this application's usage of lodash._reinterpolate:3.0.0 results in the following vulnerability(s):
Occurrences
lodash._reinterpolate:3.0.0 is a transitive dependency introduced by the following direct dependency(s):
• conventional-changelog-cli:2.0.11
└─ conventional-changelog:3.0.5
└─ conventional-changelog-core:3.1.5
└─ git-raw-commits:2.0.0
└─ lodash.template:4.4.0
└─ lodash._reinterpolate:3.0.0
└─ lodash.templatesettings:4.1.0
└─ lodash._reinterpolate:3.0.0
This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.
Vulnerabilities
DepShield reports that this application's usage of lodash.templatesettings:4.1.0 results in the following vulnerability(s):
Occurrences
lodash.templatesettings:4.1.0 is a transitive dependency introduced by the following direct dependency(s):
• conventional-changelog-cli:2.0.11
└─ conventional-changelog:3.0.5
└─ conventional-changelog-core:3.1.5
└─ git-raw-commits:2.0.0
└─ lodash.template:4.4.0
└─ lodash.templatesettings:4.1.0
This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.
Vulnerabilities
DepShield reports that this application's usage of mocha:5.0.5 results in the following vulnerability(s):
Occurrences
mocha:5.0.5 is a transitive dependency introduced by the following direct dependency(s):
• coveralls:3.0.8
└─ cobertura-parse:1.0.5
└─ mocha:5.0.5
This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.
Vulnerabilities
DepShield reports that this application's usage of handlebars:4.1.2 results in the following vulnerability(s):
Occurrences
handlebars:4.1.2 is a transitive dependency introduced by the following direct dependency(s):
• conventional-changelog-cli:2.0.23
└─ conventional-changelog:3.1.10
└─ conventional-changelog-core:4.0.0
└─ conventional-changelog-writer:4.0.7
└─ handlebars:4.1.2
• nyc:14.1.1
└─ istanbul-reports:2.2.4
└─ handlebars:4.1.2
This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.
Our project was building fine on 1.0.3 but after upgrading to 1.0.4 we get an error,
ERROR in main.js from es3ify
TypeError: asset.map is not a function
at <redacted>/node_modules/es3ify-webpack-plugin/index.js:65:31
at Array.forEach (<anonymous>)
at <redacted>/node_modules/es3ify-webpack-plugin/index.js:55:10
at _next0 (eval at create (<redacted>/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:8:1)
at eval (eval at create (<redacted>/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:21:1)
at <redacted>/node_modules/gas-webpack-plugin/index.js:33:7
at AsyncSeriesHook.eval [as callAsync] (eval at create (<redacted>/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:17:1)
at AsyncSeriesHook.lazyCompileHook (<redacted>/node_modules/tapable/lib/Hook.js:154:20)
at <redacted>/node_modules/webpack/lib/Compilation.js:1409:36
at eval (eval at create (<redacted>/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
at <redacted>/node_modules/copy-webpack-plugin/dist/index.js:101:9
Downgrading to 1.0.3 fixed the issue so not a major problem for us.
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Hi,
The plugin is broken for my when using v2.2.0 and I believe I've traced the issue down to this line:
if (!this.includePatterns.some(file => minimatch(module.resource, file))) {
return;
}
For me it seems to be skipping all files as minimatch isn't matching files using the default include pattern.
I believe this is due to upgrading minimatch from v3.0.4
to v5.0.0
after testing the following in minimatch in both versions:
const minimatch = require('minimatch');
const resource = "C:\\Foo\\Bar.js";
const patten = "C:\\Foo\\**\\*";
const result = minimatch(resource, patten);
// v3.0.4 -> result = true;
// v5.0.0 -> result = false;
I'm using Windows so I'm not sure if this is a windows only issue.
The import.meta
is used to get import.meta.url
in JS generated by wasm-pack.
Could it to be fixed if gas-webpack-plugin
allow to use esprima.parseModule
with some config option?
I opened an issue in esprima as it didn't work in the online demo. But looking more I found that doc, then maybe the error is in this plugin.
Hi, this plugin is great! But I need output code can uglify/minify?
Found another issue I guess. This doesn't work.
const fnName = "hello";
global[fnName] = () => console.log("do something..");
Originally posted by @labnol in #516 (comment)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors
Hi @fossamagna, thanks for the work on this very useful plugin.
I've been trying to upgrade to webpack 5 and running into issues with autoGlobalExportsFiles
config. It looks as though the "global" assignments are incorrectly being inserted into the webpack file.
I noticed when I take out this line, it works fine:
Line 86 in dc5c4b2
Here is my bundled file after I remove that line from this plugin. Interestingly, the code works fine if this line is left out -- I can still run this code in a spreadsheet and the global functions are found correctly:
And here it is with that line left in. Notice the insertion is not happening in the right place.
Any ideas what might be causing this?
Vulnerabilities
DepShield reports that this application's usage of debug:2.6.9 results in the following vulnerability(s):
Occurrences
debug:2.6.9 is a transitive dependency introduced by the following direct dependency(s):
• tap:13.1.11
└─ import-jsx:2.0.0
└─ babel-core:6.26.3
└─ debug:2.6.9
└─ babel-traverse:6.26.0
└─ debug:2.6.9
└─ tap-mocha-reporter:4.0.1
└─ debug:2.6.9
• webpack:4.31.0
└─ micromatch:3.1.10
└─ extglob:2.0.4
└─ expand-brackets:2.1.4
└─ debug:2.6.9
└─ snapdragon:0.8.2
└─ debug:2.6.9
This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.
When building the exact example from the homepage in a yarn workspace with node 12 or 14, webpack warned me that webpack-cli was required to build the project.
I originally used the gas plugin with webpack in a larger project that probably somehow suppressed that warning and just resulted in an error similar to the one mentioned in #460 .
Proposal: add documentation to add webpack-cli to dependencies when using yarn.
tree:
.
├── echo.js
├── main.js
├── package.json
└── webpack.config.js
Package.json contents:
{
"name": "temp",
"version": "1.0.0",
"description": "temp",
"license": "MIT",
"devDependencies": {
"gas-webpack-plugin": "^2.0.0",
"webpack": "^5.28.0"
},
"scripts": {
"build": "yarn webpack"
}
}
Other files are copied verbatim from this package's homepage example.
This is because gas-webpack-plugin was verifying that the paths of modules that are ignored by webpack, such as crypto
, are subject to auto exports. Modules that are ignored by webpack should be excluded as they cannot get the resource path.
Originally posted by @fossamagna in fossamagna/gas-entry-generator#163 (comment)
Branch | Build failing 🚨 |
---|---|
Dependency | conventional-changelog-cli |
Current Version | 1.3.10 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
conventional-changelog-cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
I did add two other use cases in my repo, one that works and one that isn't. They are more edge case situation I would say, nice to have.
The one not working is when doing a named export of a const
function inside the declaration and not as an export list like below.
I'll leave it to you to close this issue or leave it open for this "nice to have" second part.
export const doGet = () => {
const title = "Google Apps Script";
const fileName = "index.html";
return HtmlService.createHtmlOutputFromFile(fileName)
.setTitle(title)
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.DEFAULT);
};
Thank you very much again!
Originally posted by @sharky98 in #794 (comment)
Thanks for the good work.
I am getting an error after upgrading to v1.2.1.
ERROR in chunk main [entry]
090ffc44364d4dc2508e.js
/Users/labnol/node_modules/babel-loader/lib/index.js!/Users/labnol/node_modules/eslint-loader/dist/cjs.js??ref--4!/Users/labnol/src/index.js
If you can help, that would be awesome!
i am using the latest version of your script
but cannot get it to work with classes
i suspect it does not support it
The top level functions are not generated when the mode is set to production. It works fine for 'none' mode.
Vulnerabilities
DepShield reports that this application's usage of lodash.template:4.4.0 results in the following vulnerability(s):
Occurrences
lodash.template:4.4.0 is a transitive dependency introduced by the following direct dependency(s):
• conventional-changelog-cli:2.0.11
└─ conventional-changelog:3.0.5
└─ conventional-changelog-core:3.1.5
└─ git-raw-commits:2.0.0
└─ lodash.template:4.4.0
This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.
Hi. Thank you for making a great plugin.
If original source code contains decorators,
this plugin does not produce working code...
When I run the transpiled file, I get the following error.
TypeError: (0 , _metadata_MetadataStorage__WEBPACK_IMPORTED_MODULE_1__.getMetadataStorage)(...).addConstraintMetadata is not a function(line 482, file "index")
minimum reproduction repository: https://github.com/soracore/gas-ts-decorator-problem
Simply removing gas-webpack-plugin from webpack config solves this problem,
but then I cannot access the main function from GAS.
Is there any way I could workaround this problem?
I noticed an issue with the production mode. The top-level function is not added to the output if the global function calls another method that is imported from another folder.
I tried to replicate the structure here if that explains it better. https://codesandbox.io/s/mystifying-mestorf-8dfec?file=/src/index.js
When bundling with a function to global space it copies the JS DOC as the purpose of the plugin but would it be possible to remove the comment from the function definition in production mode to keep comments to a minimum.
In practice would this code:
/**
* Return write arguments.
* @customfunction
*/
function echo() {
}
//webpack stuff
var echo = () => console.log('hello');
/**
* Return write arguments.
* @customfunction
*/
__webpack_require__.g.echo = echo;
/******/ })()
;
Become this:
/**
* Return write arguments.
* @customfunction
*/
function echo() {
}
//webpack stuff
var echo = () => console.log('hello');
__webpack_require__.g.echo = echo;
/******/ })()
;
(Sorry if I'm doing this wrong this is my first issue submission)
I'm trying out the latest version 2.0.1 and unfortunately my webpack build is failing with it:
ERROR in chunk main [entry]
code.js
Cannot read property 'getChunkModules' of undefined
It works fine with 1.2.2 it seems. Any suggestions? Thanks!!
Vulnerabilities
DepShield reports that this application's usage of lodash.debounce:4.0.8 results in the following vulnerability(s):
Occurrences
lodash.debounce:4.0.8 is a transitive dependency introduced by the following direct dependency(s):
• webpack:4.26.1
└─ watchpack:1.6.0
└─ chokidar:2.0.4
└─ lodash.debounce:4.0.8
This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.
Vulnerabilities
DepShield reports that this application's usage of lodash.throttle:4.1.1 results in the following vulnerability(s):
Occurrences
lodash.throttle:4.1.1 is a transitive dependency introduced by the following direct dependency(s):
• tap:13.0.3
└─ treport:0.3.0
└─ ink:2.1.1
└─ lodash.throttle:4.1.1
This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.
Apologies if this is gross incompetence, but I'm extremely new to webpack & following the ts example in the readme throws Script function not found: doGet
when attempting to access gas-deployed webapp - mind getting me pointed in the right direction?
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1",
"gas-webpack-plugin": "^2.1.0",
src/index.ts
import "./app/do-get";
src/app/do-get.ts
const appTitle = "Google Apps Script template";
export function doGet() {
return HtmlService.createTemplateFromFile("page")
.evaluate()
.setTitle(appTitle);
}
webpack.config.js
const GasPlugin = require("gas-webpack-plugin");
module.exports = {
mode: "production",
context: __dirname,
entry: "./src/index.ts",
module: {
rules: [
{
test: /(\.ts)$/,
loader: "ts-loader",
},
],
},
resolve: {
extensions: [".ts"],
},
output: {
path: __dirname,
filename: "Code.js",
},
plugins: [
new GasPlugin({
autoGlobalExportsFiles: ["*.ts"],
}),
],
};
Code.js (as compiled)
(() => {
"use strict";
var e = {
779: (e, t) => {
Object.defineProperty(t, "__esModule", { value: !0 }),
(t.doGet = void 0),
(t.doGet = () =>
HtmlService.createTemplateFromFile("page")
.evaluate()
.setTitle("Google Apps Script template"));
},
},
t = {};
!(function r(o) {
var p = t[o];
if (void 0 !== p) return p.exports;
var a = (t[o] = { exports: {} });
return e[o](a, a.exports, r), a.exports;
})(779);
})();
Hi again @fossamagna , I wanted to see if you had any ideas how to improve this:
Now that we can use gas-webpack-plugin
to automatically export our functions on the global
object, we've reduced our the amount of repetitive code a lot, thats great.
We have one last area of repetitive code: we're manually writing a typescript interface called ServerFunctions
which has all the exported global functions on it, so that we can call them in a type-safe manner from our addon client code.
It looks like this:
export interface ServerFunctions {
setActiveSheet: (sheetName: string) => void;
getSpreadsheetProperties: () => SpreadsheetPropertiesGAS;
markSpreadsheetInstalledOn: () => void;
...
}
Then in the client we use it like this:
const Server = require('gas-client').default;
type ServerAsync = {
serverFunctions: Promisify<ServerFunctions>;
};
const server: ServerAsync = new Server({
// this is necessary for local development but will be ignored in production
allowedDevelopmentDomains: (origin: string) =>
/https:\/\/.*\.googleusercontent\.com$/.test(origin),
parentTargetOrigin: '*',
});
export default server;
I'd love to find a way to not have to manually add these methods to ServerFunctions
above. Any ideas? I was wondering: if I initially wrote the functions on an object, then I could expose them using typescript, eg:
expost const SheetFunctions = {
setActiveSheet: () => {
// do stuff
}
}
export type ServerFunctions = SheetFunctions;
but then I imagine gas-webpack-plugin
wouldn't be able to automatically export SheetFunctions.setActiveSheet
etc.
I was debugging an issue with comments not being included in the built bundle and ran across
which made me believe that the expected output should not include any top-level comments. However, it seems that it is just an old unused file that either should be updated and used or cleaned up (removed).Hi there,
Thanks for your resource first off.
I'm trying to set it up following the instructions but I am unable to do so as I end up having a compilation error in GAS
I had to modify some things in what you were doing in order to sort out my own way, such as installing .
Mainly I installed it the following way (note I'm using clasp
)
mkdir messing06
cd messing06/
clasp create --title "messing06"
npm init -y
npm install gas-webpack-plugin
npm install webpack-cli
npm install webpack
vim package.json
On there I
"build": "webpack --mode production"
The rest of the files are just as in the example
vim echo.js
module.exports = function(message) {
return message;
}
vim main.js
var echo = require('./echo');
/**
* Return write arguments.
*/
global.echo = echo;
vim webpack.config.json
const GasPlugin = require("gas-webpack-plugin");
module.exports = {
context: __dirname,
entry: "./main.js",
output: {
path: __dirname ,
filename: 'Code.gs'
},
plugins: [
new GasPlugin()
]
}
I proceed to build
npm run build
Which generates the Code.gs
that I end up clasp push
to google
Unfortunatelly I get the aforementioned error when Running it from the Website
Error ReferenceError: module is not defined (anonymous) @ echo:gs.1
Any ideas?
Here you have a sum up of the process. Thank you!!
Hi, I am trying out version 1.2.2 to try to use autoGlobalExportsFiles
and I'm getting an error when I reload my spreadsheet to try my addon:
Google Apps Script: ReferenceError: "global" is not defined. 3317128802-waffle_js_prod_ritzmaestro.js:59
In webpack.config.js I have:
new GasPlugin({
autoGlobalExportsFiles: ['**/*.ts']
}),
You can see code.js
that this creates (that doesn't work for me) and code.js.orig
that was created with my code manually adding functions to global
(this does work)
https://gist.github.com/alexblack/4422e6cd41533948842f8a427a5ba253
Currently only works when mode
is production
. Can we also support mode: develompent
?
Vulnerabilities
DepShield reports that this application's usage of lodash.flattendeep:4.4.0 results in the following vulnerability(s):
Occurrences
lodash.flattendeep:4.4.0 is a transitive dependency introduced by the following direct dependency(s):
• nyc:13.1.0
└─ caching-transform:2.0.0
└─ package-hash:2.0.0
└─ lodash.flattendeep:4.4.0
This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.