@olenbetong/appframe-vite 6.4.0 → 6.6.0
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/lib/build.js +13 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +5 -3
- package/package.json +5 -5
package/lib/build.js
CHANGED
|
@@ -25,6 +25,19 @@ export async function addAppframeBuildConfig(config) {
|
|
|
25
25
|
// Cast visualizer plugin to any to avoid Rollup type version clashes
|
|
26
26
|
plugins: [visualizer({ filename: "./dist/stats.html", gzipSize: true })],
|
|
27
27
|
external: appframe.build.externals !== false ? ["react", "react-dom", "react-dom/client"] : [],
|
|
28
|
+
treeshake: {
|
|
29
|
+
/*
|
|
30
|
+
* `@digdir/designsystemet-react` does not declare `sideEffects: false`, so the
|
|
31
|
+
* bundler has to assume every module reached through its barrel is needed and
|
|
32
|
+
* ships all ~140 components (Combobox, Table, Suggestion, …) even when an app
|
|
33
|
+
* renders a handful. None of its modules have import-time side effects, so opt
|
|
34
|
+
* them in to tree shaking explicitly.
|
|
35
|
+
*
|
|
36
|
+
* Deliberately scoped to `designsystemet-react`: `designsystemet-web` registers
|
|
37
|
+
* custom elements on import and must keep its side effects.
|
|
38
|
+
*/
|
|
39
|
+
moduleSideEffects: (id) => !/[\\/]node_modules[\\/].*designsystemet-react[\\/]/.test(id.replace(/\?.*$/, "")),
|
|
40
|
+
},
|
|
28
41
|
output: {
|
|
29
42
|
globals: appframe.build.externals !== false
|
|
30
43
|
? {
|
package/lib/index.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ export interface AppframePluginOptions {
|
|
|
11
11
|
* @default true
|
|
12
12
|
*/
|
|
13
13
|
generateTypes?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to enable the Appframe devtools panel and toolbar in dev mode.
|
|
16
|
+
* Set to `false` to skip serving the devtools app and injecting the toolbar
|
|
17
|
+
* script (e.g. when running Storybook).
|
|
18
|
+
*
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
devtools?: boolean;
|
|
14
22
|
}
|
|
15
23
|
export default function appframe(options?: AppframePluginOptions): Plugin[];
|
|
16
24
|
export { addAppframeBuildConfig, createDevMiddleware, publishSafeOutput };
|
package/lib/index.js
CHANGED
|
@@ -34,7 +34,7 @@ catch (error) {
|
|
|
34
34
|
}
|
|
35
35
|
const jsonParser = bodyParser.json();
|
|
36
36
|
export default function appframe(options = {}) {
|
|
37
|
-
let { generateTypes = true } = options;
|
|
37
|
+
let { generateTypes = true, devtools = true } = options;
|
|
38
38
|
let plugin = {
|
|
39
39
|
name: "appframe",
|
|
40
40
|
resolveId(source) {
|
|
@@ -179,7 +179,9 @@ export default function appframe(options = {}) {
|
|
|
179
179
|
}, 300);
|
|
180
180
|
});
|
|
181
181
|
// DevTools panel: serve the devtools app + REST API at /__appframe_devtools__/
|
|
182
|
-
|
|
182
|
+
if (devtools) {
|
|
183
|
+
_server.middlewares.use("/__appframe_devtools__", createDevtoolsMiddleware(hostname));
|
|
184
|
+
}
|
|
183
185
|
_server.middlewares.use(`/api/user/localize/new/${appframe.article.id}`, jsonParser);
|
|
184
186
|
_server.middlewares.use(`/api/user/localize/new/${appframe.article.id}`, localizeMiddleware);
|
|
185
187
|
_server.middlewares.use("/data/Logger/LogError", jsonParser);
|
|
@@ -198,7 +200,7 @@ export default function appframe(options = {}) {
|
|
|
198
200
|
},
|
|
199
201
|
transformIndexHtml(_html, ctx) {
|
|
200
202
|
// Only inject the toolbar in dev mode
|
|
201
|
-
if (command !== "serve")
|
|
203
|
+
if (command !== "serve" || !devtools)
|
|
202
204
|
return;
|
|
203
205
|
// Only inject for article pages (not the devtools app itself)
|
|
204
206
|
if (ctx.originalUrl?.startsWith("/__appframe_devtools__"))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/appframe-vite",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "Tools to use and deploy Vite applications to Appframe",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,23 +31,23 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@olenbetong/appframe-data": "1.5.0",
|
|
33
33
|
"body-parser": "^2.3.0",
|
|
34
|
-
"chalk": "
|
|
34
|
+
"chalk": "6.0.0",
|
|
35
35
|
"chokidar": "^5.0.0",
|
|
36
36
|
"commander": "15.0.0",
|
|
37
37
|
"dotenv": "^17.4.2",
|
|
38
38
|
"fuzzy": "^0.1.3",
|
|
39
39
|
"inquirer": "^14.0.2",
|
|
40
40
|
"inquirer-autocomplete-standalone": "^0.8.1",
|
|
41
|
-
"jsdom": "
|
|
41
|
+
"jsdom": "30.0.1",
|
|
42
42
|
"rollup-plugin-visualizer": "^7.0.1",
|
|
43
43
|
"yaml": "^2.9.0",
|
|
44
44
|
"@olenbetong/appframe-devtools": "0.3.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/jsdom": "^27.0.0",
|
|
48
|
-
"@types/node": "26.
|
|
48
|
+
"@types/node": "26.2.0",
|
|
49
49
|
"typescript": "7.0.2",
|
|
50
|
-
"vite": "8.1
|
|
50
|
+
"vite": "8.2.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"vite": ">=8.1.5"
|