vite-plugin-gas-hoist 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +20 -18
- package/README.md +20 -18
- package/package.json +18 -8
package/README.ja.md
CHANGED
|
@@ -24,7 +24,9 @@ GAS 向けに Vite でバンドルするときは、複数モジュールを 1
|
|
|
24
24
|
export const sayHello = (name) => `Hello, ${name}!`;
|
|
25
25
|
|
|
26
26
|
// ビルド後
|
|
27
|
-
var lib_ = (function()
|
|
27
|
+
var lib_ = (function () {
|
|
28
|
+
/* バンドルされた sayHello を含む IIFE */
|
|
29
|
+
})({});
|
|
28
30
|
const sayHello = (...args) => lib_.sayHello(...args); // プラグインが追加
|
|
29
31
|
```
|
|
30
32
|
|
|
@@ -42,15 +44,15 @@ import { defineConfig } from 'vite';
|
|
|
42
44
|
import { vitePluginGasHoist } from 'vite-plugin-gas-hoist';
|
|
43
45
|
|
|
44
46
|
export default defineConfig({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
plugins: [vitePluginGasHoist()],
|
|
48
|
+
build: {
|
|
49
|
+
lib: {
|
|
50
|
+
entry: 'src/main.js',
|
|
51
|
+
formats: ['iife'],
|
|
52
|
+
name: 'lib_',
|
|
53
|
+
fileName: (_, entryName) => `${entryName}.js`,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
54
56
|
});
|
|
55
57
|
```
|
|
56
58
|
|
|
@@ -65,14 +67,14 @@ GAS でグローバルに公開するときの目的は、大きく 2 つに分
|
|
|
65
67
|
|
|
66
68
|
ESM の宣言種別(`function` / `const` / `let` / `var`)と右辺の形をそのまま保つことで、この 2 つの公開を組み合わせて表現できます。GAS のライブラリ可視性ルール(`function` / `var` は外部公開、`const` / `let` は非公開)がそのまま反映される挙動です。
|
|
67
69
|
|
|
68
|
-
| ESM 宣言
|
|
69
|
-
|
|
70
|
-
| `export function foo() {}`
|
|
71
|
-
| `export const FOO = 42`
|
|
72
|
-
| `export const foo = (x) => x`
|
|
73
|
-
| `export const foo = function(x){...}` | `const foo = function(...args){return lib_.foo(...args)}` | 非公開(同上)
|
|
74
|
-
| `export let foo = ...`
|
|
75
|
-
| `export var foo = ...`
|
|
70
|
+
| ESM 宣言 | 出力 | GAS ライブラリ可視性 |
|
|
71
|
+
| ------------------------------------- | --------------------------------------------------------- | ------------------------------------------------ |
|
|
72
|
+
| `export function foo() {}` | `function foo(...args){return lib_.foo(...args)}` | 公開 |
|
|
73
|
+
| `export const FOO = 42` | `const FOO = lib_.FOO` | 非公開 |
|
|
74
|
+
| `export const foo = (x) => x` | `const foo = (...args) => lib_.foo(...args)` | 非公開(エディタの "実行" ドロップダウンに表示) |
|
|
75
|
+
| `export const foo = function(x){...}` | `const foo = function(...args){return lib_.foo(...args)}` | 非公開(同上) |
|
|
76
|
+
| `export let foo = ...` | `let foo = ...`(右辺は const と同形) | 非公開 |
|
|
77
|
+
| `export var foo = ...` | `var foo = ...`(右辺は const と同形) | 公開 |
|
|
76
78
|
|
|
77
79
|
`export { foo }` や `export { foo as bar }` のような specifier 形式の再エクスポートも、ローカル宣言の種別を引き継ぎます。表に当てはまらないパターン(`export default` や `export class`、宣言種別を判定できない再エクスポートなど)はビルド時に警告を出してスキップします。
|
|
78
80
|
|
package/README.md
CHANGED
|
@@ -24,7 +24,9 @@ The catch: that also hides everything you actually want to expose — both funct
|
|
|
24
24
|
export const sayHello = (name) => `Hello, ${name}!`;
|
|
25
25
|
|
|
26
26
|
// After build
|
|
27
|
-
var lib_ = (function()
|
|
27
|
+
var lib_ = (function () {
|
|
28
|
+
/* IIFE bundle containing sayHello */
|
|
29
|
+
})({});
|
|
28
30
|
const sayHello = (...args) => lib_.sayHello(...args); // added by the plugin
|
|
29
31
|
```
|
|
30
32
|
|
|
@@ -42,15 +44,15 @@ import { defineConfig } from 'vite';
|
|
|
42
44
|
import { vitePluginGasHoist } from 'vite-plugin-gas-hoist';
|
|
43
45
|
|
|
44
46
|
export default defineConfig({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
plugins: [vitePluginGasHoist()],
|
|
48
|
+
build: {
|
|
49
|
+
lib: {
|
|
50
|
+
entry: 'src/main.js',
|
|
51
|
+
formats: ['iife'],
|
|
52
|
+
name: 'lib_',
|
|
53
|
+
fileName: (_, entryName) => `${entryName}.js`,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
54
56
|
});
|
|
55
57
|
```
|
|
56
58
|
|
|
@@ -65,14 +67,14 @@ Exposing something globally in GAS serves one of two purposes:
|
|
|
65
67
|
|
|
66
68
|
By preserving the original ESM declaration kind (`function` / `const` / `let` / `var`) and the right-hand-side shape, the plugin lets you express both axes naturally. GAS's library visibility rules apply directly: `function` and `var` are externally visible, `const` and `let` are not.
|
|
67
69
|
|
|
68
|
-
| ESM declaration
|
|
69
|
-
|
|
70
|
-
| `export function foo() {}`
|
|
71
|
-
| `export const FOO = 42`
|
|
72
|
-
| `export const foo = (x) => x`
|
|
73
|
-
| `export const foo = function(x){...}` | `const foo = function(...args){return lib_.foo(...args)}` | internal only (same)
|
|
74
|
-
| `export let foo = ...`
|
|
75
|
-
| `export var foo = ...`
|
|
70
|
+
| ESM declaration | Output | GAS library visibility |
|
|
71
|
+
| ------------------------------------- | --------------------------------------------------------- | ------------------------------------------------------ |
|
|
72
|
+
| `export function foo() {}` | `function foo(...args){return lib_.foo(...args)}` | external |
|
|
73
|
+
| `export const FOO = 42` | `const FOO = lib_.FOO` | internal only |
|
|
74
|
+
| `export const foo = (x) => x` | `const foo = (...args) => lib_.foo(...args)` | internal only (appears in the editor's "Run" dropdown) |
|
|
75
|
+
| `export const foo = function(x){...}` | `const foo = function(...args){return lib_.foo(...args)}` | internal only (same) |
|
|
76
|
+
| `export let foo = ...` | `let foo = ...` (right-hand side as above) | internal only |
|
|
77
|
+
| `export var foo = ...` | `var foo = ...` (right-hand side as above) | external |
|
|
76
78
|
|
|
77
79
|
Specifier-form re-exports like `export { foo }` and `export { foo as bar }` inherit the kind of the local declaration. Patterns not covered above (`export default`, `export class`, re-exports whose kind cannot be determined, etc.) are skipped with a build-time warning.
|
|
78
80
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-gas-hoist",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A Vite plugin that hoists entry point exports to the global scope for Google Apps Script",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite-plugin",
|
|
@@ -23,6 +23,21 @@
|
|
|
23
23
|
"files": [
|
|
24
24
|
"src"
|
|
25
25
|
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22"
|
|
28
|
+
},
|
|
29
|
+
"devEngines": {
|
|
30
|
+
"runtime": {
|
|
31
|
+
"name": "node",
|
|
32
|
+
"version": "^22 || ^24 || >=26",
|
|
33
|
+
"onFail": "error"
|
|
34
|
+
},
|
|
35
|
+
"packageManager": {
|
|
36
|
+
"name": "pnpm",
|
|
37
|
+
"version": "12",
|
|
38
|
+
"onFail": "error"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
26
41
|
"compatiblePackages": {
|
|
27
42
|
"schemaVersion": 1,
|
|
28
43
|
"rollup": {
|
|
@@ -38,19 +53,14 @@
|
|
|
38
53
|
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
39
54
|
},
|
|
40
55
|
"devDependencies": {
|
|
41
|
-
"@biomejs/biome": "^2.
|
|
56
|
+
"@biomejs/biome": "^2.6.8",
|
|
42
57
|
"acorn": "^8.16.0",
|
|
43
58
|
"vite": "^8.0.3",
|
|
44
|
-
"vitest": "^
|
|
45
|
-
},
|
|
46
|
-
"volta": {
|
|
47
|
-
"node": "22.21.1",
|
|
48
|
-
"pnpm": "10.23.0"
|
|
59
|
+
"vitest": "^5.1.1"
|
|
49
60
|
},
|
|
50
61
|
"scripts": {
|
|
51
62
|
"test": "vitest run",
|
|
52
63
|
"lint": "biome check --write",
|
|
53
|
-
"lint:ci": "biome check",
|
|
54
64
|
"example:dev": "cd example && npm run dev",
|
|
55
65
|
"example:build": "cd example && npm run build",
|
|
56
66
|
"example:login": "pnpx @google/clasp@2.5 login",
|