svelte-bundle 0.0.1 → 0.0.12
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/bundle.js +9 -3
- package/cli.js +12 -3
- package/package.json +23 -4
package/bundle.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
// bundle.js
|
|
1
2
|
import fs from 'fs/promises';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
import { rollup } from 'rollup';
|
|
4
5
|
import svelte from 'rollup-plugin-svelte';
|
|
5
6
|
import resolve from '@rollup/plugin-node-resolve';
|
|
6
7
|
import commonjs from '@rollup/plugin-commonjs';
|
|
7
|
-
import { compile } from 'svelte/compiler';
|
|
8
8
|
import css from 'rollup-plugin-css-only';
|
|
9
9
|
import terser from '@rollup/plugin-terser';
|
|
10
10
|
|
|
@@ -54,7 +54,7 @@ export async function buildStaticFile(svelteFilePath, outputDir) {
|
|
|
54
54
|
const { default: App } = await import(tempSSRFile);
|
|
55
55
|
const { html: initialHtml } = App.render();
|
|
56
56
|
|
|
57
|
-
// Clean up temp
|
|
57
|
+
// Clean up temp files
|
|
58
58
|
await fs.rm(tempDir, { recursive: true, force: true });
|
|
59
59
|
|
|
60
60
|
// Build client-side bundle
|
|
@@ -103,17 +103,23 @@ export async function buildStaticFile(svelteFilePath, outputDir) {
|
|
|
103
103
|
</head>
|
|
104
104
|
<body>
|
|
105
105
|
<div id="app">${initialHtml}</div>
|
|
106
|
+
<script src="https://unpkg.com/svelte@3.58.0/internal/index.js"></script>
|
|
106
107
|
<script>
|
|
107
108
|
${clientCode}
|
|
108
|
-
const app = new App({
|
|
109
|
+
const app = new App({
|
|
110
|
+
target: document.getElementById('app'),
|
|
111
|
+
hydrate: true
|
|
112
|
+
});
|
|
109
113
|
</script>
|
|
110
114
|
</body>
|
|
111
115
|
</html>`;
|
|
112
116
|
|
|
113
117
|
// Write the output file
|
|
114
118
|
const outputPath = path.join(outputDir, 'output.html');
|
|
119
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
115
120
|
await fs.writeFile(outputPath, finalHtml, 'utf-8');
|
|
116
121
|
} catch (error) {
|
|
122
|
+
console.error('Build error:', error);
|
|
117
123
|
throw error;
|
|
118
124
|
}
|
|
119
125
|
}
|
package/cli.js
CHANGED
|
@@ -7,9 +7,18 @@ import { createInterface } from 'readline';
|
|
|
7
7
|
import { buildStaticFile } from './bundle.js';
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
9
9
|
|
|
10
|
+
// Get package.json data
|
|
11
|
+
import { readFile } from 'fs/promises';
|
|
10
12
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
13
|
const __dirname = path.dirname(__filename);
|
|
12
14
|
|
|
15
|
+
// Read package.json
|
|
16
|
+
const packageJson = JSON.parse(
|
|
17
|
+
await readFile(
|
|
18
|
+
new URL('./package.json', import.meta.url)
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
|
|
13
22
|
// Create readline interface for prompts
|
|
14
23
|
const rl = createInterface({
|
|
15
24
|
input: process.stdin,
|
|
@@ -21,8 +30,8 @@ const question = (query) => new Promise((resolve) => rl.question(query, resolve)
|
|
|
21
30
|
|
|
22
31
|
program
|
|
23
32
|
.name('svelte-bundle')
|
|
24
|
-
.description(
|
|
25
|
-
.version(
|
|
33
|
+
.description(packageJson.description)
|
|
34
|
+
.version(packageJson.version)
|
|
26
35
|
.requiredOption('-i, --input <path>', 'Input Svelte file')
|
|
27
36
|
.option('-o, --output <path>', 'Output directory (defaults to current directory)')
|
|
28
37
|
.option('-f, --force', 'Force overwrite without asking');
|
|
@@ -87,7 +96,7 @@ async function validateAndProcess() {
|
|
|
87
96
|
}
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
console.log(chalk.blue(
|
|
99
|
+
console.log(chalk.blue(`Starting ${packageJson.name} v${packageJson.version} build process...`));
|
|
91
100
|
console.log(chalk.gray(`Input: ${inputPath}`));
|
|
92
101
|
console.log(chalk.gray(`Output: ${outputPath}`));
|
|
93
102
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-bundle",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Bundle Svelte files into static HTML files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,10 +18,18 @@
|
|
|
18
18
|
"ssr"
|
|
19
19
|
],
|
|
20
20
|
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
21
|
+
"access": "public",
|
|
22
|
+
"registry": "https://registry.npmjs.org/"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/uhteddy/svelte-bundle.git"
|
|
22
27
|
},
|
|
23
28
|
"scripts": {
|
|
24
|
-
"prepublishOnly": "chmod +x cli.js"
|
|
29
|
+
"prepublishOnly": "chmod +x cli.js",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest",
|
|
32
|
+
"test:coverage": "vitest run --coverage"
|
|
25
33
|
},
|
|
26
34
|
"author": "Teddy Hartling",
|
|
27
35
|
"license": "MIT",
|
|
@@ -35,5 +43,16 @@
|
|
|
35
43
|
"rollup-plugin-css-only": "^4.3.0",
|
|
36
44
|
"rollup-plugin-svelte": "^7.1.4",
|
|
37
45
|
"svelte": "^3.58.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@vitest/coverage-v8": "^2.1.3",
|
|
49
|
+
"vitest": "^2.1.3"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/uhteddy/svelte-bundle/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/uhteddy/svelte-bundle#readme",
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=18"
|
|
38
57
|
}
|
|
39
|
-
}
|
|
58
|
+
}
|