@granite-js/rollipop 0.0.0 → 3.0.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/CHANGELOG.md +17 -0
- package/README.md +15 -1
- package/dist/index.cjs +152 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +122 -0
- package/package.json +49 -2
- package/.editorconfig +0 -10
- package/.gitattributes +0 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @granite-js/rollipop
|
|
2
|
+
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @granite-js/config@3.0.1
|
|
8
|
+
|
|
9
|
+
## 3.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- 586459d: Start the Granite v3 release line with Rollipop support and bundler adapters.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- @granite-js/config@3.0.0
|
package/README.md
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
# rollipop
|
|
1
|
+
# @granite-js/rollipop
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
// granite.config.ts
|
|
5
|
+
import { defineConfig } from '@granite-js/react-native/config';
|
|
6
|
+
import { rollipop } from '@granite-js/rollipop';
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
appName: 'my-service',
|
|
10
|
+
scheme: 'granite',
|
|
11
|
+
bundler: rollipop(),
|
|
12
|
+
});
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
See the [Rollipop configuration documentation](https://rollipop.dev/docs/get-started/configuration) for `rollipop.config.ts` options. To load another configuration file, pass `rollipop({ configFile: './custom.rollipop.ts' })`.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
let node_module = require("node:module");
|
|
30
|
+
let node_fs_promises = require("node:fs/promises");
|
|
31
|
+
node_fs_promises = __toESM(node_fs_promises);
|
|
32
|
+
let node_path = require("node:path");
|
|
33
|
+
node_path = __toESM(node_path);
|
|
34
|
+
|
|
35
|
+
//#region src/rollipop.ts
|
|
36
|
+
const require$2 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
37
|
+
function rollipop(options = {}) {
|
|
38
|
+
return {
|
|
39
|
+
name: "rollipop",
|
|
40
|
+
async resetCache() {
|
|
41
|
+
await (await import("rollipop")).resetCache();
|
|
42
|
+
},
|
|
43
|
+
async runBuild(buildOption) {
|
|
44
|
+
const { dev = false, cache = true, platform } = buildOption;
|
|
45
|
+
const context = this.getContext();
|
|
46
|
+
const { bundler, config } = await load(context, options, "build", buildOption);
|
|
47
|
+
const outdir = node_path.resolve(context.cwd, buildOption.outdir ?? options.outdir ?? "dist", buildOption.outdirSuffix ?? "");
|
|
48
|
+
await node_fs_promises.mkdir(outdir, { recursive: true });
|
|
49
|
+
const startedAt = performance.now();
|
|
50
|
+
const outfile = node_path.resolve(outdir, buildOption.outfile ?? `bundle.${platform}.js`);
|
|
51
|
+
const sourcemapOutfile = `${outfile}.map`;
|
|
52
|
+
const chunk = await bundler.runBuild(config, {
|
|
53
|
+
platform,
|
|
54
|
+
dev,
|
|
55
|
+
cache,
|
|
56
|
+
outfile,
|
|
57
|
+
sourcemap: true,
|
|
58
|
+
sourcemapOutfile,
|
|
59
|
+
assetsDir: outdir
|
|
60
|
+
});
|
|
61
|
+
const sourcemap = await node_fs_promises.readFile(sourcemapOutfile, "utf8");
|
|
62
|
+
return {
|
|
63
|
+
bundle: {
|
|
64
|
+
source: outputFile(outfile, chunk.code),
|
|
65
|
+
sourcemap: outputFile(sourcemapOutfile, sourcemap)
|
|
66
|
+
},
|
|
67
|
+
outfile,
|
|
68
|
+
sourcemapOutfile,
|
|
69
|
+
platform,
|
|
70
|
+
extra: buildOption.extra,
|
|
71
|
+
totalModuleCount: chunk.moduleIds.length,
|
|
72
|
+
duration: performance.now() - startedAt,
|
|
73
|
+
size: Buffer.byteLength(chunk.code)
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
async runServer(serverOptions) {
|
|
77
|
+
const { bundler, config } = await load(this.getContext(), options, "serve");
|
|
78
|
+
if (serverOptions.clientLogs !== true) {
|
|
79
|
+
console.log(["Client logs have been disabled.", `To enable client logs, set the '--client-logs' flag when running the dev server.`].join("\n"));
|
|
80
|
+
config.reporter = { update() {} };
|
|
81
|
+
}
|
|
82
|
+
const { host = "localhost", port = 8081 } = serverOptions;
|
|
83
|
+
const server = await bundler.runServer(config, {
|
|
84
|
+
host,
|
|
85
|
+
port,
|
|
86
|
+
buildOptions: { cache: serverOptions.cache }
|
|
87
|
+
});
|
|
88
|
+
try {
|
|
89
|
+
if (serverOptions.interactive !== false) setupInteractiveMode(server, config);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
await server.instance.close();
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
return { close: async () => {
|
|
95
|
+
await server.instance.close();
|
|
96
|
+
} };
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
async function load(context, options, command, buildOption) {
|
|
101
|
+
const bundler = await import("rollipop");
|
|
102
|
+
const config = await bundler.loadConfig({
|
|
103
|
+
cwd: context.cwd,
|
|
104
|
+
configFile: options.configFile,
|
|
105
|
+
mode: command === "serve" || buildOption?.dev ? "development" : "production",
|
|
106
|
+
context: { command: command === "serve" ? "start" : "bundle" }
|
|
107
|
+
});
|
|
108
|
+
config.polyfills = [{
|
|
109
|
+
type: "plain",
|
|
110
|
+
code: `globalThis.__granite = globalThis.__granite || {}; globalThis.__granite.app = ${JSON.stringify({
|
|
111
|
+
name: context.appName,
|
|
112
|
+
scheme: context.scheme,
|
|
113
|
+
host: context.host
|
|
114
|
+
})};`
|
|
115
|
+
}, ...config.polyfills];
|
|
116
|
+
return {
|
|
117
|
+
bundler,
|
|
118
|
+
config
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function outputFile(filePath, text) {
|
|
122
|
+
return {
|
|
123
|
+
path: filePath,
|
|
124
|
+
contents: Buffer.from(text),
|
|
125
|
+
text
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function setupInteractiveMode(server, config) {
|
|
129
|
+
let setup;
|
|
130
|
+
try {
|
|
131
|
+
const entry = node_path.dirname(require$2.resolve("rollipop"));
|
|
132
|
+
setup = require$2(node_path.join(entry, "node/commands/start/setup-interactive-mode")).setupInteractiveMode;
|
|
133
|
+
} catch {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
setup?.({
|
|
137
|
+
devServer: server,
|
|
138
|
+
commands: config.commands
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/index.ts
|
|
144
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
145
|
+
try {
|
|
146
|
+
require$1.resolve("rollipop");
|
|
147
|
+
} catch (error) {
|
|
148
|
+
throw new Error("`@granite-js/rollipop` requires `rollipop` to be installed.", { cause: error });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
//#endregion
|
|
152
|
+
exports.rollipop = rollipop;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BundlerAdapter } from "@granite-js/config";
|
|
2
|
+
|
|
3
|
+
//#region src/rollipop.d.ts
|
|
4
|
+
interface RollipopOptions {
|
|
5
|
+
configFile?: string;
|
|
6
|
+
outdir?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function rollipop(options?: RollipopOptions): BundlerAdapter;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type RollipopOptions, rollipop };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BundlerAdapter } from "@granite-js/config";
|
|
2
|
+
|
|
3
|
+
//#region src/rollipop.d.ts
|
|
4
|
+
interface RollipopOptions {
|
|
5
|
+
configFile?: string;
|
|
6
|
+
outdir?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function rollipop(options?: RollipopOptions): BundlerAdapter;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type RollipopOptions, rollipop };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/rollipop.ts
|
|
6
|
+
const require$1 = createRequire(import.meta.url);
|
|
7
|
+
function rollipop(options = {}) {
|
|
8
|
+
return {
|
|
9
|
+
name: "rollipop",
|
|
10
|
+
async resetCache() {
|
|
11
|
+
await (await import("rollipop")).resetCache();
|
|
12
|
+
},
|
|
13
|
+
async runBuild(buildOption) {
|
|
14
|
+
const { dev = false, cache = true, platform } = buildOption;
|
|
15
|
+
const context = this.getContext();
|
|
16
|
+
const { bundler, config } = await load(context, options, "build", buildOption);
|
|
17
|
+
const outdir = path.resolve(context.cwd, buildOption.outdir ?? options.outdir ?? "dist", buildOption.outdirSuffix ?? "");
|
|
18
|
+
await fs.mkdir(outdir, { recursive: true });
|
|
19
|
+
const startedAt = performance.now();
|
|
20
|
+
const outfile = path.resolve(outdir, buildOption.outfile ?? `bundle.${platform}.js`);
|
|
21
|
+
const sourcemapOutfile = `${outfile}.map`;
|
|
22
|
+
const chunk = await bundler.runBuild(config, {
|
|
23
|
+
platform,
|
|
24
|
+
dev,
|
|
25
|
+
cache,
|
|
26
|
+
outfile,
|
|
27
|
+
sourcemap: true,
|
|
28
|
+
sourcemapOutfile,
|
|
29
|
+
assetsDir: outdir
|
|
30
|
+
});
|
|
31
|
+
const sourcemap = await fs.readFile(sourcemapOutfile, "utf8");
|
|
32
|
+
return {
|
|
33
|
+
bundle: {
|
|
34
|
+
source: outputFile(outfile, chunk.code),
|
|
35
|
+
sourcemap: outputFile(sourcemapOutfile, sourcemap)
|
|
36
|
+
},
|
|
37
|
+
outfile,
|
|
38
|
+
sourcemapOutfile,
|
|
39
|
+
platform,
|
|
40
|
+
extra: buildOption.extra,
|
|
41
|
+
totalModuleCount: chunk.moduleIds.length,
|
|
42
|
+
duration: performance.now() - startedAt,
|
|
43
|
+
size: Buffer.byteLength(chunk.code)
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
async runServer(serverOptions) {
|
|
47
|
+
const { bundler, config } = await load(this.getContext(), options, "serve");
|
|
48
|
+
if (serverOptions.clientLogs !== true) {
|
|
49
|
+
console.log(["Client logs have been disabled.", `To enable client logs, set the '--client-logs' flag when running the dev server.`].join("\n"));
|
|
50
|
+
config.reporter = { update() {} };
|
|
51
|
+
}
|
|
52
|
+
const { host = "localhost", port = 8081 } = serverOptions;
|
|
53
|
+
const server = await bundler.runServer(config, {
|
|
54
|
+
host,
|
|
55
|
+
port,
|
|
56
|
+
buildOptions: { cache: serverOptions.cache }
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
if (serverOptions.interactive !== false) setupInteractiveMode(server, config);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
await server.instance.close();
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
return { close: async () => {
|
|
65
|
+
await server.instance.close();
|
|
66
|
+
} };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async function load(context, options, command, buildOption) {
|
|
71
|
+
const bundler = await import("rollipop");
|
|
72
|
+
const config = await bundler.loadConfig({
|
|
73
|
+
cwd: context.cwd,
|
|
74
|
+
configFile: options.configFile,
|
|
75
|
+
mode: command === "serve" || buildOption?.dev ? "development" : "production",
|
|
76
|
+
context: { command: command === "serve" ? "start" : "bundle" }
|
|
77
|
+
});
|
|
78
|
+
config.polyfills = [{
|
|
79
|
+
type: "plain",
|
|
80
|
+
code: `globalThis.__granite = globalThis.__granite || {}; globalThis.__granite.app = ${JSON.stringify({
|
|
81
|
+
name: context.appName,
|
|
82
|
+
scheme: context.scheme,
|
|
83
|
+
host: context.host
|
|
84
|
+
})};`
|
|
85
|
+
}, ...config.polyfills];
|
|
86
|
+
return {
|
|
87
|
+
bundler,
|
|
88
|
+
config
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function outputFile(filePath, text) {
|
|
92
|
+
return {
|
|
93
|
+
path: filePath,
|
|
94
|
+
contents: Buffer.from(text),
|
|
95
|
+
text
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function setupInteractiveMode(server, config) {
|
|
99
|
+
let setup;
|
|
100
|
+
try {
|
|
101
|
+
const entry = path.dirname(require$1.resolve("rollipop"));
|
|
102
|
+
setup = require$1(path.join(entry, "node/commands/start/setup-interactive-mode")).setupInteractiveMode;
|
|
103
|
+
} catch {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
setup?.({
|
|
107
|
+
devServer: server,
|
|
108
|
+
commands: config.commands
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/index.ts
|
|
114
|
+
const require = createRequire(import.meta.url);
|
|
115
|
+
try {
|
|
116
|
+
require.resolve("rollipop");
|
|
117
|
+
} catch (error) {
|
|
118
|
+
throw new Error("`@granite-js/rollipop` requires `rollipop` to be installed.", { cause: error });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
export { rollipop };
|
package/package.json
CHANGED
|
@@ -1,4 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/rollipop",
|
|
3
|
-
"version": "
|
|
4
|
-
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Rollipop bundler adapter for Granite",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/toss/granite.git",
|
|
13
|
+
"directory": "packages/rollipop"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"require": {
|
|
22
|
+
"types": "./dist/index.d.cts",
|
|
23
|
+
"default": "./dist/index.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsdown",
|
|
33
|
+
"prepack": "yarn build",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"typecheck": "tsc --noEmit"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@granite-js/config": "3.0.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "24.10.12",
|
|
42
|
+
"rollipop": "1.0.0-alpha.32",
|
|
43
|
+
"tsdown": "0.20.3",
|
|
44
|
+
"typescript": "5.9.3",
|
|
45
|
+
"vitest": "^4.0.12"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"rollipop": "^1"
|
|
49
|
+
},
|
|
50
|
+
"sideEffects": false
|
|
51
|
+
}
|
package/.editorconfig
DELETED
package/.gitattributes
DELETED