jiek 2.3.2 → 2.3.4

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.
Files changed (81) hide show
  1. package/dist/.internal/.chunks/{filterSupport.4rM7f6jB.cjs → getWD.Bdo2NGCR.cjs} +30 -30
  2. package/dist/.internal/.chunks/{filterSupport.BXWpLBpT.js → getWD.DGvwAHMY.js} +29 -29
  3. package/dist/.internal/.chunks/{loadConfig.OOKddvHF.cjs → loadConfig.8xhNFEJe.cjs} +30 -12
  4. package/dist/.internal/.chunks/{loadConfig.CFfzkm_p.js → loadConfig.BjzxLOdC.js} +26 -9
  5. package/dist/.internal/bin/common.cjs +92 -97
  6. package/dist/.internal/bin/common.d.cts +2 -0
  7. package/dist/.internal/bin/common.d.ts +2 -0
  8. package/dist/.internal/bin/common.js +93 -98
  9. package/dist/.internal/bin/parseArgv.cjs +2 -2
  10. package/dist/.internal/bin/parseArgv.js +2 -2
  11. package/dist/.internal/commands/utils/createAreaManagement.cjs +108 -0
  12. package/dist/.internal/commands/utils/createAreaManagement.d.cts +18 -0
  13. package/dist/.internal/commands/utils/createAreaManagement.d.ts +18 -0
  14. package/dist/.internal/commands/utils/createAreaManagement.js +106 -0
  15. package/dist/.internal/polyfill.cjs +13 -0
  16. package/dist/.internal/polyfill.d.cts +1 -0
  17. package/dist/.internal/polyfill.d.ts +1 -0
  18. package/dist/.internal/polyfill.js +11 -0
  19. package/dist/.internal/rollup/base.d.cts +27 -4
  20. package/dist/.internal/rollup/base.d.ts +27 -4
  21. package/dist/.internal/utils/filterSupport.cjs +1 -1
  22. package/dist/.internal/utils/filterSupport.js +2 -2
  23. package/dist/.internal/utils/loadConfig.cjs +3 -3
  24. package/dist/.internal/utils/loadConfig.d.cts +1 -0
  25. package/dist/.internal/utils/loadConfig.d.ts +1 -0
  26. package/dist/.internal/utils/loadConfig.js +4 -4
  27. package/dist/.internal/utils/pascalCase.cjs +5 -0
  28. package/dist/.internal/utils/pascalCase.d.cts +3 -0
  29. package/dist/.internal/utils/pascalCase.d.ts +3 -0
  30. package/dist/.internal/utils/pascalCase.js +3 -0
  31. package/dist/.internal/utils/reveal.cjs +9 -0
  32. package/dist/.internal/utils/reveal.d.cts +3 -0
  33. package/dist/.internal/utils/reveal.d.ts +3 -0
  34. package/dist/.internal/utils/reveal.js +7 -0
  35. package/dist/bin/index.cjs +101 -43
  36. package/dist/index.d.cts +7 -0
  37. package/dist/index.d.ts +7 -0
  38. package/dist/rollup/index.cjs +91 -31
  39. package/dist/rollup/index.js +90 -30
  40. package/package.json +6 -2
  41. package/src/bin/build.cts +0 -5
  42. package/src/bin/common.ts +0 -3
  43. package/src/bin/index.cts +0 -7
  44. package/src/bin/parseArgv.ts +0 -26
  45. package/src/bridge.ts +0 -46
  46. package/src/commands/base.ts +0 -18
  47. package/src/commands/build/analyzer.ts +0 -122
  48. package/src/commands/build/client/analyzer.tsx +0 -121
  49. package/src/commands/build/client/index.ts +0 -26
  50. package/src/commands/build.ts +0 -544
  51. package/src/commands/descriptions.ts +0 -17
  52. package/src/commands/meta.ts +0 -5
  53. package/src/commands/publish.ts +0 -628
  54. package/src/commands/utils/optionParser.ts +0 -4
  55. package/src/index.ts +0 -12
  56. package/src/inner.ts +0 -11
  57. package/src/rollup/base.ts +0 -151
  58. package/src/rollup/bundle-analyzer.ts +0 -62
  59. package/src/rollup/index.ts +0 -892
  60. package/src/rollup/plugins/create-require.ts +0 -23
  61. package/src/rollup/plugins/progress.ts +0 -26
  62. package/src/rollup/plugins/replace.ts +0 -96
  63. package/src/rollup/plugins/skip.ts +0 -21
  64. package/src/rollup/plugins/with-external.ts +0 -23
  65. package/src/rollup/utils/commonOptions.ts +0 -9
  66. package/src/rollup/utils/externalResolver.ts +0 -47
  67. package/src/rollup/utils/globalResolver.ts +0 -13
  68. package/src/rollup/utils/withMinify.ts +0 -18
  69. package/src/rollup-plugin-utils.ts +0 -32
  70. package/src/server.ts +0 -30
  71. package/src/utils/checkDependency.ts +0 -26
  72. package/src/utils/filterSupport.ts +0 -90
  73. package/src/utils/getInternalModuleName.ts +0 -5
  74. package/src/utils/getRoot.ts +0 -14
  75. package/src/utils/getWD.ts +0 -31
  76. package/src/utils/intersection.ts +0 -1
  77. package/src/utils/loadConfig.ts +0 -108
  78. package/src/utils/recursiveListFiles.ts +0 -13
  79. package/src/utils/resolveExports.ts +0 -165
  80. package/src/utils/ts.ts +0 -94
  81. package/src/utils/tsRegister.ts +0 -22
package/src/bin/index.cts DELETED
@@ -1,7 +0,0 @@
1
- import '#~/bin/common'
2
-
3
- import '../commands/publish'
4
-
5
- import parseArgv from '#~/bin/parseArgv'
6
-
7
- parseArgv()
@@ -1,26 +0,0 @@
1
- import { program } from 'commander'
2
- import process from 'node:process'
3
-
4
- const { argv } = process
5
- const env: Record<string, string> = {}
6
- let isPassThrough = false
7
- const newArgv = argv.filter((arg) => {
8
- if (isPassThrough) {
9
- return true
10
- }
11
- if (arg === '--') {
12
- isPassThrough = true
13
- return false
14
- }
15
- const m = /^--env\.(\w+)=(.*)$/.exec(arg)
16
- if (m) {
17
- env[m[1]] = m[2]
18
- return false
19
- }
20
- return true
21
- })
22
- for (const [key, value] of Object.entries(env)) {
23
- process.env[key] = value
24
- }
25
-
26
- export default () => program.parse(newArgv)
package/src/bridge.ts DELETED
@@ -1,46 +0,0 @@
1
- import type { Module } from '#~/rollup/bundle-analyzer'
2
-
3
- import { sendMessage } from 'execa'
4
-
5
- export const bridgeDisabledRef = { value: false }
6
-
7
- export interface RollupBuildEntryCtx {
8
- type: 'esm' | 'cjs'
9
- name: string
10
- path: string
11
- exportConditions: string[]
12
- input: string
13
- }
14
-
15
- export interface RollupBuildEventMap {
16
- init: {
17
- leafMap: Map<string, string[][]>
18
- targetsLength: number
19
- }
20
- progress: RollupBuildEntryCtx & {
21
- tags?: string[]
22
- event?: string
23
- message?: string
24
- }
25
- watchChange: RollupBuildEntryCtx & {
26
- id: string
27
- }
28
- modulesAnalyze: RollupBuildEntryCtx & {
29
- modules: Module[]
30
- }
31
- debug: unknown
32
- }
33
-
34
- export type RollupBuildEvent = keyof RollupBuildEventMap extends infer K
35
- ? K extends infer Item extends keyof RollupBuildEventMap ? {
36
- type: Item
37
- data: RollupBuildEventMap[Item]
38
- }
39
- : never
40
- : never
41
-
42
- export const publish = async <K extends keyof RollupBuildEventMap>(type: K, data: RollupBuildEventMap[K]) => {
43
- if (bridgeDisabledRef.value) return Promise.resolve()
44
-
45
- return sendMessage({ type, data })
46
- }
@@ -1,18 +0,0 @@
1
- import { program } from 'commander'
2
- import pkg from 'jiek/package.json'
3
-
4
- import { filterDescription } from '#~/commands/descriptions'
5
- import { IS_WORKSPACE } from '#~/commands/meta'
6
- import { type } from '#~/utils/filterSupport'
7
-
8
- program
9
- .name('jk/jiek')
10
- .version(pkg.version)
11
- .description(`${pkg.description} - Version ${pkg.version}`)
12
- .option('-c, --config-path <configPath>', 'Custom jiek config path')
13
- .option('--env.<name>=<value>', 'Set the environment variable.')
14
-
15
- if (type !== '' && IS_WORKSPACE) {
16
- program
17
- .option('-f, --filter <filter>', filterDescription)
18
- }
@@ -1,122 +0,0 @@
1
- import type { Command } from 'commander'
2
-
3
- import { CLIENT_CUSTOM_RENDER_SCRIPT } from '#~/commands/build/client/index'
4
- import { parseBoolean } from '#~/commands/utils/optionParser'
5
- import type { Module } from '#~/rollup/bundle-analyzer'
6
- import type { createServer } from '#~/server'
7
- import { checkDependency } from '#~/utils/checkDependency'
8
- import { existsSync, mkdirSync, statSync, writeFileSync } from 'node:fs'
9
- import path from 'node:path'
10
-
11
- export interface AnalyzerBuildOptions {
12
- ana?: boolean
13
- /**
14
- * @default '.jk-analyses'
15
- */
16
- 'ana.dir': string
17
- /**
18
- * @default 'server'
19
- */
20
- 'ana.mode': string
21
- 'ana.open'?: boolean
22
- /**
23
- * @default 'parsed'
24
- */
25
- 'ana.size': string
26
- }
27
-
28
- export const registerAnalyzerCommandOptions = (command: Command) =>
29
- command
30
- .option('--ana', 'Enable the bundle analyzer.', parseBoolean)
31
- .option('--ana.dir <DIR>', 'The directory of the bundle analyzer.', '.jk-analyses')
32
- .option(
33
- '--ana.mode <MODE>',
34
- 'The mode of the bundle analyzer, support "static", "json" and "server".',
35
- 'server'
36
- )
37
- .option('--ana.open', 'Open the bundle analyzer in the browser.', parseBoolean)
38
- .option(
39
- '--ana.size <SIZE>',
40
- 'The default size of the bundle analyzer, support "stat", "parsed" and "gzip".',
41
- 'parsed'
42
- )
43
-
44
- export const useAnalyzer = async (options: AnalyzerBuildOptions, server?: ReturnType<typeof createServer>) => {
45
- const modules: Module[] = []
46
- let bundleAnalyzerModule: typeof import('vite-bundle-analyzer') | undefined
47
- const analyzer = options.ana
48
- ? {
49
- dir: options['ana.dir'],
50
- mode: options['ana.mode'],
51
- open: options['ana.open'],
52
- size: options['ana.size']
53
- }
54
- : undefined
55
- if (
56
- options.ana
57
- && ![
58
- 'stat',
59
- 'parsed',
60
- 'gzip'
61
- ].includes(analyzer?.size ?? '')
62
- ) {
63
- throw new Error('The value of `ana.size` must be "stat", "parsed" or "gzip"')
64
- }
65
-
66
- if (analyzer) {
67
- await checkDependency('vite-bundle-analyzer')
68
- bundleAnalyzerModule = await import('vite-bundle-analyzer')
69
- }
70
-
71
- const refreshAnalyzer = async (cwd: string, applyModules: typeof modules) => {
72
- if (!(analyzer && server && bundleAnalyzerModule)) return
73
-
74
- if (analyzer.mode === 'json') {
75
- const anaDir = path.resolve(cwd, analyzer.dir)
76
- if (!existsSync(anaDir)) {
77
- mkdirSync(anaDir, { recursive: true })
78
- }
79
- const gitIgnorePath = path.resolve(anaDir, '.gitignore')
80
- if (!existsSync(gitIgnorePath)) {
81
- writeFileSync(gitIgnorePath, '*\n!.gitignore\n')
82
- }
83
- const npmIgnorePath = path.resolve(anaDir, '.npmignore')
84
- if (!existsSync(npmIgnorePath)) {
85
- writeFileSync(npmIgnorePath, '*\n')
86
- }
87
- if (!statSync(anaDir).isDirectory()) {
88
- throw new Error(`The directory '${anaDir}' is not a directory.`)
89
- }
90
- }
91
-
92
- const { renderView, injectHTMLTag } = bundleAnalyzerModule
93
- applyModules.forEach(m => {
94
- const index = modules.findIndex(({ filename }) => filename === m.filename)
95
- if (index === -1) {
96
- modules.push(m)
97
- } else {
98
- modules[index] = m
99
- }
100
- })
101
- let html = await renderView(modules, {
102
- title: `Jiek Analyzer`,
103
- mode: analyzer.size as 'stat' | 'parsed' | 'gzip'
104
- })
105
- html = injectHTMLTag({
106
- html,
107
- injectTo: 'body',
108
- descriptors: [
109
- { kind: 'script', text: CLIENT_CUSTOM_RENDER_SCRIPT }
110
- ]
111
- })
112
- void server.renderTo('/ana', html)
113
- }
114
-
115
- return {
116
- modules,
117
- refreshAnalyzer,
118
- ANALYZER_ENV: {
119
- JIEK_ANALYZER: analyzer ? JSON.stringify(analyzer) : undefined
120
- }
121
- }
122
- }
@@ -1,121 +0,0 @@
1
- import type { Module } from '#~/rollup/bundle-analyzer'
2
-
3
- interface Node {
4
- id: string
5
- filename: string
6
- parent?: Node
7
- }
8
-
9
- declare global {
10
- // @ts-ignore
11
- // eslint-disable-next-line no-var,vars-on-top
12
- var React: typeof import('react')
13
- // eslint-disable-next-line no-var,vars-on-top
14
- var analyzeModule: Module[]
15
- interface WindowEventMap {
16
- 'graph:click': CustomEvent<
17
- | undefined
18
- | { node: Node }
19
- >
20
- 'send:filter': CustomEvent<{
21
- analyzeModule: Module[]
22
- }>
23
- }
24
- }
25
-
26
- export function Main() {
27
- const { useState, useMemo, useEffect, useCallback } = React
28
- const [path, setPath] = useState(() => location.pathname.replace(/^\/ana\/?/, ''))
29
- const [pkgName, entry] = useMemo(() => {
30
- const pkgName = /^(@[^/]+\/[^/]+|[^/]+)\/?/.exec(path)?.[1]
31
- return [
32
- pkgName,
33
- (pkgName != null) ? path.replace(`${pkgName}/`, '') : undefined
34
- ]
35
- }, [path])
36
- const push = useCallback((newPath: string) => {
37
- setPath(newPath)
38
- document.title = `${document.title.replace(/ - \/.*/, '')} - \/${newPath}`
39
- history.pushState(null, '', `/ana/${newPath}`)
40
- }, [])
41
- const filterModules = useCallback((startWith: string) => {
42
- const modules = analyzeModule.filter(m => m.filename.startsWith(startWith))
43
- dispatchEvent(new CustomEvent('send:filter', { detail: { analyzeModule: modules } }))
44
- }, [])
45
- useEffect(() => {
46
- if (path !== '') {
47
- document.title = `${document.title.replace(/ - \/.*/, '')} - \/${path}`
48
- } else {
49
- document.title = document.title.replace(/ - \/.*/, '')
50
- }
51
- filterModules(path)
52
- }, [path, filterModules])
53
- useEffect(() => {
54
- const offGraphClick = listen('graph:click', ({ detail }) => {
55
- if (!detail) return
56
-
57
- let root = detail.node
58
- while (root.parent) {
59
- root = root.parent
60
- }
61
- if (root.filename === path) return
62
- push(root.filename)
63
- })
64
- return () => {
65
- offGraphClick()
66
- }
67
- }, [push])
68
- function listen<T extends keyof WindowEventMap>(type: T, listener: (this: Window, ev: WindowEventMap[T]) => any) {
69
- window.addEventListener(type, listener)
70
- return () => {
71
- window.removeEventListener(type, listener)
72
- }
73
- }
74
- return (
75
- <div
76
- style={{
77
- padding: '12px 55px'
78
- }}
79
- >
80
- /
81
- <select
82
- style={{
83
- appearance: 'none',
84
- border: 'none',
85
- background: 'none'
86
- }}
87
- value={pkgName}
88
- onChange={e => push(e.target.value)}
89
- >
90
- <option value=''>All</option>
91
- {analyzeModule
92
- .map(m => /^(@[^/]+\/[^/]+|[^/]+)\/?/.exec(m.filename)?.[1])
93
- .filter((v, i, a) => a.indexOf(v) === i)
94
- .map(v => (
95
- <option key={v} value={v}>{v}</option>
96
- ))}
97
- </select>
98
- {pkgName != null && <>
99
- /
100
- <select
101
- style={{
102
- appearance: 'none',
103
- border: 'none',
104
- background: 'none'
105
- }}
106
- value={entry}
107
- onChange={e => push(`${pkgName}/${e.target.value}`)}
108
- >
109
- <option value=''>All</option>
110
- {analyzeModule
111
- .filter(m => m.filename.startsWith(`${pkgName}/`))
112
- .map(m => m.filename.replace(`${pkgName}/`, ''))
113
- .filter((v, i, a) => a.indexOf(v) === i)
114
- .map(v => (
115
- <option key={v} value={v}>{v}</option>
116
- ))}
117
- </select>
118
- </>}
119
- </div>
120
- )
121
- }
@@ -1,26 +0,0 @@
1
- import { Main } from './analyzer'
2
-
3
- declare global {
4
- // eslint-disable-next-line no-var,vars-on-top
5
- var CUSTOM_SIDE_BAR: boolean
6
- // eslint-disable-next-line no-var,vars-on-top
7
- var __REPLACE_INJECT__: string
8
- }
9
-
10
- function render() {
11
- CUSTOM_SIDE_BAR = true
12
- window.addEventListener('client:ready', () =>
13
- window.dispatchEvent(
14
- new CustomEvent('send:ui', {
15
- detail: { type: 'Main', Component: __REPLACE_INJECT__ }
16
- })
17
- ))
18
- }
19
-
20
- export const CLIENT_CUSTOM_RENDER_SCRIPT = [
21
- Main.toString(),
22
- render
23
- .toString()
24
- .replace('__REPLACE_INJECT__', Main.name),
25
- `(${render.name})()`
26
- ].join('\n')