@woodsportal/hubspot-kit 1.0.41-dev.1 → 1.0.41-dev.3
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/dist/cli.js +8 -2
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/scripts/audit-tdz-split.mjs +11 -5
- package/scripts/check-cdn-size-regression.mjs +49 -0
- package/scripts/check-hubspot-bundle-size.mjs +18 -4
- package/scripts/generate-cdn-bundle-breakdown.mjs +61 -0
- package/scripts/generate-cdn-manifest.mjs +23 -8
- package/scripts/portal-vite-env.mjs +76 -2
- package/scripts/publish-cdn-github.mjs +51 -14
- package/scripts/refresh-artifact-sizes.mjs +77 -0
- package/scripts/verify-cdn-api-endpoint.mjs +17 -10
- package/scripts/vite/create-dev-server-config.mjs +7 -1
- package/scripts/vite/portal-build-shared.js +62 -2
- package/src/dev-module-config/ui/module-config-overlay-side.ts +13 -3
- package/src/dev-module-config/ui/module-config-toolbar-theme.ts +12 -3
- package/vite/vite.config.cdn-app.mjs +43 -30
- package/vite/vite.config.cdn-audit.mjs +34 -0
- package/vite/vite.config.cdn-esm.mjs +1 -1
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
export type ModuleConfigOverlaySide = 'left' | 'right'
|
|
2
2
|
|
|
3
|
-
const STORAGE_KEY = '
|
|
3
|
+
const STORAGE_KEY = 'wp.d.cfg.side'
|
|
4
|
+
const LEGACY_STORAGE_KEY = 'woodsportal:module-config-overlay-side'
|
|
4
5
|
|
|
5
6
|
export function loadModuleConfigOverlaySide(): ModuleConfigOverlaySide {
|
|
6
7
|
if (typeof window === 'undefined') return 'right'
|
|
7
8
|
try {
|
|
8
|
-
const value =
|
|
9
|
-
|
|
9
|
+
const value =
|
|
10
|
+
window.localStorage.getItem(STORAGE_KEY) ??
|
|
11
|
+
window.localStorage.getItem(LEGACY_STORAGE_KEY)
|
|
12
|
+
if (value === 'left' || value === 'right') {
|
|
13
|
+
if (!window.localStorage.getItem(STORAGE_KEY)) {
|
|
14
|
+
window.localStorage.setItem(STORAGE_KEY, value)
|
|
15
|
+
window.localStorage.removeItem(LEGACY_STORAGE_KEY)
|
|
16
|
+
}
|
|
17
|
+
return value
|
|
18
|
+
}
|
|
19
|
+
return 'right'
|
|
10
20
|
} catch {
|
|
11
21
|
return 'right'
|
|
12
22
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type ModuleConfigToolbarTheme = 'light' | 'dark'
|
|
2
2
|
|
|
3
|
-
const STORAGE_KEY = '
|
|
3
|
+
const STORAGE_KEY = 'wp.d.cfg.theme'
|
|
4
|
+
const LEGACY_STORAGE_KEY = 'woodsportal:module-config-toolbar-theme'
|
|
4
5
|
|
|
5
6
|
export function detectPortalTheme(): ModuleConfigToolbarTheme {
|
|
6
7
|
if (typeof document === 'undefined') return 'light'
|
|
@@ -10,8 +11,16 @@ export function detectPortalTheme(): ModuleConfigToolbarTheme {
|
|
|
10
11
|
export function loadModuleConfigToolbarTheme(): ModuleConfigToolbarTheme {
|
|
11
12
|
if (typeof window === 'undefined') return 'light'
|
|
12
13
|
try {
|
|
13
|
-
const stored =
|
|
14
|
-
|
|
14
|
+
const stored =
|
|
15
|
+
window.localStorage.getItem(STORAGE_KEY) ??
|
|
16
|
+
window.localStorage.getItem(LEGACY_STORAGE_KEY)
|
|
17
|
+
if (stored === 'dark' || stored === 'light') {
|
|
18
|
+
if (!window.localStorage.getItem(STORAGE_KEY)) {
|
|
19
|
+
window.localStorage.setItem(STORAGE_KEY, stored)
|
|
20
|
+
window.localStorage.removeItem(LEGACY_STORAGE_KEY)
|
|
21
|
+
}
|
|
22
|
+
return stored
|
|
23
|
+
}
|
|
15
24
|
} catch {
|
|
16
25
|
// ignore
|
|
17
26
|
}
|
|
@@ -8,37 +8,50 @@ import {
|
|
|
8
8
|
root,
|
|
9
9
|
} from '../scripts/vite/portal-build-shared.js'
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
react: 'WoodsPortalVendor.React',
|
|
13
|
-
'react/jsx-runtime': 'WoodsPortalVendor.jsxRuntime',
|
|
14
|
-
'react/jsx-dev-runtime': 'WoodsPortalVendor.jsxDevRuntime',
|
|
15
|
-
'react-dom': 'WoodsPortalVendor.ReactDOM',
|
|
16
|
-
'react-dom/client': 'WoodsPortalVendor.ReactDOMClient',
|
|
17
|
-
}
|
|
11
|
+
const buildId = portalBuildId()
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
/** Longest-match first — bare `react` must not swallow `react/jsx-runtime`. */
|
|
14
|
+
const reactShimAliases = [
|
|
15
|
+
{ find: 'react/jsx-runtime', replacement: resolve(root, 'src/cdn/shims/react-jsx-runtime.ts') },
|
|
16
|
+
{ find: 'react/jsx-dev-runtime', replacement: resolve(root, 'src/cdn/shims/react-jsx-runtime.ts') },
|
|
17
|
+
{ find: 'react-dom/client', replacement: resolve(root, 'src/cdn/shims/react-dom-client.ts') },
|
|
18
|
+
{ find: 'react-dom', replacement: resolve(root, 'src/cdn/shims/react-dom.ts') },
|
|
19
|
+
{ find: 'react', replacement: resolve(root, 'src/cdn/shims/react.ts') },
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
export default defineConfig(({ mode }) => {
|
|
23
|
+
const baseResolve = portalResolve(mode)
|
|
24
|
+
return {
|
|
25
|
+
// Relative base so dynamic import() resolves lazy chunks from jsDelivr (same dir as app.js), not HubSpot origin.
|
|
26
|
+
base: './',
|
|
27
|
+
// TanStack autoCodeSplitting + ESM CDN entry caused router.init stack overflow on HubSpot.
|
|
28
|
+
// Keep Rollup lazy chunks via React.lazy() / dynamic import(); route modules stay in the app entry.
|
|
29
|
+
plugins: portalPlugins(mode, { codeSplitting: false }),
|
|
30
|
+
resolve: {
|
|
31
|
+
...baseResolve,
|
|
32
|
+
alias: [...reactShimAliases, ...(baseResolve.alias ?? [])],
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
define: portalDefine(mode),
|
|
35
|
+
build: {
|
|
36
|
+
outDir: resolve(root, 'dist/cdn'),
|
|
37
|
+
emptyOutDir: false,
|
|
38
|
+
copyPublicDir: false,
|
|
39
|
+
cssCodeSplit: false,
|
|
40
|
+
rollupOptions: {
|
|
41
|
+
input: resolve(root, 'src/cdn/app-entry.ts'),
|
|
42
|
+
output: {
|
|
43
|
+
format: 'es',
|
|
44
|
+
entryFileNames: `app.${buildId}.js`,
|
|
45
|
+
chunkFileNames: `chunks/[name].${buildId}.[hash].js`,
|
|
46
|
+
assetFileNames: (assetInfo) => {
|
|
47
|
+
if (assetInfo.name?.endsWith('.css')) {
|
|
48
|
+
return `app.${buildId}.css`
|
|
49
|
+
}
|
|
50
|
+
return `assets/[name].[hash][extname]`
|
|
51
|
+
},
|
|
52
|
+
},
|
|
40
53
|
},
|
|
54
|
+
minify: true,
|
|
41
55
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}))
|
|
56
|
+
}
|
|
57
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CDN app bundle audit — rollup visualizer treemap for dist/cdn/app.*.js graph.
|
|
3
|
+
* Usage: yarn vite build --config vite.config.cdn-audit.mjs --mode prod
|
|
4
|
+
*/
|
|
5
|
+
import { defineConfig, mergeConfig } from 'vite'
|
|
6
|
+
import { resolve } from 'node:path'
|
|
7
|
+
import { importConsumerDep } from '../scripts/resolve-consumer-dep.mjs'
|
|
8
|
+
import { root } from '../scripts/vite/portal-build-shared.js'
|
|
9
|
+
import cdnAppConfig from './vite.config.cdn-app.mjs'
|
|
10
|
+
|
|
11
|
+
const { default: visualizer } = await importConsumerDep('rollup-plugin-visualizer')
|
|
12
|
+
|
|
13
|
+
export default defineConfig((env) =>
|
|
14
|
+
mergeConfig(typeof cdnAppConfig === 'function' ? cdnAppConfig(env) : cdnAppConfig, {
|
|
15
|
+
build: {
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
rollupOptions: {
|
|
18
|
+
plugins: [
|
|
19
|
+
visualizer({
|
|
20
|
+
filename: resolve(root, 'docs/audit/cdn-bundle-stats.html'),
|
|
21
|
+
gzipSize: true,
|
|
22
|
+
brotliSize: true,
|
|
23
|
+
template: 'treemap',
|
|
24
|
+
}),
|
|
25
|
+
visualizer({
|
|
26
|
+
filename: resolve(root, 'docs/audit/cdn-bundle-visualizer.json'),
|
|
27
|
+
json: true,
|
|
28
|
+
gzipSize: true,
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
)
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
/** Phase 2: ESM CDN build with route code-splitting (not used for HubSpot module.js). */
|
|
12
12
|
export default defineConfig(({ mode }) => ({
|
|
13
|
-
plugins: portalPlugins(mode, { codeSplitting:
|
|
13
|
+
plugins: portalPlugins(mode, { codeSplitting: false }),
|
|
14
14
|
resolve: portalResolve(mode),
|
|
15
15
|
define: portalDefine(mode),
|
|
16
16
|
build: {
|