jiek 0.4.7-alpha.14 → 0.4.7-alpha.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.
Files changed (51) hide show
  1. package/bin/jiek.js +4 -7
  2. package/dist/{cli.d.cts → cli.d.mts} +0 -15
  3. package/dist/cli.d.mts.map +1 -0
  4. package/dist/cli.d.ts +0 -15
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +222 -4408
  7. package/dist/cli.js.map +1 -0
  8. package/dist/cli.min.js +1 -19
  9. package/dist/cli.min.js.map +1 -0
  10. package/dist/cli.min.mjs +1 -0
  11. package/dist/cli.min.mjs.map +1 -0
  12. package/dist/cli.mjs +803 -0
  13. package/dist/cli.mjs.map +1 -0
  14. package/dist/{index.d.cts → index.d.mts} +0 -15
  15. package/dist/index.d.mts.map +1 -0
  16. package/dist/index.d.ts +0 -15
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +3 -1
  19. package/dist/index.js.map +1 -0
  20. package/dist/index.min.js +1 -1
  21. package/dist/index.min.js.map +1 -0
  22. package/dist/index.min.mjs +1 -0
  23. package/dist/index.min.mjs.map +1 -0
  24. package/dist/index.mjs +3 -0
  25. package/dist/index.mjs.map +1 -0
  26. package/dist/rollup/index.d.mts.map +1 -0
  27. package/dist/rollup/index.d.ts.map +1 -0
  28. package/dist/rollup/index.js +69 -4189
  29. package/dist/rollup/index.js.map +1 -0
  30. package/dist/rollup/index.min.js +1 -19
  31. package/dist/rollup/index.min.js.map +1 -0
  32. package/dist/rollup/index.min.mjs +1 -0
  33. package/dist/rollup/index.min.mjs.map +1 -0
  34. package/dist/rollup/index.mjs +551 -0
  35. package/dist/rollup/index.mjs.map +1 -0
  36. package/package.json +19 -11
  37. package/src/commands/base.ts +2 -1
  38. package/src/commands/build.ts +2 -4
  39. package/src/commands/publish.ts +2 -16
  40. package/src/pkg.ts +1 -0
  41. package/src/rollup/index.ts +3 -5
  42. package/src/utils/filterSupport.ts +0 -2
  43. package/src/utils/getExports.ts +7 -11
  44. package/src/utils/tsRegister.ts +0 -4
  45. package/dist/cli.cjs +0 -5041
  46. package/dist/cli.min.cjs +0 -19
  47. package/dist/index.cjs +0 -5
  48. package/dist/index.min.cjs +0 -1
  49. package/dist/rollup/index.cjs +0 -4688
  50. package/dist/rollup/index.min.cjs +0 -19
  51. /package/dist/rollup/{index.d.cts → index.d.mts} +0 -0
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "jiek",
3
- "type": "module",
4
- "version": "0.4.7-alpha.14",
3
+ "version": "0.4.7-alpha.3",
5
4
  "description": "YiJie's personal kits.",
6
5
  "bin": {
7
6
  "jiek": "bin/jiek.js",
@@ -27,17 +26,27 @@
27
26
  "./package.json": "./package.json",
28
27
  ".": {
29
28
  "source": "./src/index.ts",
30
- "require": "./dist/index.cjs",
29
+ "import": "./dist/index.mjs",
31
30
  "default": "./dist/index.js"
32
31
  },
33
32
  "./cli": {
34
33
  "source": "./src/cli.ts",
35
- "require": "./dist/cli.cjs",
34
+ "import": "./dist/cli.mjs",
36
35
  "default": "./dist/cli.js"
37
36
  },
38
37
  "./rollup": {
39
38
  "source": "./src/rollup/index.ts",
40
- "require": "./dist/rollup/index.cjs",
39
+ "import": "./dist/rollup/index.mjs",
40
+ "default": "./dist/rollup/index.js"
41
+ },
42
+ "./cli.js": {
43
+ "source": "./src/cli.ts",
44
+ "import": "./dist/cli.mjs",
45
+ "default": "./dist/cli.js"
46
+ },
47
+ "./rollup.js": {
48
+ "source": "./src/rollup/index.ts",
49
+ "import": "./dist/rollup/index.mjs",
41
50
  "default": "./dist/rollup/index.js"
42
51
  }
43
52
  },
@@ -46,7 +55,6 @@
46
55
  },
47
56
  "dependencies": {
48
57
  "@jiek/rollup-plugin-dts": "^6.1.1",
49
- "@rollup/plugin-commonjs": "^28.0.0",
50
58
  "@rollup/plugin-json": "^6.0.1",
51
59
  "@rollup/plugin-node-resolve": "^15.3.0",
52
60
  "@rollup/plugin-terser": "^0.4.4",
@@ -58,12 +66,13 @@
58
66
  "inquirer": "^8.2.6",
59
67
  "js-yaml": "^4.1.0",
60
68
  "jsonc-parser": "^3.2.1",
69
+ "micromatch": "^4.0.5",
61
70
  "rollup": "^4.1.5",
62
71
  "rollup-plugin-copy": "^3.5.0",
63
72
  "rollup-plugin-esbuild": "^6.1.0",
64
73
  "typescript": "^5.0.0",
65
- "@jiek/pkger": "^0.2.0",
66
- "@jiek/utils": "^0.2.1"
74
+ "@jiek/pkger": "^0.1.11",
75
+ "@jiek/utils": "^0.2.0"
67
76
  },
68
77
  "optionalDependencies": {
69
78
  "@pnpm/filter-workspace-packages": "^7.2.13",
@@ -80,11 +89,10 @@
80
89
  "@types/js-yaml": "^4.0.9",
81
90
  "@types/micromatch": "^4.0.6",
82
91
  "esbuild-register": "^3.5.0",
83
- "micromatch": "^4.0.5",
84
92
  "node-sass": "^9.0.0",
85
93
  "postcss": "^8.4.47",
86
94
  "rollup-plugin-postcss": "^4.0.2"
87
95
  },
88
- "main": "./dist/index.cjs",
89
- "module": "./dist/index.js"
96
+ "main": "./dist/index.js",
97
+ "module": "./dist/index.mjs"
90
98
  }
@@ -1,5 +1,6 @@
1
1
  import { program } from 'commander'
2
- import pkg from 'jiek/package.json'
2
+
3
+ import pkg from '../pkg'
3
4
 
4
5
  program
5
6
  .version(pkg.version)
@@ -1,7 +1,6 @@
1
1
  import '../rollup/base'
2
2
 
3
3
  import fs from 'node:fs'
4
- import { createRequire } from 'node:module'
5
4
  import path from 'node:path'
6
5
 
7
6
  import { MultiBar, Presets } from 'cli-progress'
@@ -15,11 +14,10 @@ import { loadConfig } from '../utils/loadConfig'
15
14
  import { tsRegisterName } from '../utils/tsRegister'
16
15
 
17
16
  const FILE_TEMPLATE = (manifest: unknown) => (`
18
- module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
17
+ const manifest = ${JSON.stringify(manifest, null, 2)}
18
+ module.exports = require('jiek/rollup').template(manifest)
19
19
  `.trimStart())
20
20
 
21
- const require = createRequire(import.meta.url)
22
-
23
21
  program
24
22
  .command('build')
25
23
  .option('-s, --silent', "Don't display logs.")
@@ -12,21 +12,6 @@ import { getSelectedProjectsGraph } from '../utils/filterSupport'
12
12
  import { getExports } from '../utils/getExports'
13
13
  import { loadConfig } from '../utils/loadConfig'
14
14
 
15
- declare module 'jiek' {
16
- export interface Config {
17
- publish?: {
18
- /**
19
- * @default false
20
- */
21
- withSuffix?: boolean
22
- /**
23
- * @default true
24
- */
25
- withSource?: boolean
26
- }
27
- }
28
- }
29
-
30
15
  program
31
16
  .command('publish')
32
17
  .aliases(['pub', 'p'])
@@ -54,7 +39,8 @@ program
54
39
  config: loadConfig(dir),
55
40
  dir,
56
41
  noFilter: true,
57
- isPublish: true
42
+ withSource: true,
43
+ withSuffix: true
58
44
  })
59
45
  newManifest.exports = {
60
46
  ...resolvedEntrypoints,
package/src/pkg.ts ADDED
@@ -0,0 +1 @@
1
+ export default require('../package.json')
@@ -7,7 +7,6 @@ import type { RecursiveRecord } from '@jiek/pkger/entrypoints'
7
7
  import { getAllLeafs } from '@jiek/pkger/entrypoints'
8
8
  import { dts } from '@jiek/rollup-plugin-dts'
9
9
  import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'
10
- import commonjs from '@rollup/plugin-commonjs'
11
10
  import json from '@rollup/plugin-json'
12
11
  import { nodeResolve } from '@rollup/plugin-node-resolve'
13
12
  import terser from '@rollup/plugin-terser'
@@ -64,6 +63,8 @@ const debug = (...args: unknown[]) => sendMessage({ type: 'debug', data: args }
64
63
 
65
64
  const resolveWorkspacePath = (p: string) => resolve(WORKSPACE_ROOT, p)
66
65
 
66
+ const intersection = <T>(a: Set<T>, b: Set<T>) => new Set([...a].filter(i => b.has(i)))
67
+
67
68
  const pascalCase = (str: string) =>
68
69
  str
69
70
  .replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase())
@@ -133,7 +134,6 @@ const getExtendTSConfig = (tsconfigPath: string): TSConfig => {
133
134
  if (extendsPaths.length === 0) return tsconfig
134
135
  return extendsPaths
135
136
  .map(getExtendTSConfig)
136
- .concat(tsconfig)
137
137
  // https://www.typescriptlang.org/tsconfig/#files:~:text=Currently%2C%20the%20only%20top%2Dlevel%20property%20that%20is%20excluded%20from%20inheritance%20is%20references.
138
138
  // Currently, the only top-level property that is excluded from inheritance is references.
139
139
  .reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
@@ -143,7 +143,7 @@ const getExtendTSConfig = (tsconfigPath: string): TSConfig => {
143
143
  ...acc.compilerOptions,
144
144
  ...compilerOptions
145
145
  }
146
- }), {})
146
+ }), tsconfig)
147
147
  }
148
148
 
149
149
  const getCompilerOptionsByFilePath = (tsconfigPath: string, filePath: string): Record<string, unknown> | undefined => {
@@ -249,7 +249,6 @@ const generateConfigs = ({
249
249
  ...withMinify({
250
250
  file: output,
251
251
  name,
252
- interop: 'auto',
253
252
  sourcemap: typeof options?.output?.sourcemap === 'object'
254
253
  ? options.output.sourcemap.js
255
254
  : options?.output?.sourcemap,
@@ -276,7 +275,6 @@ const generateConfigs = ({
276
275
  )
277
276
  .catch(() => void 0),
278
277
  esbuild(),
279
- commonjs(),
280
278
  progress({
281
279
  onEvent: (event, message) =>
282
280
  sendMessage(
@@ -1,5 +1,4 @@
1
1
  import fs from 'node:fs'
2
- import { createRequire } from 'node:module'
3
2
  import path from 'node:path'
4
3
 
5
4
  import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'
@@ -12,7 +11,6 @@ import { getWD } from './getWD'
12
11
  export let type = ''
13
12
 
14
13
  try {
15
- const require = createRequire(import.meta.url)
16
14
  require.resolve('@pnpm/filter-workspace-packages')
17
15
  type = 'pnpm'
18
16
  } catch { /* empty */ }
@@ -20,7 +20,8 @@ export function getExports({
20
20
  config,
21
21
  dir,
22
22
  noFilter,
23
- isPublish
23
+ withSource,
24
+ withSuffix
24
25
  }: {
25
26
  entrypoints: string | string[] | Record<string, unknown>
26
27
  pkgIsModule: boolean
@@ -28,17 +29,12 @@ export function getExports({
28
29
  config?: Config
29
30
  dir?: string
30
31
  noFilter?: boolean
31
- isPublish?: boolean
32
+ withSource?: boolean
33
+ withSuffix?: boolean
32
34
  }) {
33
35
  const dirResolve = (...paths: string[]) => resolve(dir ?? process.cwd(), ...paths)
34
36
  const dirRelative = (path: string) => relative(dir ?? process.cwd(), path)
35
- const {
36
- build = {},
37
- publish: {
38
- withSuffix = false,
39
- withSource = true
40
- } = {}
41
- } = config ?? {}
37
+ const { build = {} } = config ?? {}
42
38
  const {
43
39
  crossModuleConvertor = true
44
40
  } = build
@@ -94,8 +90,8 @@ export function getExports({
94
90
  filteredResolvedEntrypoints,
95
91
  entrypoints2Exports(filteredResolvedEntrypoints, {
96
92
  outdir: jsOutdir,
97
- withSuffix: isPublish ? withSuffix : undefined,
98
- withSource: isPublish ? withSource : undefined,
93
+ withSource,
94
+ withSuffix,
99
95
  withConditional: {
100
96
  ...crossModuleWithConditional
101
97
  }
@@ -1,7 +1,3 @@
1
- import { createRequire } from 'node:module'
2
-
3
- const require = createRequire(import.meta.url)
4
-
5
1
  function packageIsExist(name: string) {
6
2
  try {
7
3
  require.resolve(name)