jiek 0.1.11 → 0.1.12-alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/dist/commands/build.esm.js +9 -31
  2. package/dist/commands/build.esm.js.map +1 -1
  3. package/dist/commands/build.esm.min.js +1 -1
  4. package/dist/commands/build.esm.min.js.map +1 -1
  5. package/dist/commands/publish.esm.js +11 -17
  6. package/dist/commands/publish.esm.js.map +1 -1
  7. package/dist/commands/publish.esm.min.js +1 -1
  8. package/dist/commands/publish.esm.min.js.map +1 -1
  9. package/dist/index.esm.js +3 -0
  10. package/dist/index.esm.js.map +1 -1
  11. package/dist/index.esm.min.js +1 -1
  12. package/dist/index.esm.min.js.map +1 -1
  13. package/dist/index.iife.js +109 -58
  14. package/dist/index.iife.js.map +1 -1
  15. package/dist/index.iife.min.js +1 -1
  16. package/dist/index.iife.min.js.map +1 -1
  17. package/dist/index.umd.js +111 -60
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/index.umd.min.js +1 -1
  20. package/dist/index.umd.min.js.map +1 -1
  21. package/dist/rollup/utils/commonOptions.esm.js +1 -0
  22. package/dist/rollup/utils/commonOptions.esm.js.map +1 -1
  23. package/dist/rollup/utils/commonOptions.esm.min.js +1 -1
  24. package/dist/rollup/utils/commonOptions.esm.min.js.map +1 -1
  25. package/dist/rollup.esm.js +8 -2
  26. package/dist/rollup.esm.js.map +1 -1
  27. package/dist/rollup.esm.min.js +1 -1
  28. package/dist/rollup.esm.min.js.map +1 -1
  29. package/dist/rollup.iife.js +22 -9
  30. package/dist/rollup.iife.js.map +1 -1
  31. package/dist/rollup.iife.min.js +1 -1
  32. package/dist/rollup.iife.min.js.map +1 -1
  33. package/dist/rollup.umd.js +24 -11
  34. package/dist/rollup.umd.js.map +1 -1
  35. package/dist/rollup.umd.min.js +1 -1
  36. package/dist/rollup.umd.min.js.map +1 -1
  37. package/dist/utils/filterSupport.esm.js +78 -0
  38. package/dist/utils/filterSupport.esm.js.map +1 -0
  39. package/dist/utils/filterSupport.esm.min.js +2 -0
  40. package/dist/utils/filterSupport.esm.min.js.map +1 -0
  41. package/package.json +16 -9
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.min.js","sources":["../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport type { PackageJson } from '@npm/types'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ root: rootOption, filter, bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: ['packages/*']\n })\n const mainfests: [dir: string, PackageJson][] = []\n Object\n .entries(selectedProjectsGraph)\n .forEach(([, { package: { dir, manifest } }]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .option('--filter <filter>', 'filter packages')\n .option('--root <root>', 'root path')\n .action(async ({ root: rootOption, filter, ...options }: {\n root?: string\n filter?: string\n }) => {\n actionRestore()\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n const wd = getWorkspaceDir(root)\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, { package: { manifest } }] of Object.entries(selectedProjectsGraph)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["resolve","actionDone","actionRestore","Promise","r","mergePackageJson","manifest","cwd","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","commander","program","command","aliases","option","action","async","root","rootOption","filter","bumper","options","path","isAbsolute","process","wd","getWorkspaceDir","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","mainfests","Object","entries","forEach","package","dir","push","passArgs","reduce","acc","key","value","m","newVersion","bump","version","newManifest","fs","renameSync","join","writeFileSync","JSON","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","parse","readFileSync","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","pnpmWorkspaceFilePath","pnpmWorkspaceFileContent","pnpmWorkspace","load","Error","existsSync","packageJSON","name","packages","jiekTempDir","paths","mkdirSync","rollupBinaryPath","require","replace","i","escapeManifestName","configFile","argv"],"mappings":"ujCAAA,IAAIA,EAIG,SAASC,IACND,GACV,CAEO,SAASE,IACC,IAAIC,SAAmBC,GAAAJ,EAAUI,GAClD,CCNgB,SAAAC,EAAiBC,EAG9BC,GACK,MACJC,MAAQC,OAAQC,EAAYH,IAAKI,KAAMH,GAAS,CAAC,EAAAI,QAAGA,GAClDN,EACEG,EAASC,IACbG,MAAMC,QAAQF,GAAWA,OAAU,GAE9B,MAAA,IACFN,KACAS,EAAMA,MAAA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c,aAAcN,EACdO,SAAUuC,EAAcM,WAEpBC,EAAc,IAAIC,IAAoBzD,EAAK5B,QAAQ+B,EAAI,wBAAyBsD,GACjF7B,EAAGwB,WAAWI,MAAmB5B,EAAA8B,UAAUF,KAEhD,MAAMG,EAAmBC,QAAQxF,QAAQ,UACtCyF,QAAQ,mBAAoB,mBAC/B,IAAIC,EAAI,EACR,IAAA,MAAY9C,GAAOD,SAASrC,SAAEA,OAAiBkC,OAAOC,QAAQR,GAAwB,CAC9E,MAAAsB,EAAclD,EAAiBC,EAAUsC,GAEzC+C,EAAqBrF,EAAS4E,MAAMO,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtEG,EAAaR,EACjB,GAAGO,GAAsB,aAAaD,wBAExClC,EAAGG,cAAciC,EAAYrB,EAAchB,IAC3C,IAAInB,EAAS,GACT,GAAyB,SAAzBN,QAAQ0C,IAAIC,SAAqB,CAG1BrC,EAAA,iBAFYoD,QAAQxF,QAAQ,0BAClBwF,QAAQxF,QAAQ,6BAErC,CAEAgE,EAAaC,SAAS,GAAG7B,IAASmD,QAAuBK,IAAc,CACrErF,IAAKqC,EAAKsB,MAAO,WAErB,CAEWjE,GAAA,IC3FfgB,EAAAA,QAAQmD,MAAMtC,QAAQ+D"}
1
+ {"version":3,"file":"index.umd.min.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n if (!notWorkspace && type === 'pnpm') {\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n return {\n wd, root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([dir, manifest]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["resolve","type","require","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","pnpmWorkspaceFilePath","default","pnpmWorkspaceFileContent","fs","readFileSync","pnpmWorkspace","load","Error","existsSync","packageJSON","JSON","parse","name","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","packages","value","Object","entries","reduce","acc","key","package","manifest","actionDone","actionRestore","Promise","r","mergePackageJson","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","option","command","aliases","action","bumper","options","selectedProjectsGraphEntries","length","mainfests","forEach","dir","push","passArgs","m","newVersion","bump","version","newManifest","renameSync","join","writeFileSync","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","commander","keys","jiekTempDir","paths","mkdirSync","rollupBinaryPath","replace","i","escapeManifestName","configFile","pkg","description","argv"],"mappings":"opCAQO,ICRHA,EDQOC,EAAO,GAElB,IACEC,QAAQF,QAAQ,mCACTC,EAAA,MACT,CAAQ,MAAc,CActBE,eAAsBC,IAChB,IAAAC,EAASC,EAAA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EG,EAAaP,EACjB,GAAGM,GAAsB,aAAaD,wBAExC9E,EAAAA,QAAG0D,cAAcsB,EAAYb,EAAcZ,IAC3C,IAAI1C,EAAS,GACT,GAAyB,SAAzBvB,QAAQ8E,IAAIC,SAAqB,CAG1BxD,EAAA,iBAFYjC,QAAQF,QAAQ,0BAClBE,QAAQF,QAAQ,6BAErC,CAEAoF,EAAaC,SAAS,GAAGlD,IAAS+D,QAAuBI,IAAc,CACrEzF,IAAKyD,EAAKgB,MAAO,WAErB,CAEWvC,GAAA,ICvDf,MAAMwD,EAAMrG,QAAQ,mBAGjB2F,EAAAvF,QAAAsE,QAAQ2B,EAAI3B,SACZ4B,YAAYD,EAAIC,aAChB5C,OAAO,gBAAiB,aAE3BtD,EAAAA,QAAQwB,MAAMlB,QAAQ6F"}
@@ -2,6 +2,7 @@ const defineOutput = (output) => output;
2
2
  const commonOutputOptions = defineOutput({
3
3
  dir: "dist",
4
4
  exports: "named",
5
+ interop: "auto",
5
6
  sourcemap: true
6
7
  });
7
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"commonOptions.esm.js","sources":["../../../src/rollup/utils/commonOptions.ts"],"sourcesContent":["import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n sourcemap: true\n})\n"],"names":[],"mappings":"AAEA,MAAM,YAAA,GAAe,CAA0B,MAAc,KAAA,MAAA,CAAA;AAEtD,MAAM,sBAAsB,YAAa,CAAA;AAAA,EAC9C,GAAK,EAAA,MAAA;AAAA,EACL,OAAS,EAAA,OAAA;AAAA,EACT,SAAW,EAAA,IAAA;AACb,CAAC;;;;"}
1
+ {"version":3,"file":"commonOptions.esm.js","sources":["../../../src/rollup/utils/commonOptions.ts"],"sourcesContent":["import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n"],"names":[],"mappings":"AAEA,MAAM,YAAA,GAAe,CAA0B,MAAc,KAAA,MAAA,CAAA;AAEtD,MAAM,sBAAsB,YAAa,CAAA;AAAA,EAC9C,GAAK,EAAA,MAAA;AAAA,EACL,OAAS,EAAA,OAAA;AAAA,EACT,OAAS,EAAA,MAAA;AAAA,EACT,SAAW,EAAA,IAAA;AACb,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- const e={dir:"dist",exports:"named",sourcemap:!0};export{e as commonOutputOptions};
1
+ const o={dir:"dist",exports:"named",interop:"auto",sourcemap:!0};export{o as commonOutputOptions};
2
2
  //# sourceMappingURL=commonOptions.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"commonOptions.esm.min.js","sources":["../../../src/rollup/utils/commonOptions.ts"],"sourcesContent":["import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n sourcemap: true\n})\n"],"names":["commonOutputOptions","dir","exports","sourcemap"],"mappings":"AAEA,MAEaA,EAAmC,CAC9CC,IAAK,OACLC,QAAS,QACTC,WAAW"}
1
+ {"version":3,"file":"commonOptions.esm.min.js","sources":["../../../src/rollup/utils/commonOptions.ts"],"sourcesContent":["import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n"],"names":["commonOutputOptions","dir","exports","interop","sourcemap"],"mappings":"AAEA,MAEaA,EAAmC,CAC9CC,IAAK,OACLC,QAAS,QACTC,QAAS,OACTC,WAAW"}
@@ -1,7 +1,9 @@
1
1
  import { resolve } from 'node:path';
2
2
  import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
3
+ import json from '@rollup/plugin-json';
3
4
  import autoprefixer from 'autoprefixer';
4
5
  import { dts } from 'rollup-plugin-dts';
6
+ import esbuild from 'rollup-plugin-esbuild';
5
7
  import postcss from 'rollup-plugin-postcss';
6
8
  import { createGlobalsLinkage } from './rollup/plugins/globals.esm.js';
7
9
  import skip from './rollup/plugins/skip.esm.js';
@@ -9,8 +11,6 @@ import { commonOutputOptions } from './rollup/utils/commonOptions.esm.js';
9
11
  import externalResolver from './rollup/utils/externalResolver.esm.js';
10
12
  import withMinify from './rollup/utils/withMinify.esm.js';
11
13
 
12
- const esbuildModule = require("rollup-plugin-esbuild");
13
- const esbuild = esbuildModule.default;
14
14
  const workspaceRoot = getWorkspaceDir();
15
15
  function resolveWorkspacePath(p) {
16
16
  return resolve(workspaceRoot, p);
@@ -35,6 +35,9 @@ const template = ({
35
35
  );
36
36
  const [globalsRegister, globalsOutput] = createGlobalsLinkage();
37
37
  const external = externalResolver();
38
+ const commonPlugins = [
39
+ json()
40
+ ];
38
41
  return [
39
42
  {
40
43
  input: exportsEntries,
@@ -47,6 +50,7 @@ const template = ({
47
50
  })
48
51
  ],
49
52
  plugins: [
53
+ commonPlugins,
50
54
  globalsRegister({ external }),
51
55
  styled && skip({ patterns: [/\.s?css$/] }),
52
56
  esbuild(),
@@ -72,6 +76,7 @@ const template = ({
72
76
  })
73
77
  ],
74
78
  plugins: [
79
+ commonPlugins,
75
80
  globalsOutput,
76
81
  styled && postcss({
77
82
  plugins: [autoprefixer],
@@ -98,6 +103,7 @@ const template = ({
98
103
  }
99
104
  ],
100
105
  plugins: [
106
+ commonPlugins,
101
107
  styled && skip({ patterns: [/\.s?css$/] }),
102
108
  dts({ tsconfig: resolveWorkspacePath("tsconfig.dts.json") }),
103
109
  {
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.esm.js","sources":["../src/rollup/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuildModule = require('rollup-plugin-esbuild')\nimport postcss from 'rollup-plugin-postcss'\nconst esbuild = esbuildModule.default\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n input: input,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAMA,MAAO,gBAAgB,OAAQ,CAAA,uBAAA,CAAA,CAAA;AAE/B,MAAM,UAAU,aAAc,CAAA,OAAA,CAAA;AAQ9B,MAAM,gBAAgB,eAAgB,EAAA,CAAA;AACtC,SAAS,qBAAqB,CAAW,EAAA;AACvC,EAAO,OAAA,OAAA,CAAQ,eAAe,CAAC,CAAA,CAAA;AACjC,CAAA;AAEO,MAAM,WAAW,CACtB;AAAA,EACE,MAAS,GAAA,KAAA;AAAA,EACT,OAAS,EAAA;AAAA,IACP,KAAA,EAAO,eAAe,EAAC;AAAA,IACvB,KAAA,EAAO,eAAe,EAAC;AAAA,IACvB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port { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonPlugins = [\n json()\n ]\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n input: input,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,gBAAgB,eAAgB,EAAA,CAAA;AACtC,SAAS,qBAAqB,CAAW,EAAA;AACvC,EAAO,OAAA,OAAA,CAAQ,eAAe,CAAC,CAAA,CAAA;AACjC,CAAA;AAEO,MAAM,WAAW,CACtB;AAAA,EACE,MAAS,GAAA,KAAA;AAAA,EACT,OAAS,EAAA;AAAA,IACP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A,aACF;AAAA,WACF;AAAA,SACF;AAAA,QACA,UAAA;AAAA,OACF;AAAA,MACA,QAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
@@ -1,2 +1,2 @@
1
- import{resolve as e}from"node:path";import{getWorkspaceDir as r}from"@jiek/utils/getWorkspaceDir";import s from"autoprefixer";import{dts as t}from"rollup-plugin-dts";import i from"rollup-plugin-postcss";import{createGlobalsLinkage as o}from"./rollup/plugins/globals.esm.min.js";import n from"./rollup/plugins/skip.esm.min.js";import{commonOutputOptions as l}from"./rollup/utils/commonOptions.esm.min.js";import p from"./rollup/utils/externalResolver.esm.min.js";import m from"./rollup/utils/withMinify.esm.min.js";const u=require("rollup-plugin-esbuild").default,a=r();const c=({styled:r=!1,plugins:{index:c=[],entry:d=[],dts:f=[]}={}}={},g)=>{if(!g.name)throw new Error("pkg.name is required");const j=g.name.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())),x=Object.fromEntries(Object.entries(g.exports??{}).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,r])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof r?r:r["inner-src"]]))),[y,$]=o(),b=p();return[{input:x,output:[...m({...l,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[y({external:b}),r&&n({patterns:[/\.s?css$/]}),u(),c]},...Object.entries(x).map((([e,t])=>{const o=j+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())));return{input:t,output:[...m({...l,name:o,format:"iife",entryFileNames:`${e}.iife.js`}),...m({...l,name:o,format:"umd",entryFileNames:`${e}.umd.js`})],plugins:[$,r&&i({plugins:[s],minimize:!0,sourceMap:!0,extract:`${e}.css`}),u(),d],external:b}})),{input:x,output:[{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0},{dir:"dist"}],plugins:[r&&n({patterns:[/\.s?css$/]}),t({tsconfig:(v="tsconfig.dts.json",e(a,v))}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,r){for(const e of Object.values(r))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${g.name}'`))}},f],external:b}];var v};export{c as template};
1
+ import{resolve as e}from"node:path";import{getWorkspaceDir as r}from"@jiek/utils/getWorkspaceDir";import s from"@rollup/plugin-json";import t from"autoprefixer";import{dts as o}from"rollup-plugin-dts";import i from"rollup-plugin-esbuild";import n from"rollup-plugin-postcss";import{createGlobalsLinkage as p}from"./rollup/plugins/globals.esm.min.js";import l from"./rollup/plugins/skip.esm.min.js";import{commonOutputOptions as m}from"./rollup/utils/commonOptions.esm.min.js";import u from"./rollup/utils/externalResolver.esm.min.js";import a from"./rollup/utils/withMinify.esm.min.js";const c=r();const d=({styled:r=!1,plugins:{index:d=[],entry:f=[],dts:g=[]}={}}={},j)=>{if(!j.name)throw new Error("pkg.name is required");const x=j.name.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())),y=Object.fromEntries(Object.entries(j.exports??{}).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,r])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof r?r:r["inner-src"]]))),[$,b]=p(),v=u(),w=[s()];return[{input:y,output:[...a({...m,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[w,$({external:v}),r&&l({patterns:[/\.s?css$/]}),i(),d]},...Object.entries(y).map((([e,s])=>{const o=x+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())));return{input:s,output:[...a({...m,name:o,format:"iife",entryFileNames:`${e}.iife.js`}),...a({...m,name:o,format:"umd",entryFileNames:`${e}.umd.js`})],plugins:[w,b,r&&n({plugins:[t],minimize:!0,sourceMap:!0,extract:`${e}.css`}),i(),f],external:v}})),{input:y,output:[{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0},{dir:"dist"}],plugins:[w,r&&l({patterns:[/\.s?css$/]}),o({tsconfig:(O="tsconfig.dts.json",e(c,O))}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,r){for(const e of Object.values(r))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${j.name}'`))}},g],external:v}];var O};export{d as template};
2
2
  //# sourceMappingURL=rollup.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.esm.min.js","sources":["../src/rollup/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuildModule = require('rollup-plugin-esbuild')\nimport postcss from 'rollup-plugin-postcss'\nconst esbuild = esbuildModule.default\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n input: input,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n"],"names":["esbuild","require","default","workspaceRoot","getWorkspaceDir","template","styled","plugins","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","name","Error","namePrefix","replace","_","$1","toUpperCase","exportsEntries","Object","fromEntries","entries","exports","filter","key","test","value","map","globalsRegister","globalsOutput","createGlobalsLinkage","external","externalResolver","input","output","withMinify","commonOutputOptions","format","entryFileNames","preserveModules","skip","patterns","outputName","postcss","autoprefixer","minimize","sourceMap","extract","dir","tsconfig","p","resolve","generateBundle","bundle","file","values","code"],"mappings":"kgBAMA,MAEMA,EAFiBC,QAAQ,yBAEDC,QAQxBC,EAAgBC,IAKf,MAAMC,EAAW,EAEpBC,UAAS,EACTC,SACEC,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KAQI,IAACA,EAAIC,KACD,MAAA,IAAIC,MAAM,wBAEZ,MAAAC,EAAaH,EAChBC,KACAG,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,gBAClCC,EAAiBC,OAAOC,YAC5BD,OAAOE,QAAQX,EAAIY,SAAW,CAAA,GAE3BC,QAAO,EAAEC,MAAU,qBAAqBC,KAAKD,KAE7CD,QAAO,EAAI,CAAAG,KAA4B,iBAAVA,GAAsBA,EAAM,cAAgBA,EAAc,SACvFC,KAAI,EAAEH,EAAKE,KAAW,CACrBF,EACGV,QAAQ,OAAQ,SAChBA,QAAQ,QAAS,IACH,iBAAVY,EAAqBA,EAAQA,EAAM,kBAIzCE,EAAiBC,GAAiBC,IACnCC,EAAWC,IAEV,MAAA,CACL,CACEC,MAAOf,EACPgB,OAAQ,IACHC,EAAW,IACTC,EACHC,OAAQ,MACRC,eAAgB,gBAChBC,iBAAiB,KAGrBpC,QAAS,CACPyB,EAAgB,CAAEG,aAClB7B,GAAUsC,EAAK,CAAEC,SAAU,CAAC,cAC5B7C,IACAS,OAGDc,OAAOE,QAAQH,GAAgBS,KAAI,EAAEhB,EAAMsB,MAC5C,MAAMS,EAAa7B,GACR,UAATF,EAAmB,GACjBA,EAAKG,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,iBAGvC,MAAA,CACLgB,QACAC,OAAQ,IACHC,EAAW,IACTC,EACHzB,KAAM+B,EACNL,OAAQ,OACRC,eAAgB,GAAG3B,iBAElBwB,EAAW,IACTC,EACHzB,KAAM+B,EACNL,OAAQ,MACRC,eAAgB,GAAG3B,cAGvBR,QAAS,CACP0B,EACA3B,GAAUyC,EAAQ,CAChBxC,QAAS,CAACyC,GACVC,UAAU,EACVC,WAAW,EACXC,QAAS,GAAGpC,UAEdf,IACAW,GAEFwB,WACF,IAEF,CACEE,MAAOf,EACPgB,OAAQ,CACN,CACEc,IAAK,OACLV,eAAgB,EAAG3B,UAAW,GAAGA,EAAKG,QAAQ,SAAU,eACxDyB,iBAAiB,GAEnB,CACES,IAAK,SAGT7C,QAAS,CACPD,GAAUsC,EAAK,CAAEC,SAAU,CAAC,cAC5BjC,EAAI,CAAEyC,UA1HgBC,EA0He,oBAzHpCC,EAAQpD,EAAemD,MA0HxB,CACEvC,KAAM,wCAKN,cAAAyC,CAAerC,EAAGsC,GAChB,IAAA,MAAWC,KAAQnC,OAAOoC,OAAOF,GACzB,SAAUC,IAEXA,EAAAE,KAAOF,EAAKE,KAAK1C,QACpB,iCACA,mBAAmBJ,EAAIC,SAG7B,GAEFF,GAEFsB,aA9IN,IAA8BmB,CAgJ5B"}
1
+ {"version":3,"file":"rollup.esm.min.js","sources":["../src/rollup/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonPlugins = [\n json()\n ]\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n input: input,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n"],"names":["workspaceRoot","getWorkspaceDir","template","styled","plugins","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","name","Error","namePrefix","replace","_","$1","toUpperCase","exportsEntries","Object","fromEntries","entries","exports","filter","key","test","value","map","globalsRegister","globalsOutput","createGlobalsLinkage","external","externalResolver","commonPlugins","json","input","output","withMinify","commonOutputOptions","format","entryFileNames","preserveModules","skip","patterns","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","dir","tsconfig","p","resolve","generateBundle","bundle","file","values","code"],"mappings":"0kBAgBA,MAAMA,EAAgBC,IAKf,MAAMC,EAAW,EAEpBC,UAAS,EACTC,SACEC,MAAOC,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,WACF,IAEF,CACEI,MAAOjB,EACPkB,OAAQ,CACN,CACEe,IAAK,OACLX,eAAgB,EAAG7B,UAAW,GAAGA,EAAKG,QAAQ,SAAU,eACxD2B,iBAAiB,GAEnB,CACEU,IAAK,SAGThD,QAAS,CACP8B,EACA/B,GAAUwC,EAAK,CAAEC,SAAU,CAAC,cAC5BnC,EAAI,CAAE4C,UAhIgBC,EAgIe,oBA/HpCC,EAAQvD,EAAesD,MAgIxB,CACE1C,KAAM,wCAKN,cAAA4C,CAAexC,EAAGyC,GAChB,IAAA,MAAWC,KAAQtC,OAAOuC,OAAOF,GACzB,SAAUC,IAEXA,EAAAE,KAAOF,EAAKE,KAAK7C,QACpB,iCACA,mBAAmBJ,EAAIC,SAG7B,GAEFF,GAEFsB,aApJN,IAA8BsB,CAsJ5B"}
@@ -1,6 +1,14 @@
1
- var jiekrollup = (function (exports, node_path, getWorkspaceDir, autoprefixer, rollupPluginDts, postcss, terser) {
1
+ var jiekrollup = (function (exports, node_path, getWorkspaceDir, json, autoprefixer, rollupPluginDts, esbuild, postcss, terser) {
2
2
  'use strict';
3
3
 
4
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
5
+
6
+ var json__default = /*#__PURE__*/_interopDefault(json);
7
+ var autoprefixer__default = /*#__PURE__*/_interopDefault(autoprefixer);
8
+ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
9
+ var postcss__default = /*#__PURE__*/_interopDefault(postcss);
10
+ var terser__default = /*#__PURE__*/_interopDefault(terser);
11
+
4
12
  function globalResolver(external) {
5
13
  if (external.startsWith("@zodui/")) {
6
14
  return external.replace(/[@/-](\w)/g, (_, c) => c.toUpperCase());
@@ -70,6 +78,7 @@ var jiekrollup = (function (exports, node_path, getWorkspaceDir, autoprefixer, r
70
78
  const commonOutputOptions = defineOutput({
71
79
  dir: "dist",
72
80
  exports: "named",
81
+ interop: "auto",
73
82
  sourcemap: true
74
83
  });
75
84
 
@@ -87,13 +96,11 @@ var jiekrollup = (function (exports, node_path, getWorkspaceDir, autoprefixer, r
87
96
  {
88
97
  ...output,
89
98
  entryFileNames: output.entryFileNames?.replace(/(\.js)$/, ".min$1"),
90
- plugins: [...output.plugins ?? [], terser()]
99
+ plugins: [...output.plugins ?? [], terser__default.default()]
91
100
  }
92
101
  ];
93
102
  }
94
103
 
95
- const esbuildModule = require("rollup-plugin-esbuild");
96
- const esbuild = esbuildModule.default;
97
104
  const workspaceRoot = getWorkspaceDir.getWorkspaceDir();
98
105
  function resolveWorkspacePath(p) {
99
106
  return node_path.resolve(workspaceRoot, p);
@@ -118,6 +125,9 @@ var jiekrollup = (function (exports, node_path, getWorkspaceDir, autoprefixer, r
118
125
  );
119
126
  const [globalsRegister, globalsOutput] = createGlobalsLinkage();
120
127
  const external = externalResolver();
128
+ const commonPlugins = [
129
+ json__default.default()
130
+ ];
121
131
  return [
122
132
  {
123
133
  input: exportsEntries,
@@ -130,9 +140,10 @@ var jiekrollup = (function (exports, node_path, getWorkspaceDir, autoprefixer, r
130
140
  })
131
141
  ],
132
142
  plugins: [
143
+ commonPlugins,
133
144
  globalsRegister({ external }),
134
145
  styled && skip({ patterns: [/\.s?css$/] }),
135
- esbuild(),
146
+ esbuild__default.default(),
136
147
  indexPlugins
137
148
  ]
138
149
  },
@@ -155,14 +166,15 @@ var jiekrollup = (function (exports, node_path, getWorkspaceDir, autoprefixer, r
155
166
  })
156
167
  ],
157
168
  plugins: [
169
+ commonPlugins,
158
170
  globalsOutput,
159
- styled && postcss({
160
- plugins: [autoprefixer],
171
+ styled && postcss__default.default({
172
+ plugins: [autoprefixer__default.default],
161
173
  minimize: true,
162
174
  sourceMap: true,
163
175
  extract: `${name}.css`
164
176
  }),
165
- esbuild(),
177
+ esbuild__default.default(),
166
178
  entryPlugins
167
179
  ],
168
180
  external
@@ -181,6 +193,7 @@ var jiekrollup = (function (exports, node_path, getWorkspaceDir, autoprefixer, r
181
193
  }
182
194
  ],
183
195
  plugins: [
196
+ commonPlugins,
184
197
  styled && skip({ patterns: [/\.s?css$/] }),
185
198
  rollupPluginDts.dts({ tsconfig: resolveWorkspacePath("tsconfig.dts.json") }),
186
199
  {
@@ -211,5 +224,5 @@ var jiekrollup = (function (exports, node_path, getWorkspaceDir, autoprefixer, r
211
224
 
212
225
  return exports;
213
226
 
214
- })({}, node_path, getWorkspaceDir, autoprefixer, rollupPluginDts, postcss, terser);
227
+ })({}, node_path, getWorkspaceDir, json, autoprefixer, rollupPluginDts, esbuild, postcss, terser);
215
228
  //# sourceMappingURL=rollup.iife.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.iife.js","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/globals.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/externalResolver.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts"],"sourcesContent":["export default function (external: string) {\n if (external.startsWith('@zodui/')) {\n return external\n .replace(/[@/-](\\w)/g, (_, c) => c.toUpperCase())\n }\n return {\n react: 'React',\n // TODO `react/jsx-runtime` is not supported `umd`\n 'react/jsx-runtime': 'ReactJSXRuntime',\n // https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.development.js\n 'react-dom': 'ReactDOM',\n // https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.development.js\n // TODO make the library use the global variable `TDesignReact` replace `TDesign`\n 'tdesign-react/esm': 'TDesign',\n // https://cdn.jsdelivr.net/npm/tdesign-react@1.4.0/dist/tdesign.js\n // https://cdn.jsdelivr.net/npm/tdesign-react@1.4.0/dist/tdesign.css\n 'tdesign-icons-react': 'TDesignIconReact',\n // https://cdn.jsdelivr.net/npm/tdesign-icons-react@1.4.0/dist/index.js\n zod: 'Zod',\n '@zodui/core': 'ZodUICore',\n '@zodui/core/utils': 'ZodUICoreUtils',\n '@zodui/react': 'ZodUIReact'\n }[external]\n}\n","import type { Plugin, PluginImpl } from 'rollup'\n\nimport globalResolver from '../utils/globalResolver'\n\ninterface GlobalsOptions {\n external?: (string | RegExp)[]\n}\n\nexport function createGlobalsLinkage() {\n let globals = {}\n const dependencies = new Set<string>([])\n return [\n (({ external } = {}) => {\n return {\n name: 'globals',\n resolveId(id) {\n if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {\n dependencies.add(id)\n return { id, external: true }\n }\n return null\n },\n outputOptions(options) {\n globals = [...dependencies].reduce((acc, value) => ({\n ...acc,\n [value]: globalResolver(value)\n }), {})\n return { ...options, globals }\n }\n }\n }) as PluginImpl<GlobalsOptions>,\n { outputOptions: options => ({ ...options, globals }) } as Plugin\n ] as const\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n sourcemap: true\n})\n","export default function () {\n const cwd = process.cwd()\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkg = require(`${cwd}/package.json`)\n const { dependencies = {}, peerDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n}\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuildModule = require('rollup-plugin-esbuild')\nimport postcss from 'rollup-plugin-postcss'\nconst esbuild = esbuildModule.default\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n input: input,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n"],"names":["getWorkspaceDir","resolve","dts"],"mappings":";;;EAAA,uBAAA,CAAyB,QAAkB,EAAA;EACzC,EAAI,IAAA,QAAA,CAAS,UAAW,CAAA,SAAS,CAAG,EAAA;EAClC,IAAO,OAAA,QAAA,CACJ,QAAQ,YAAc,EAAA,CAAC,GAAG,CAAM,KAAA,CAAA,CAAE,aAAa,CAAA,CAAA;EAAA,GACpD;EACA,EAAO,OAAA;EAAA,IACL,KAAO,EAAA,OAAA;EAAA;EAAA,IAEP,mBAAqB,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;EAAA,QACzCC,oBAAI,EAAE,QAAA,EAAU,oBAAqB,CAAA,mBAAmB,GAAG,CAAA;EAAA,QAC3D;EAAA,UACE,IAAM,EAAA,uCAAA;EAAA;EAAA;EAAA;EAAA;EAAA,UAKN,cAAA,CAAe,GAAG,MAAQ,EAAA;EACxB,YAAA,KAAA,MAAW,IAAQ,IAAA,MAAA,CAAO,MAAO,CAAA,MAAM,CAAG,EAAA;EACxC,cAAA,IAAI,EAAE,MAAU,IAAA,IAAA,CAAA;EAAO,gBAAA,SAAA;EAEvB,cAAK,IAAA,CAAA,IAAA,GAAO,KAAK,IAAK,CAAA,OAAA;EAAA,gBACpB,gCAAA;EAAA,gBACA,CAAA,gBAAA,EAAmB,IAAI,IAAI,CAAA,CAAA,CAAA;EAAA,eAC7B,CAAA;EAAA,aACF;EAAA,WACF;EAAA,SACF;EAAA,QACA,UAAA;EAAA,OACF;EAAA,MACA,QAAA;EAAA,KACF;EAAA,GACF,CAAA;EACF;;;;;;;;;;"}
1
+ {"version":3,"file":"rollup.iife.js","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/globals.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/externalResolver.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts"],"sourcesContent":["export default function (external: string) {\n if (external.startsWith('@zodui/')) {\n return external\n .replace(/[@/-](\\w)/g, (_, c) => c.toUpperCase())\n }\n return {\n react: 'React',\n // TODO `react/jsx-runtime` is not supported `umd`\n 'react/jsx-runtime': 'ReactJSXRuntime',\n // https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.development.js\n 'react-dom': 'ReactDOM',\n // https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.development.js\n // TODO make the library use the global variable `TDesignReact` replace `TDesign`\n 'tdesign-react/esm': 'TDesign',\n // https://cdn.jsdelivr.net/npm/tdesign-react@1.4.0/dist/tdesign.js\n // https://cdn.jsdelivr.net/npm/tdesign-react@1.4.0/dist/tdesign.css\n 'tdesign-icons-react': 'TDesignIconReact',\n // https://cdn.jsdelivr.net/npm/tdesign-icons-react@1.4.0/dist/index.js\n zod: 'Zod',\n '@zodui/core': 'ZodUICore',\n '@zodui/core/utils': 'ZodUICoreUtils',\n '@zodui/react': 'ZodUIReact'\n }[external]\n}\n","import type { Plugin, PluginImpl } from 'rollup'\n\nimport globalResolver from '../utils/globalResolver'\n\ninterface GlobalsOptions {\n external?: (string | RegExp)[]\n}\n\nexport function createGlobalsLinkage() {\n let globals = {}\n const dependencies = new Set<string>([])\n return [\n (({ external } = {}) => {\n return {\n name: 'globals',\n resolveId(id) {\n if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {\n dependencies.add(id)\n return { id, external: true }\n }\n return null\n },\n outputOptions(options) {\n globals = [...dependencies].reduce((acc, value) => ({\n ...acc,\n [value]: globalResolver(value)\n }), {})\n return { ...options, globals }\n }\n }\n }) as PluginImpl<GlobalsOptions>,\n { outputOptions: options => ({ ...options, globals }) } as Plugin\n ] as const\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n","export default function () {\n const cwd = process.cwd()\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkg = require(`${cwd}/package.json`)\n const { dependencies = {}, peerDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n}\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonPlugins = [\n json()\n ]\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n input: input,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n 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AA,IACD;EAAA,MACE,KAAO,EAAA,cAAA;EAAA,MACP,MAAQ,EAAA;EAAA,QACN;EAAA,UACE,GAAK,EAAA,MAAA;EAAA,UACL,cAAA,EAAgB,CAAC,EAAE,IAAK,EAAA,KAAM,GAAG,IAAK,CAAA,OAAA,CAAQ,QAAU,EAAA,EAAE,CAAC,CAAA,SAAA,CAAA;EAAA,UAC3D,eAAiB,EAAA,IAAA;EAAA,SACnB;EAAA,QACA;EAAA,UACE,GAAK,EAAA,MAAA;EAAA,SACP;EAAA,OACF;EAAA,MACA,OAAS,EAAA;EAAA,QACP,aAAA;EAAA,QACA,UAAU,IAAK,CAAA,EAAE,UAAU,CAAC,UAAU,GAAG,CAAA;EAAA,QACzCG,oBAAI,EAAE,QAAA,EAAU,oBAAqB,CAAA,mBAAmB,GAAG,CAAA;EAAA,QAC3D;EAAA,UACE,IAAM,EAAA,uCAAA;EAAA;EAAA;EAAA;EAAA;EAAA,UAKN,cAAA,CAAe,GAAG,MAAQ,EAAA;EACxB,YAAA,KAAA,MAAW,IAAQ,IAAA,MAAA,CAAO,MAAO,CAAA,MAAM,CAAG,EAAA;EACxC,cAAA,IAAI,EAAE,MAAU,IAAA,IAAA,CAAA;EAAO,gBAAA,SAAA;EAEvB,cAAK,IAAA,CAAA,IAAA,GAAO,KAAK,IAAK,CAAA,OAAA;EAAA,gBACpB,gCAAA;EAAA,gBACA,CAAA,gBAAA,EAAmB,IAAI,IAAI,CAAA,CAAA,CAAA;EAAA,eAC7B,CAAA;EAAA,aACF;EAAA,WACF;EAAA,SACF;EAAA,QACA,UAAA;EAAA,OACF;EAAA,MACA,QAAA;EAAA,KACF;EAAA,GACF,CAAA;EACF;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- var jiekrollup=function(e,t,r,s,n,i,o){"use strict";function a(e){return e.startsWith("@zodui/")?e.replace(/[@/-](\w)/g,((e,t)=>t.toUpperCase())):{react:"React","react/jsx-runtime":"ReactJSXRuntime","react-dom":"ReactDOM","tdesign-react/esm":"TDesign","tdesign-icons-react":"TDesignIconReact",zod:"Zod","@zodui/core":"ZodUICore","@zodui/core/utils":"ZodUICoreUtils","@zodui/react":"ZodUIReact"}[e]}var c=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const l={dir:"dist",exports:"named",sourcemap:!0};function p(e){return[e,{...e,entryFileNames:e.entryFileNames?.replace(/(\.js)$/,".min$1"),plugins:[...e.plugins??[],o()]}]}const u=require("rollup-plugin-esbuild").default,d=r.getWorkspaceDir();return e.template=({styled:e=!1,plugins:{index:r=[],entry:o=[],dts:m=[]}={}}={},g)=>{if(!g.name)throw new Error("pkg.name is required");const f=g.name.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())),j=Object.fromEntries(Object.entries(g.exports??{}).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,t])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof t?t:t["inner-src"]]))),[x,$]=function(){let e={};const t=new Set([]);return[({external:r}={})=>({name:"globals",resolveId:e=>r?.some((t=>t instanceof RegExp?t.test(e):t===e))?(t.add(e),{id:e,external:!0}):null,outputOptions:r=>(e=[...t].reduce(((e,t)=>({...e,[t]:a(t)})),{}),{...r,globals:e})}),{outputOptions:t=>({...t,globals:e})}]}(),y=function(){const e=process.cwd(),t=require(`${e}/package.json`),{dependencies:r={},peerDependencies:s={}}=t;return Object.keys(r).concat(Object.keys(s)).map((e=>new RegExp(`^${e}(/.*)?$`)))}();return[{input:j,output:[...p({...l,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[x({external:y}),e&&c({patterns:[/\.s?css$/]}),u(),r]},...Object.entries(j).map((([t,r])=>{const n=f+("index"===t?"":t.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())));return{input:r,output:[...p({...l,name:n,format:"iife",entryFileNames:`${t}.iife.js`}),...p({...l,name:n,format:"umd",entryFileNames:`${t}.umd.js`})],plugins:[$,e&&i({plugins:[s],minimize:!0,sourceMap:!0,extract:`${t}.css`}),u(),o],external:y}})),{input:j,output:[{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0},{dir:"dist"}],plugins:[e&&c({patterns:[/\.s?css$/]}),n.dts({tsconfig:(b="tsconfig.dts.json",t.resolve(d,b))}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,t){for(const e of Object.values(t))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${g.name}'`))}},m],external:y}];var b},e}({},node_path,getWorkspaceDir,autoprefixer,rollupPluginDts,postcss,terser);
1
+ var jiekrollup=function(e,t,r,s,n,o,a,i,c){"use strict";function u(e){return e&&e.__esModule?e:{default:e}}var l=u(s),p=u(n),d=u(a),m=u(i),f=u(c);function g(e){return e.startsWith("@zodui/")?e.replace(/[@/-](\w)/g,((e,t)=>t.toUpperCase())):{react:"React","react/jsx-runtime":"ReactJSXRuntime","react-dom":"ReactDOM","tdesign-react/esm":"TDesign","tdesign-icons-react":"TDesignIconReact",zod:"Zod","@zodui/core":"ZodUICore","@zodui/core/utils":"ZodUICoreUtils","@zodui/react":"ZodUIReact"}[e]}var j=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const x={dir:"dist",exports:"named",interop:"auto",sourcemap:!0};function $(e){return[e,{...e,entryFileNames:e.entryFileNames?.replace(/(\.js)$/,".min$1"),plugins:[...e.plugins??[],f.default()]}]}const y=r.getWorkspaceDir();return e.template=({styled:e=!1,plugins:{index:r=[],entry:s=[],dts:n=[]}={}}={},a)=>{if(!a.name)throw new Error("pkg.name is required");const i=a.name.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())),c=Object.fromEntries(Object.entries(a.exports??{}).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,t])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof t?t:t["inner-src"]]))),[u,f]=function(){let e={};const t=new Set([]);return[({external:r}={})=>({name:"globals",resolveId:e=>r?.some((t=>t instanceof RegExp?t.test(e):t===e))?(t.add(e),{id:e,external:!0}):null,outputOptions:r=>(e=[...t].reduce(((e,t)=>({...e,[t]:g(t)})),{}),{...r,globals:e})}),{outputOptions:t=>({...t,globals:e})}]}(),b=function(){const e=process.cwd(),t=require(`${e}/package.json`),{dependencies:r={},peerDependencies:s={}}=t;return Object.keys(r).concat(Object.keys(s)).map((e=>new RegExp(`^${e}(/.*)?$`)))}(),v=[l.default()];return[{input:c,output:[...$({...x,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[v,u({external:b}),e&&j({patterns:[/\.s?css$/]}),d.default(),r]},...Object.entries(c).map((([t,r])=>{const n=i+("index"===t?"":t.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())));return{input:r,output:[...$({...x,name:n,format:"iife",entryFileNames:`${t}.iife.js`}),...$({...x,name:n,format:"umd",entryFileNames:`${t}.umd.js`})],plugins:[v,f,e&&m.default({plugins:[p.default],minimize:!0,sourceMap:!0,extract:`${t}.css`}),d.default(),s],external:b}})),{input:c,output:[{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0},{dir:"dist"}],plugins:[v,e&&j({patterns:[/\.s?css$/]}),o.dts({tsconfig:(O="tsconfig.dts.json",t.resolve(y,O))}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,t){for(const e of Object.values(t))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${a.name}'`))}},n],external:b}];var O},e}({},node_path,getWorkspaceDir,json,autoprefixer,rollupPluginDts,esbuild,postcss,terser);
2
2
  //# sourceMappingURL=rollup.iife.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.iife.min.js","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts","../src/rollup/plugins/globals.ts","../src/rollup/utils/externalResolver.ts"],"sourcesContent":["export default function (external: string) {\n if (external.startsWith('@zodui/')) {\n return external\n .replace(/[@/-](\\w)/g, (_, c) => c.toUpperCase())\n }\n return {\n react: 'React',\n // TODO `react/jsx-runtime` is not supported `umd`\n 'react/jsx-runtime': 'ReactJSXRuntime',\n // https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.development.js\n 'react-dom': 'ReactDOM',\n // https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.development.js\n // TODO make the library use the global variable `TDesignReact` replace `TDesign`\n 'tdesign-react/esm': 'TDesign',\n // https://cdn.jsdelivr.net/npm/tdesign-react@1.4.0/dist/tdesign.js\n // https://cdn.jsdelivr.net/npm/tdesign-react@1.4.0/dist/tdesign.css\n 'tdesign-icons-react': 'TDesignIconReact',\n // https://cdn.jsdelivr.net/npm/tdesign-icons-react@1.4.0/dist/index.js\n zod: 'Zod',\n '@zodui/core': 'ZodUICore',\n '@zodui/core/utils': 'ZodUICoreUtils',\n '@zodui/react': 'ZodUIReact'\n }[external]\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n sourcemap: true\n})\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuildModule = require('rollup-plugin-esbuild')\nimport postcss from 'rollup-plugin-postcss'\nconst esbuild = esbuildModule.default\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n input: input,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n","import type { Plugin, PluginImpl } from 'rollup'\n\nimport globalResolver from '../utils/globalResolver'\n\ninterface GlobalsOptions {\n external?: (string | RegExp)[]\n}\n\nexport function createGlobalsLinkage() {\n let globals = {}\n const dependencies = new Set<string>([])\n return [\n (({ external } = {}) => {\n return {\n name: 'globals',\n resolveId(id) {\n if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {\n dependencies.add(id)\n return { id, external: true }\n }\n return null\n },\n outputOptions(options) {\n globals = [...dependencies].reduce((acc, value) => ({\n ...acc,\n [value]: globalResolver(value)\n }), {})\n return { ...options, globals }\n }\n }\n }) as PluginImpl<GlobalsOptions>,\n { outputOptions: options => ({ ...options, globals }) } as Plugin\n ] as const\n}\n","export default function () {\n const cwd = process.cwd()\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkg = require(`${cwd}/package.json`)\n const { dependencies = {}, peerDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n}\n"],"names":["globalResolver","external","startsWith","replace","_","c","toUpperCase","react","zod","skip","options","name","load","id","patterns","some","pattern","includes","test","commonOutputOptions","dir","exports","sourcemap","withMinify","output","entryFileNames","plugins","terser","esbuild","require","default","workspaceRoot","getWorkspaceDir","styled","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","Error","namePrefix","$1","exportsEntries","Object","fromEntries","entries","filter","key","value","map","globalsRegister","globalsOutput","globals","dependencies","Set","resolveId","dep","RegExp","add","outputOptions","reduce","acc","createGlobalsLinkage","cwd","process","peerDependencies","keys","concat","externalResolver","input","format","preserveModules","outputName","postcss","autoprefixer","minimize","sourceMap","extract","tsconfig","p","resolve","generateBundle","bundle","file","values","code"],"mappings":"oDAAA,SAAAA,EAAyBC,GACnB,OAAAA,EAASC,WAAW,WACfD,EACJE,QAAQ,cAAc,CAACC,EAAGC,IAAMA,EAAEC,gBAEhC,CACLC,MAAO,QAEP,oBAAqB,kBAErB,YAAa,WAGb,oBAAqB,UAGrB,sBAAuB,mBAEvBC,IAAK,MACL,cAAe,YACf,oBAAqB,iBACrB,eAAgB,cAChBP,EACJ,C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eAAgB,EAAGd,UAAW,GAAGA,EAAKR,QAAQ,SAAU,eACxDsE,iBAAiB,GAEnB,CACErD,IAAK,SAGTM,QAAS,CACPO,GAAUxB,EAAK,CAAEK,SAAU,CAAC,cAC5BwB,EAAAA,IAAI,CAAE0C,UA1HgBC,EA0He,oBAzHpCC,EAAAA,QAAQnD,EAAekD,MA0HxB,CACEtE,KAAM,wCAKN,cAAAwE,CAAe/E,EAAGgF,GAChB,IAAA,MAAWC,KAAQxC,OAAOyC,OAAOF,GACzB,SAAUC,IAEXA,EAAAE,KAAOF,EAAKE,KAAKpF,QACpB,iCACA,mBAAmBqC,EAAI7B,SAG7B,GAEF4B,GAEFtC,aA9IN,IAA8BgF,CAgJ5B"}
1
+ {"version":3,"file":"rollup.iife.min.js","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts","../src/rollup/plugins/globals.ts","../src/rollup/utils/externalResolver.ts"],"sourcesContent":["export default function (external: string) {\n if (external.startsWith('@zodui/')) {\n return external\n .replace(/[@/-](\\w)/g, (_, c) => c.toUpperCase())\n }\n return {\n react: 'React',\n // TODO `react/jsx-runtime` is not supported `umd`\n 'react/jsx-runtime': 'ReactJSXRuntime',\n // https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.development.js\n 'react-dom': 'ReactDOM',\n // https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.development.js\n // TODO make the library use the global variable `TDesignReact` replace `TDesign`\n 'tdesign-react/esm': 'TDesign',\n // https://cdn.jsdelivr.net/npm/tdesign-react@1.4.0/dist/tdesign.js\n // https://cdn.jsdelivr.net/npm/tdesign-react@1.4.0/dist/tdesign.css\n 'tdesign-icons-react': 'TDesignIconReact',\n // https://cdn.jsdelivr.net/npm/tdesign-icons-react@1.4.0/dist/index.js\n zod: 'Zod',\n '@zodui/core': 'ZodUICore',\n '@zodui/core/utils': 'ZodUICoreUtils',\n '@zodui/react': 'ZodUIReact'\n }[external]\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonPlugins = [\n json()\n ]\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n input: input,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n","import type { Plugin, PluginImpl } from 'rollup'\n\nimport globalResolver from '../utils/globalResolver'\n\ninterface GlobalsOptions {\n external?: (string | RegExp)[]\n}\n\nexport function createGlobalsLinkage() {\n let globals = {}\n const dependencies = new Set<string>([])\n return [\n (({ external } = {}) => {\n return {\n name: 'globals',\n resolveId(id) {\n if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {\n dependencies.add(id)\n return { id, external: true }\n }\n return null\n },\n outputOptions(options) {\n globals = [...dependencies].reduce((acc, value) => ({\n ...acc,\n [value]: globalResolver(value)\n }), {})\n return { ...options, globals }\n }\n }\n }) as PluginImpl<GlobalsOptions>,\n { outputOptions: options => ({ ...options, globals }) } as Plugin\n ] as const\n}\n","export default function () {\n const cwd = process.cwd()\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkg = require(`${cwd}/package.json`)\n const { dependencies = {}, peerDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n}\n"],"names":["globalResolver","external","startsWith","replace","_","c","toUpperCase","react","zod","skip","options","name","load","id","patterns","some","pattern","includes","test","commonOutputOptions","dir","exports","interop","sourcemap","withMinify","output","entryFileNames","plugins","terser","workspaceRoot","getWorkspaceDir","styled","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","Error","namePrefix","$1","exportsEntries","Object","fromEntries","entries","filter","key","value","map","globalsRegister","globalsOutput","globals","dependencies","Set","resolveId","dep","RegExp","add","outputOptions","reduce","acc","createGlobalsLinkage","cwd","process","require","peerDependencies","keys","concat","externalResolver","commonPlugins","json","input","format","preserveModules","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","tsconfig","p","resolve","generateBundle","bundle","file","values","code"],"mappings":"kJAAA,SAAAA,EAAyBC,GACnB,OAAAA,EAASC,WAAW,WACfD,EACJE,QAAQ,cAAc,CAACC,EAAGC,IAAMA,EAAEC,gBAEhC,CACLC,MAAO,QAEP,oBAAqB,kBAErB,YAAa,WAGb,oBAAqB,UAGrB,sBAAuB,mBAEvBC,IAAK,MACL,cAAe,YACf,oBAAqB,iBACrB,eAAgB,cAChBP,EACJ,CCjBA,IAAAQ,EAAgB,CAACC,EAAU,CAAA,KAClB,CACLC,KAAM,OAEN,IAAAC,CAAKC,GACH,GACEH,EAAQI,UAAUC,MAAMC,GACH,iBAAZA,EACHH,EAAGI,SAASD,GACZA,EAAQE,KAAKL,KAGZ,MAAA,EAEX,IClBJ,MAEaM,EAAmC,CAC9CC,IAAK,OACLC,QAAS,QACTC,QAAS,OACTC,WAAW,GCLb,SAAAC,EAAyBC,GAIhB,MAAA,CACLA,EACA,IACKA,EACHC,eAAgBD,EAAOC,gBAAgBvB,QAAQ,UAAW,UAC1DwB,QAAS,IAAKF,EAAOE,SAAW,GAAKC,cAG3C,CCCA,MAAMC,EAAgBC,EAAgBA,oCAKd,EAEpBC,UAAS,EACTJ,SACEK,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KAQI,IAACA,EAAI3B,KACD,MAAA,IAAI4B,MAAM,wBAEZ,MAAAC,EAAaF,EAChB3B,KACAR,QAAQ,eAAe,CAACC,EAAGqC,IAAOA,EAA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