jiek 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/{tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/LICENSE → LICENSE} +1 -1
  2. package/package.json +13 -8
  3. package/src/commands/build.ts +0 -91
  4. package/src/commands/publish.ts +0 -79
  5. package/src/index.ts +0 -6
  6. package/src/inner.ts +0 -11
  7. package/src/merge-package-json.ts +0 -19
  8. package/src/rollup/index.ts +0 -162
  9. package/src/rollup/plugins/globals.ts +0 -34
  10. package/src/rollup/plugins/skip.ts +0 -23
  11. package/src/rollup/utils/commonOptions.ts +0 -9
  12. package/src/rollup/utils/externalResolver.ts +0 -11
  13. package/src/rollup/utils/globalResolver.ts +0 -24
  14. package/src/rollup/utils/withMinify.ts +0 -16
  15. package/tests/build.spec.ts +0 -28
  16. package/tests/fixtures/node_modules/.bin/jiek +0 -17
  17. package/tests/fixtures/node_modules/.jiek/jiek+test-foo.rollup.config.js +0 -31
  18. package/tests/fixtures/node_modules/.modules.yaml +0 -95
  19. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/README.md +0 -3
  20. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/bin/esbuild +0 -0
  21. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/package.json +0 -20
  22. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/loader.js +0 -3
  23. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/package.json +0 -8
  24. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/LICENSE +0 -20
  25. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/README.md +0 -481
  26. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/package.json +0 -59
  27. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/browser.js +0 -269
  28. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/common.js +0 -274
  29. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/index.js +0 -10
  30. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/node.js +0 -263
  31. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/LICENSE +0 -21
  32. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/README.md +0 -50
  33. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/loader.d.ts +0 -3
  34. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/loader.js +0 -15
  35. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/node.d.ts +0 -23
  36. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/node.js +0 -4926
  37. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/loader.js +0 -1
  38. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/node_modules/.bin/esbuild +0 -14
  39. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/package.json +0 -46
  40. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/register.js +0 -3
  41. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/LICENSE.md +0 -21
  42. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/README.md +0 -3
  43. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/bin/esbuild +0 -0
  44. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/install.js +0 -288
  45. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/lib/main.d.ts +0 -703
  46. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/lib/main.js +0 -2436
  47. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/node_modules/.bin/esbuild +0 -14
  48. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/package.json +0 -46
  49. package/tests/fixtures/node_modules/.pnpm/lock.yaml +0 -291
  50. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js +0 -162
  51. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/license.md +0 -21
  52. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/package.json +0 -37
  53. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/readme.md +0 -60
  54. package/tests/fixtures/node_modules/.pnpm/node_modules/.bin/esbuild +0 -14
  55. package/tests/fixtures/package.json +0 -8
  56. package/tests/fixtures/packages/bar/package.json +0 -4
  57. package/tests/fixtures/packages/foo/dist/index.d.ts +0 -3
  58. package/tests/fixtures/packages/foo/dist/index.esm.d.ts +0 -3
  59. package/tests/fixtures/packages/foo/dist/index.esm.js +0 -6
  60. package/tests/fixtures/packages/foo/dist/index.esm.js.map +0 -1
  61. package/tests/fixtures/packages/foo/dist/index.esm.min.js +0 -2
  62. package/tests/fixtures/packages/foo/dist/index.esm.min.js.map +0 -1
  63. package/tests/fixtures/packages/foo/dist/index.iife.js +0 -15
  64. package/tests/fixtures/packages/foo/dist/index.iife.js.map +0 -1
  65. package/tests/fixtures/packages/foo/dist/index.iife.min.js +0 -2
  66. package/tests/fixtures/packages/foo/dist/index.iife.min.js.map +0 -1
  67. package/tests/fixtures/packages/foo/dist/index.umd.js +0 -16
  68. package/tests/fixtures/packages/foo/dist/index.umd.js.map +0 -1
  69. package/tests/fixtures/packages/foo/dist/index.umd.min.js +0 -2
  70. package/tests/fixtures/packages/foo/dist/index.umd.min.js.map +0 -1
  71. package/tests/fixtures/packages/foo/package.json +0 -7
  72. package/tests/fixtures/packages/foo/src/index.ts +0 -3
  73. package/tests/fixtures/pnpm-workspace.yaml +0 -2
  74. package/tests/publish.spec.ts +0 -31
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023-present Typp
3
+ Copyright (c) 2024-present YiJie
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jiek",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "YiJie's personal kits.",
5
5
  "bin": {
6
6
  "jiek": "bin/jiek.js",
@@ -18,8 +18,8 @@
18
18
  "rollup-plugin-dts": "^6.1.0",
19
19
  "rollup-plugin-esbuild": "^6.1.0",
20
20
  "rollup-plugin-postcss": "^4.0.2",
21
- "@jiek/pkger": "0.1.2",
22
- "@jiek/utils": "0.1.3"
21
+ "@jiek/pkger": "0.1.3",
22
+ "@jiek/utils": "0.1.4"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@npm/types": "^1.0.2",
@@ -27,6 +27,9 @@
27
27
  "@types/js-yaml": "^4.0.9",
28
28
  "esbuild-register": "^3.5.0"
29
29
  },
30
+ "files": [
31
+ "dist"
32
+ ],
30
33
  "types": "dist/index.d.ts",
31
34
  "main": "dist/index.umd.js",
32
35
  "module": "dist/index.esm.js",
@@ -34,11 +37,13 @@
34
37
  "jsdelivr": "dist/index.umd.min.js",
35
38
  "browser": "dist/index.umd.min.js",
36
39
  "typesVersions": {
37
- "<5.0": [
38
- "*",
39
- "dist/*",
40
- "dist/*/index.esm.d.ts"
41
- ]
40
+ "<5.0": {
41
+ "*": [
42
+ "*",
43
+ "dist/*",
44
+ "dist/*/index.esm.d.ts"
45
+ ]
46
+ }
42
47
  },
43
48
  "exports": {
44
49
  "./package.json": "./package.json",
@@ -1,91 +0,0 @@
1
- import * as childProcess from 'node:child_process'
2
- import fs from 'node:fs'
3
- import path from 'node:path'
4
-
5
- import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'
6
- import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'
7
- import { program } from 'commander'
8
- import { load } from 'js-yaml'
9
-
10
- import { actionDone, actionRestore } from '../inner'
11
- import { mergePackageJson } from '../merge-package-json'
12
-
13
- const FILE_TEMPLATE = (manifest: unknown) => `
14
- module.exports = require('${
15
- process.env.NODE_ENV === 'test'
16
- ? 'jiek/src/rollup/index.ts'
17
- : 'jiek/rollup'
18
- }').template({ }, ${JSON.stringify(manifest, null, 2)})
19
- `.trimStart()
20
-
21
- program
22
- .command('build')
23
- .option('--filter <filter>', 'filter packages')
24
- .option('--root <root>', 'root path')
25
- .action(async ({ root: rootOption, filter, ...options }: {
26
- root?: string
27
- filter?: string
28
- }) => {
29
- actionRestore()
30
- const root = rootOption
31
- ? path.isAbsolute(rootOption)
32
- ? rootOption
33
- : path.resolve(process.cwd(), rootOption)
34
- : process.cwd()
35
- const wd = getWorkspaceDir(root)
36
- const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')
37
- const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')
38
- const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {
39
- packages: string[]
40
- }
41
- if (root === wd && !filter) {
42
- throw new Error('root path is workspace root, please provide a filter')
43
- // TODO inquirer prompt support user select packages
44
- }
45
- if (root !== wd && !filter) {
46
- const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))
47
- if (!packageJSONIsExist) {
48
- throw new Error('root path is not workspace root, please provide a filter')
49
- }
50
- const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))
51
- if (!packageJSON.name) {
52
- throw new Error('root path is not workspace root, please provide a filter')
53
- }
54
- filter = packageJSON.name
55
- }
56
- const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
57
- filter: filter ?? '',
58
- followProdDepsOnly: true
59
- }], {
60
- prefix: root,
61
- workspaceDir: wd,
62
- patterns: pnpmWorkspace.packages
63
- })
64
- const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)
65
- if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())
66
-
67
- const rollupBinaryPath = require.resolve('rollup')
68
- .replace(/dist\/rollup.js$/, 'dist/bin/rollup')
69
- let i = 0
70
- for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {
71
- const newManifest = mergePackageJson(manifest, dir)
72
- // TODO support auto build child packages in workspaces
73
- const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\//g, '+')
74
- const configFile = jiekTempDir(
75
- `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
76
- )
77
- fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))
78
- let prefix = ''
79
- if (process.env.NODE_ENV === 'test') {
80
- const registerPath = require.resolve('esbuild-register')
81
- const loaderPath = require.resolve('esbuild-register/loader')
82
- prefix = `node --import ${registerPath} -r ${loaderPath} `
83
- }
84
- // TODO replace with `spawn` to support watch mode
85
- childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {
86
- cwd: dir, stdio: 'inherit'
87
- })
88
- }
89
-
90
- actionDone()
91
- })
@@ -1,79 +0,0 @@
1
- import fs from 'node:fs'
2
- import path from 'node:path'
3
-
4
- import { bump, type BumperType } from '@jiek/utils/bumper'
5
- import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'
6
- import type { PackageJson } from '@npm/types'
7
- import { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'
8
- import * as childProcess from 'child_process'
9
- import { program } from 'commander'
10
-
11
- import { actionDone, actionRestore } from '../inner'
12
- import { mergePackageJson } from '../merge-package-json'
13
-
14
- program
15
- .command('publish')
16
- .aliases(['pub', 'p'])
17
- .option('--filter <filter>', 'filter packages')
18
- .option('--root <root>', 'root path')
19
- .option('--bumper <bumper>', 'bump version', 'patch')
20
- .action(async ({ root: rootOption, filter, bumper, ...options }: {
21
- root?: string
22
- filter?: string
23
- bumper: BumperType
24
- }) => {
25
- actionRestore()
26
- const root = rootOption
27
- ? path.isAbsolute(rootOption)
28
- ? rootOption
29
- : path.resolve(process.cwd(), rootOption)
30
- : process.cwd()
31
- const wd = getWorkspaceDir(root)
32
- const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
33
- filter: filter ?? '',
34
- followProdDepsOnly: true
35
- }], {
36
- prefix: root,
37
- workspaceDir: wd,
38
- patterns: ['packages/*']
39
- })
40
- const mainfests: [dir: string, PackageJson][] = []
41
- Object
42
- .entries(selectedProjectsGraph)
43
- .forEach(([, { package: { dir, manifest } }]) => {
44
- mainfests.push([
45
- dir, mergePackageJson(manifest, dir)
46
- ])
47
- })
48
- const passArgs = Object
49
- .entries(options)
50
- .reduce((acc, [key, value]) => {
51
- if (value) {
52
- acc.push(`--${key}`, value as string)
53
- }
54
- return acc
55
- }, [] as string[])
56
- for (const [dir, m] of mainfests) {
57
- const newVersion = bump(m.version, bumper)
58
- const newManifest = {
59
- ...m,
60
- version: newVersion
61
- }
62
- fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))
63
- fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))
64
- console.log(newManifest)
65
- try {
66
- childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {
67
- cwd: dir,
68
- stdio: 'inherit'
69
- })
70
- const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))
71
- oldPackageJson.version = newVersion
72
- fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))
73
- } finally {
74
- fs.unlinkSync(path.join(dir, 'package.json'))
75
- fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))
76
- }
77
- }
78
- actionDone()
79
- })
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- import './commands/publish'
2
- import './commands/build'
3
-
4
- import { program } from 'commander'
5
-
6
- program.parse(process.argv)
package/src/inner.ts DELETED
@@ -1,11 +0,0 @@
1
- let resolve: () => void
2
-
3
- export let actionFuture: Promise<void>
4
-
5
- export function actionDone() {
6
- resolve()
7
- }
8
-
9
- export function actionRestore() {
10
- actionFuture = new Promise<void>(r => resolve = r)
11
- }
@@ -1,19 +0,0 @@
1
- import { type Options, pkger } from '@jiek/pkger'
2
- import type { PackageJson } from '@npm/types'
3
- import type { Manifest } from '@pnpm/workspace.pkgs-graph'
4
-
5
- export function mergePackageJson(manifest: Manifest & {
6
- jiek?: Options
7
- exports?: unknown | unknown[]
8
- }, cwd: string) {
9
- const {
10
- jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports
11
- } = manifest
12
- const inputs = jiekInputs ?? (
13
- Array.isArray(exports) ? exports : undefined
14
- )
15
- return {
16
- ...manifest,
17
- ...pkger({ inputs, cwd, ...jiek })
18
- } as PackageJson
19
- }
@@ -1,162 +0,0 @@
1
- import { resolve } from 'node:path'
2
-
3
- import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'
4
- import autoprefixer from 'autoprefixer'
5
- import type { InputPluginOption, RollupOptions } from 'rollup'
6
- import { dts } from 'rollup-plugin-dts'
7
- import esbuild from 'rollup-plugin-esbuild'
8
- import postcss from 'rollup-plugin-postcss'
9
-
10
- import { createGlobalsLinkage } from './plugins/globals'
11
- import skip from './plugins/skip'
12
- import { commonOutputOptions } from './utils/commonOptions'
13
- import externalResolver from './utils/externalResolver'
14
- import withMinify from './utils/withMinify'
15
-
16
- const workspaceRoot = getWorkspaceDir()
17
- function resolveWorkspacePath(p: string) {
18
- return resolve(workspaceRoot, p)
19
- }
20
-
21
- export const template = (
22
- {
23
- styled = false,
24
- plugins: {
25
- index: indexPlugins = [],
26
- entry: entryPlugins = [],
27
- dts: dtsPlugins = []
28
- } = {}
29
- }: {
30
- /**
31
- * include styles files
32
- */
33
- styled?: boolean
34
- plugins?: {
35
- index?: InputPluginOption
36
- entry?: InputPluginOption
37
- dts?: InputPluginOption
38
- }
39
- } = {},
40
- pkg: {
41
- name?: string
42
- exports?: Record<string, string | {
43
- import: string
44
- 'inner-src': string
45
- }>
46
- }
47
- ) => {
48
- if (!pkg.name) {
49
- throw new Error('pkg.name is required')
50
- }
51
- const namePrefix = pkg
52
- .name
53
- .replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase())
54
- const exportsEntries = Object.fromEntries(
55
- Object.entries(pkg.exports ?? {})
56
- // filter static files
57
- .filter(([key]) => !/\.(json|css|scss)$/.test(key))
58
- // filter no `inner-src` or `import` field entries
59
- .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])
60
- .map(([key, value]) => [
61
- key
62
- .replace(/^\.$/, 'index')
63
- .replace(/^\.\//, ''),
64
- typeof value === 'string' ? value : value['inner-src']
65
- ])
66
- )
67
-
68
- const [globalsRegister, globalsOutput] = createGlobalsLinkage()
69
- const external = externalResolver()
70
-
71
- return [
72
- {
73
- input: exportsEntries,
74
- output: [
75
- ...withMinify({
76
- ...commonOutputOptions,
77
- format: 'esm',
78
- entryFileNames: '[name].esm.js',
79
- preserveModules: true
80
- })
81
- ],
82
- plugins: [
83
- globalsRegister({ external }),
84
- styled && skip({ patterns: [/\.s?css$/] }),
85
- esbuild(),
86
- indexPlugins
87
- ]
88
- },
89
- ...Object.entries(exportsEntries).map(([name, input]) => {
90
- const outputName = namePrefix + (
91
- name === 'index' ? '' : (
92
- name[0].toUpperCase() + name.slice(1)
93
- )
94
- )
95
- return {
96
- input: input,
97
- output: [
98
- ...withMinify({
99
- ...commonOutputOptions,
100
- name: outputName,
101
- format: 'iife',
102
- entryFileNames: `${name}.iife.js`
103
- }),
104
- ...withMinify({
105
- ...commonOutputOptions,
106
- name: outputName,
107
- format: 'umd',
108
- entryFileNames: `${name}.umd.js`
109
- })
110
- ],
111
- plugins: [
112
- globalsOutput,
113
- styled && postcss({
114
- plugins: [autoprefixer],
115
- minimize: true,
116
- sourceMap: true,
117
- extract: `${name}.css`
118
- }),
119
- esbuild(),
120
- entryPlugins
121
- ],
122
- external
123
- }
124
- }),
125
- {
126
- input: exportsEntries,
127
- output: [
128
- {
129
- dir: 'dist',
130
- entryFileNames: ({ name }) => `${name.replace(/^src\//, '')}.esm.d.ts`,
131
- preserveModules: true
132
- },
133
- {
134
- dir: 'dist'
135
- }
136
- ],
137
- plugins: [
138
- styled && skip({ patterns: [/\.s?css$/] }),
139
- dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),
140
- {
141
- name: 'rollup-plugin-declare-module-replacer',
142
- /**
143
- * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
144
- * in output file generated
145
- */
146
- generateBundle(_, bundle) {
147
- for (const file of Object.values(bundle)) {
148
- if (!('code' in file)) continue
149
-
150
- file.code = file.code.replace(
151
- /declare module ['|"]\..*['|"]/g,
152
- `declare module '${pkg.name}'`
153
- )
154
- }
155
- }
156
- },
157
- dtsPlugins
158
- ],
159
- external
160
- }
161
- ] as RollupOptions[]
162
- }
@@ -1,34 +0,0 @@
1
- import type { Plugin, PluginImpl } from 'rollup'
2
-
3
- import globalResolver from '../utils/globalResolver'
4
-
5
- interface GlobalsOptions {
6
- external?: (string | RegExp)[]
7
- }
8
-
9
- export function createGlobalsLinkage() {
10
- let globals = {}
11
- const dependencies = new Set<string>([])
12
- return [
13
- (({ external } = {}) => {
14
- return {
15
- name: 'globals',
16
- resolveId(id) {
17
- if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {
18
- dependencies.add(id)
19
- return { id, external: true }
20
- }
21
- return null
22
- },
23
- outputOptions(options) {
24
- globals = [...dependencies].reduce((acc, value) => ({
25
- ...acc,
26
- [value]: globalResolver(value)
27
- }), {})
28
- return { ...options, globals }
29
- }
30
- }
31
- }) as PluginImpl<GlobalsOptions>,
32
- { outputOptions: options => ({ ...options, globals }) } as Plugin
33
- ] as const
34
- }
@@ -1,23 +0,0 @@
1
- import type { PluginImpl } from 'rollup'
2
-
3
- interface Options {
4
- patterns?: (string | RegExp)[]
5
- }
6
-
7
- export default ((options = {}) => {
8
- return {
9
- name: 'skip',
10
- // skip the specified files by `options.patterns`
11
- load(id) {
12
- if (
13
- options.patterns?.some((pattern) =>
14
- typeof pattern === 'string'
15
- ? id.includes(pattern)
16
- : pattern.test(id)
17
- )
18
- ) {
19
- return ''
20
- }
21
- }
22
- }
23
- }) as PluginImpl<Options>
@@ -1,9 +0,0 @@
1
- import type { OutputOptions } from 'rollup'
2
-
3
- const defineOutput = <O extends OutputOptions>(output: O) => output
4
-
5
- export const commonOutputOptions = defineOutput({
6
- dir: 'dist',
7
- exports: 'named',
8
- sourcemap: true
9
- })
@@ -1,11 +0,0 @@
1
- export default function () {
2
- const cwd = process.cwd()
3
- // eslint-disable-next-line @typescript-eslint/no-var-requires
4
- const pkg = require(`${cwd}/package.json`)
5
- const { dependencies = {}, peerDependencies = {} } = pkg
6
- const external = <(string | RegExp)[]>Object
7
- .keys(dependencies)
8
- .concat(Object.keys(peerDependencies))
9
- return external
10
- .map(dep => new RegExp(`^${dep}(/.*)?$`))
11
- }
@@ -1,24 +0,0 @@
1
- export default function (external: string) {
2
- if (external.startsWith('@zodui/')) {
3
- return external
4
- .replace(/[@/-](\w)/g, (_, c) => c.toUpperCase())
5
- }
6
- return {
7
- react: 'React',
8
- // TODO `react/jsx-runtime` is not supported `umd`
9
- 'react/jsx-runtime': 'ReactJSXRuntime',
10
- // https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.development.js
11
- 'react-dom': 'ReactDOM',
12
- // https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.development.js
13
- // TODO make the library use the global variable `TDesignReact` replace `TDesign`
14
- 'tdesign-react/esm': 'TDesign',
15
- // https://cdn.jsdelivr.net/npm/tdesign-react@1.4.0/dist/tdesign.js
16
- // https://cdn.jsdelivr.net/npm/tdesign-react@1.4.0/dist/tdesign.css
17
- 'tdesign-icons-react': 'TDesignIconReact',
18
- // https://cdn.jsdelivr.net/npm/tdesign-icons-react@1.4.0/dist/index.js
19
- zod: 'Zod',
20
- '@zodui/core': 'ZodUICore',
21
- '@zodui/core/utils': 'ZodUICoreUtils',
22
- '@zodui/react': 'ZodUIReact'
23
- }[external]
24
- }
@@ -1,16 +0,0 @@
1
- import terser from '@rollup/plugin-terser'
2
- import type { OutputOptions, OutputPlugin } from 'rollup'
3
-
4
- export default function (output: OutputOptions & {
5
- entryFileNames?: string
6
- plugins?: OutputPlugin[]
7
- }): OutputOptions[] {
8
- return [
9
- output,
10
- {
11
- ...output,
12
- entryFileNames: output.entryFileNames?.replace(/(\.js)$/, '.min$1'),
13
- plugins: [...(output.plugins ?? []), terser()]
14
- }
15
- ]
16
- }
@@ -1,28 +0,0 @@
1
- import '../src/commands/build'
2
-
3
- import path from 'node:path'
4
-
5
- import * as childProcess from 'child_process'
6
- import { program } from 'commander'
7
- import { beforeAll, describe, test } from 'vitest'
8
-
9
- import { actionFuture } from '../src/inner'
10
-
11
- const ROOT = path.resolve(__dirname, 'fixtures')
12
-
13
- beforeAll(() => {
14
- childProcess.execSync('pnpm i', {
15
- cwd: ROOT,
16
- stdio: 'inherit'
17
- })
18
- })
19
-
20
- const prefixes = ['node', 'jiek', 'build', '--root', ROOT]
21
- describe('build', () => {
22
- test('base', () => {
23
- process.env.WORKSPACE_DIR = ROOT
24
- process.argv = [...prefixes, '--filter', 'test-foo']
25
- program.parse(process.argv)
26
- return actionFuture
27
- })
28
- })
@@ -1,17 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
- esac
7
-
8
- if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/Users/yijie/codes/projects/jiek/packages/jiek/bin/node_modules:/Users/yijie/codes/projects/jiek/packages/jiek/node_modules:/Users/yijie/codes/projects/jiek/packages/node_modules:/Users/yijie/codes/projects/jiek/node_modules:/Users/yijie/codes/projects/node_modules:/Users/yijie/codes/node_modules:/Users/yijie/node_modules:/Users/node_modules:/node_modules:/Users/yijie/codes/projects/jiek/packages/jiek/tests/fixtures/node_modules/.pnpm/node_modules"
10
- else
11
- export NODE_PATH="/Users/yijie/codes/projects/jiek/packages/jiek/bin/node_modules:/Users/yijie/codes/projects/jiek/packages/jiek/node_modules:/Users/yijie/codes/projects/jiek/packages/node_modules:/Users/yijie/codes/projects/jiek/node_modules:/Users/yijie/codes/projects/node_modules:/Users/yijie/codes/node_modules:/Users/yijie/node_modules:/Users/node_modules:/node_modules:/Users/yijie/codes/projects/jiek/packages/jiek/tests/fixtures/node_modules/.pnpm/node_modules:$NODE_PATH"
12
- fi
13
- if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../jiek/bin/jiek.js" "$@"
15
- else
16
- exec node "$basedir/../jiek/bin/jiek.js" "$@"
17
- fi
@@ -1,31 +0,0 @@
1
- // import { template } from 'jiek/src/rollup'
2
- module.exports = require('jiek/src/rollup/index.ts').template({ }, {
3
- "name": "@jiek/test-foo",
4
- "version": "0.1.2",
5
- "dependencies": {
6
- "@jiek/test-bar": "workspace:^*"
7
- },
8
- "types": "dist/index.d.ts",
9
- "main": "dist/index.umd.js",
10
- "module": "dist/index.esm.js",
11
- "unpkg": "dist/index.umd.min.js",
12
- "jsdelivr": "dist/index.umd.min.js",
13
- "browser": "dist/index.umd.min.js",
14
- "typesVersions": {
15
- "<5.0": [
16
- "*",
17
- "dist/*",
18
- "dist/*/index.esm.d.ts"
19
- ]
20
- },
21
- "exports": {
22
- "package.json": "package.json",
23
- ".": {
24
- "types": "dist/index.d.ts",
25
- "import": "dist/index.esm.js",
26
- "default": "dist/index.esm.js",
27
- "require": "dist/index.umd.js",
28
- "inner-src": "src/index.ts"
29
- }
30
- }
31
- })