jiek 1.0.10 → 1.0.12
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.cjs +8 -7
- package/dist/cli.js +8 -7
- package/dist/cli.min.cjs +4 -4
- package/dist/cli.min.js +4 -4
- package/dist/rollup/index.cjs +32 -25
- package/dist/rollup/index.js +25 -18
- package/dist/rollup/index.min.cjs +4 -4
- package/dist/rollup/index.min.js +2 -2
- package/package.json +3 -3
- package/src/rollup/index.ts +23 -11
- package/src/utils/loadConfig.ts +3 -0
package/src/rollup/index.ts
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
import './base'
|
2
|
-
|
3
1
|
import fs from 'node:fs'
|
4
|
-
import { dirname, relative, resolve } from 'node:path'
|
2
|
+
import { dirname, extname, relative, resolve } from 'node:path'
|
5
3
|
|
6
4
|
import type { RecursiveRecord } from '@jiek/pkger/entrypoints'
|
7
5
|
import { getAllLeafs } from '@jiek/pkger/entrypoints'
|
@@ -12,6 +10,7 @@ import json from '@rollup/plugin-json'
|
|
12
10
|
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
13
11
|
import terser from '@rollup/plugin-terser'
|
14
12
|
import { sendMessage } from 'execa'
|
13
|
+
import { isMatch } from 'micromatch'
|
15
14
|
import type { InputPluginOption, OutputOptions, OutputPlugin, RollupOptions } from 'rollup'
|
16
15
|
import esbuild from 'rollup-plugin-esbuild'
|
17
16
|
import ts from 'typescript'
|
@@ -195,9 +194,22 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
|
|
195
194
|
? input
|
196
195
|
: recusiveListFiles(process.cwd())
|
197
196
|
.filter(p => /(?<!\.d)\.[cm]?tsx?$/.test(p))
|
197
|
+
.map(p => relative(process.cwd(), p))
|
198
|
+
.filter(p => isMatch(p, input.slice(2)))
|
198
199
|
const globCommonDir = input.includes('*')
|
199
|
-
? input.split('*')[0]
|
200
|
+
? input.split('*')[0].replace('./', '')
|
201
|
+
: ''
|
202
|
+
const pathCommonDir = path.includes('*')
|
203
|
+
? path.split('*')[0].replace('./', '')
|
200
204
|
: ''
|
205
|
+
if (
|
206
|
+
(globCommonDir.length > 0 && pathCommonDir.length === 0)
|
207
|
+
|| (globCommonDir.length === 0 && pathCommonDir.length > 0)
|
208
|
+
) {
|
209
|
+
throw new Error('input and path should both include "*" or not include "*"')
|
210
|
+
}
|
211
|
+
const jsOutputSuffix = extname(output)
|
212
|
+
const tsOutputSuffix = jsOutputSuffix.replace(/(\.[cm]?)js$/, '.d$1ts')
|
201
213
|
return [
|
202
214
|
{
|
203
215
|
input: inputObj,
|
@@ -209,9 +221,9 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
|
|
209
221
|
interop: 'auto',
|
210
222
|
entryFileNames: (chunkInfo) => (
|
211
223
|
Array.isArray(inputObj)
|
212
|
-
? chunkInfo.facadeModuleId!.replace(`${process.cwd()}/`, '
|
213
|
-
.replace(globCommonDir,
|
214
|
-
.replace(/(\.[cm]?)ts$/,
|
224
|
+
? chunkInfo.facadeModuleId!.replace(`${process.cwd()}/`, '')
|
225
|
+
.replace(globCommonDir, pathCommonDir)
|
226
|
+
.replace(/(\.[cm]?)ts$/, jsOutputSuffix)
|
215
227
|
: output.replace(`${jsOutdir}/`, '')
|
216
228
|
),
|
217
229
|
sourcemap: typeof options?.output?.sourcemap === 'object'
|
@@ -266,12 +278,12 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
|
|
266
278
|
: options?.output?.sourcemap,
|
267
279
|
entryFileNames: (chunkInfo) => (
|
268
280
|
Array.isArray(inputObj)
|
269
|
-
? chunkInfo.facadeModuleId!.replace(`${process.cwd()}/`, '
|
270
|
-
.replace(globCommonDir,
|
271
|
-
.replace(/(\.[cm]?)ts$/,
|
281
|
+
? chunkInfo.facadeModuleId!.replace(`${process.cwd()}/`, '')
|
282
|
+
.replace(globCommonDir, pathCommonDir)
|
283
|
+
.replace(/(\.[cm]?)ts$/, tsOutputSuffix)
|
272
284
|
: output
|
273
285
|
.replace(`${jsOutdir}/`, '')
|
274
|
-
.replace(/(\.[cm]?)js$/,
|
286
|
+
.replace(/(\.[cm]?)js$/, tsOutputSuffix)
|
275
287
|
),
|
276
288
|
strict: typeof options?.output?.strict === 'object'
|
277
289
|
? options.output.strict.dts
|
package/src/utils/loadConfig.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import fs from 'node:fs'
|
2
|
+
import { createRequire } from 'node:module'
|
2
3
|
import path from 'node:path'
|
3
4
|
|
4
5
|
import { program } from 'commander'
|
@@ -8,6 +9,8 @@ import { load } from 'js-yaml'
|
|
8
9
|
import { getWD } from './getWD'
|
9
10
|
import { tsRegisterName } from './tsRegister'
|
10
11
|
|
12
|
+
const require = createRequire(import.meta.url)
|
13
|
+
|
11
14
|
let configName = 'jiek.config'
|
12
15
|
|
13
16
|
function getConfigPath(root: string, dir?: string) {
|