jiek 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +5 -0
- package/dist/cli.cjs.js +668 -0
- package/dist/cli.cjs.js.map +1 -0
- package/dist/cli.cjs.min.js +2 -0
- package/dist/{cli.umd.min.js.map → cli.cjs.min.js.map} +1 -1
- package/dist/commands/publish.esm.js +1 -1
- package/dist/commands/publish.esm.js.map +1 -1
- package/dist/commands/publish.esm.min.js +1 -1
- package/dist/commands/publish.esm.min.js.map +1 -1
- package/dist/index.cjs.js +6 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.cjs.min.js +2 -0
- package/dist/index.cjs.min.js.map +1 -0
- package/dist/rollup/utils/externalResolver.esm.js +5 -3
- package/dist/rollup/utils/externalResolver.esm.js.map +1 -1
- package/dist/rollup/utils/externalResolver.esm.min.js +1 -1
- package/dist/rollup/utils/externalResolver.esm.min.js.map +1 -1
- package/dist/rollup/utils/globalResolver.esm.js +3 -20
- package/dist/rollup/utils/globalResolver.esm.js.map +1 -1
- package/dist/rollup/utils/globalResolver.esm.min.js +1 -1
- package/dist/rollup/utils/globalResolver.esm.min.js.map +1 -1
- package/dist/rollup.cjs.js +227 -0
- package/dist/rollup.cjs.js.map +1 -0
- package/dist/rollup.cjs.min.js +2 -0
- package/dist/rollup.cjs.min.js.map +1 -0
- package/dist/rollup.d.ts +3 -0
- package/dist/rollup.esm.d.ts +3 -0
- package/dist/rollup.esm.js +11 -1
- package/dist/rollup.esm.js.map +1 -1
- package/dist/rollup.esm.min.js +1 -1
- package/dist/rollup.esm.min.js.map +1 -1
- package/package.json +4 -1
- package/dist/cli.iife.js +0 -658
- package/dist/cli.iife.js.map +0 -1
- package/dist/cli.iife.min.js +0 -2
- package/dist/cli.iife.min.js.map +0 -1
- package/dist/cli.umd.js +0 -661
- package/dist/cli.umd.js.map +0 -1
- package/dist/cli.umd.min.js +0 -2
- package/dist/index.iife.js +0 -11
- package/dist/index.iife.js.map +0 -1
- package/dist/index.iife.min.js +0 -2
- package/dist/index.iife.min.js.map +0 -1
- package/dist/index.umd.js +0 -12
- package/dist/index.umd.js.map +0 -1
- package/dist/index.umd.min.js +0 -2
- package/dist/index.umd.min.js.map +0 -1
- package/dist/rollup.iife.js +0 -228
- package/dist/rollup.iife.js.map +0 -1
- package/dist/rollup.iife.min.js +0 -2
- package/dist/rollup.iife.min.js.map +0 -1
- package/dist/rollup.umd.js +0 -229
- package/dist/rollup.umd.js.map +0 -1
- package/dist/rollup.umd.min.js +0 -2
- package/dist/rollup.umd.min.js.map +0 -1
@@ -0,0 +1,227 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var node_path = require('node:path');
|
4
|
+
var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
|
5
|
+
var json = require('@rollup/plugin-json');
|
6
|
+
var autoprefixer = require('autoprefixer');
|
7
|
+
var rollupPluginDts = require('rollup-plugin-dts');
|
8
|
+
var esbuild = require('rollup-plugin-esbuild');
|
9
|
+
var postcss = require('rollup-plugin-postcss');
|
10
|
+
var terser = require('@rollup/plugin-terser');
|
11
|
+
|
12
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
13
|
+
|
14
|
+
var json__default = /*#__PURE__*/_interopDefault(json);
|
15
|
+
var autoprefixer__default = /*#__PURE__*/_interopDefault(autoprefixer);
|
16
|
+
var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
|
17
|
+
var postcss__default = /*#__PURE__*/_interopDefault(postcss);
|
18
|
+
var terser__default = /*#__PURE__*/_interopDefault(terser);
|
19
|
+
|
20
|
+
function globalResolver(external) {
|
21
|
+
if (external.startsWith("node:")) {
|
22
|
+
return external.slice(5);
|
23
|
+
}
|
24
|
+
return external.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase());
|
25
|
+
}
|
26
|
+
|
27
|
+
function createGlobalsLinkage() {
|
28
|
+
let globals = {};
|
29
|
+
const dependencies = /* @__PURE__ */ new Set([]);
|
30
|
+
return [
|
31
|
+
({ external } = {}) => {
|
32
|
+
return {
|
33
|
+
name: "globals",
|
34
|
+
resolveId(id) {
|
35
|
+
if (external?.some((dep) => dep instanceof RegExp ? dep.test(id) : dep === id)) {
|
36
|
+
dependencies.add(id);
|
37
|
+
return { id, external: true };
|
38
|
+
}
|
39
|
+
return null;
|
40
|
+
},
|
41
|
+
outputOptions(options) {
|
42
|
+
globals = [...dependencies].reduce((acc, value) => ({
|
43
|
+
...acc,
|
44
|
+
[value]: globalResolver(value)
|
45
|
+
}), {});
|
46
|
+
return { ...options, globals };
|
47
|
+
}
|
48
|
+
};
|
49
|
+
},
|
50
|
+
{ outputOptions: (options) => ({ ...options, globals }) }
|
51
|
+
];
|
52
|
+
}
|
53
|
+
|
54
|
+
var skip = (options = {}) => {
|
55
|
+
return {
|
56
|
+
name: "skip",
|
57
|
+
// skip the specified files by `options.patterns`
|
58
|
+
load(id) {
|
59
|
+
if (options.patterns?.some(
|
60
|
+
(pattern) => typeof pattern === "string" ? id.includes(pattern) : pattern.test(id)
|
61
|
+
)) {
|
62
|
+
return "";
|
63
|
+
}
|
64
|
+
}
|
65
|
+
};
|
66
|
+
};
|
67
|
+
|
68
|
+
const defineOutput = (output) => output;
|
69
|
+
const commonOutputOptions = defineOutput({
|
70
|
+
dir: "dist",
|
71
|
+
exports: "named",
|
72
|
+
interop: "auto",
|
73
|
+
sourcemap: true
|
74
|
+
});
|
75
|
+
|
76
|
+
function externalResolver() {
|
77
|
+
const cwd = process.cwd();
|
78
|
+
const pkg = require(`${cwd}/package.json`);
|
79
|
+
const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg;
|
80
|
+
const external = Object.keys(dependencies).concat(Object.keys(peerDependencies)).concat(Object.keys(optionalDependencies));
|
81
|
+
return external.map((dep) => new RegExp(`^${dep}(/.*)?$`)).concat([
|
82
|
+
/^node:/
|
83
|
+
]);
|
84
|
+
}
|
85
|
+
|
86
|
+
function withMinify(output) {
|
87
|
+
return [
|
88
|
+
output,
|
89
|
+
{
|
90
|
+
...output,
|
91
|
+
entryFileNames: output.entryFileNames?.replace(/(\.js)$/, ".min$1"),
|
92
|
+
plugins: [...output.plugins ?? [], terser__default.default()]
|
93
|
+
}
|
94
|
+
];
|
95
|
+
}
|
96
|
+
|
97
|
+
const workspaceRoot = getWorkspaceDir.getWorkspaceDir();
|
98
|
+
function resolveWorkspacePath(p) {
|
99
|
+
return node_path.resolve(workspaceRoot, p);
|
100
|
+
}
|
101
|
+
const template = ({
|
102
|
+
styled = false,
|
103
|
+
plugins: {
|
104
|
+
index: indexPlugins = [],
|
105
|
+
entry: entryPlugins = [],
|
106
|
+
dts: dtsPlugins = []
|
107
|
+
} = {}
|
108
|
+
} = {}, pkg) => {
|
109
|
+
const { jiek: {
|
110
|
+
browser = false
|
111
|
+
} = {} } = pkg;
|
112
|
+
if (!pkg.name) {
|
113
|
+
throw new Error("pkg.name is required");
|
114
|
+
}
|
115
|
+
const namePrefix = pkg.name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase());
|
116
|
+
const exportsEntries = Object.fromEntries(
|
117
|
+
Object.entries(pkg.exports ?? {}).filter(([key]) => !/\.(json|css|scss)$/.test(key)).filter(([, value]) => typeof value === "object" && value["inner-src"] && value["import"]).map(([key, value]) => [
|
118
|
+
key.replace(/^\.$/, "index").replace(/^\.\//, ""),
|
119
|
+
typeof value === "string" ? value : value["inner-src"]
|
120
|
+
])
|
121
|
+
);
|
122
|
+
const [globalsRegister, globalsOutput] = createGlobalsLinkage();
|
123
|
+
const external = externalResolver();
|
124
|
+
const commonPlugins = [
|
125
|
+
json__default.default()
|
126
|
+
];
|
127
|
+
return [
|
128
|
+
{
|
129
|
+
input: exportsEntries,
|
130
|
+
output: [
|
131
|
+
...withMinify({
|
132
|
+
...commonOutputOptions,
|
133
|
+
format: "esm",
|
134
|
+
entryFileNames: "[name].esm.js",
|
135
|
+
preserveModules: true
|
136
|
+
})
|
137
|
+
],
|
138
|
+
plugins: [
|
139
|
+
commonPlugins,
|
140
|
+
globalsRegister({ external }),
|
141
|
+
styled && skip({ patterns: [/\.s?css$/] }),
|
142
|
+
esbuild__default.default(),
|
143
|
+
indexPlugins
|
144
|
+
]
|
145
|
+
},
|
146
|
+
...Object.entries(exportsEntries).map(([name, input]) => {
|
147
|
+
const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
|
148
|
+
return {
|
149
|
+
input,
|
150
|
+
output: browser ? [
|
151
|
+
...withMinify({
|
152
|
+
...commonOutputOptions,
|
153
|
+
name: outputName,
|
154
|
+
format: "iife",
|
155
|
+
entryFileNames: `${name}.iife.js`
|
156
|
+
}),
|
157
|
+
...withMinify({
|
158
|
+
...commonOutputOptions,
|
159
|
+
name: outputName,
|
160
|
+
format: "umd",
|
161
|
+
entryFileNames: `${name}.umd.js`
|
162
|
+
})
|
163
|
+
] : [
|
164
|
+
...withMinify({
|
165
|
+
...commonOutputOptions,
|
166
|
+
name: outputName,
|
167
|
+
format: "cjs",
|
168
|
+
entryFileNames: `${name}.cjs.js`
|
169
|
+
})
|
170
|
+
],
|
171
|
+
plugins: [
|
172
|
+
commonPlugins,
|
173
|
+
globalsOutput,
|
174
|
+
styled && postcss__default.default({
|
175
|
+
plugins: [autoprefixer__default.default],
|
176
|
+
minimize: true,
|
177
|
+
sourceMap: true,
|
178
|
+
extract: `${name}.css`
|
179
|
+
}),
|
180
|
+
esbuild__default.default(),
|
181
|
+
entryPlugins
|
182
|
+
],
|
183
|
+
external
|
184
|
+
};
|
185
|
+
}),
|
186
|
+
{
|
187
|
+
input: exportsEntries,
|
188
|
+
output: [
|
189
|
+
{
|
190
|
+
dir: "dist",
|
191
|
+
entryFileNames: ({ name }) => `${name.replace(/^src\//, "")}.esm.d.ts`,
|
192
|
+
preserveModules: true
|
193
|
+
},
|
194
|
+
{
|
195
|
+
dir: "dist"
|
196
|
+
}
|
197
|
+
],
|
198
|
+
plugins: [
|
199
|
+
commonPlugins,
|
200
|
+
styled && skip({ patterns: [/\.s?css$/] }),
|
201
|
+
rollupPluginDts.dts({ tsconfig: resolveWorkspacePath("tsconfig.dts.json") }),
|
202
|
+
{
|
203
|
+
name: "rollup-plugin-declare-module-replacer",
|
204
|
+
/**
|
205
|
+
* replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
|
206
|
+
* in output file generated
|
207
|
+
*/
|
208
|
+
generateBundle(_, bundle) {
|
209
|
+
for (const file of Object.values(bundle)) {
|
210
|
+
if (!("code" in file))
|
211
|
+
continue;
|
212
|
+
file.code = file.code.replace(
|
213
|
+
/declare module ['|"]\..*['|"]/g,
|
214
|
+
`declare module '${pkg.name}'`
|
215
|
+
);
|
216
|
+
}
|
217
|
+
}
|
218
|
+
},
|
219
|
+
dtsPlugins
|
220
|
+
],
|
221
|
+
external
|
222
|
+
}
|
223
|
+
];
|
224
|
+
};
|
225
|
+
|
226
|
+
exports.template = template;
|
227
|
+
//# sourceMappingURL=rollup.cjs.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"rollup.cjs.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 // a/b => AB\n // a-b => AB\n // a@b => AB\n // a@b/c => ABC\n // node:a => a\n // node:a_b => a_b\n if (external.startsWith('node:')) {\n return external.slice(5)\n }\n return external\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\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 = {}, optionalDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n .concat(Object.keys(optionalDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n .concat([\n /^node:/\n ])\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 jiek?: {\n browser?: boolean\n }\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n const { jiek: {\n browser = false\n } = {} } = pkg\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: browser ? [\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 ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs.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":["terser","getWorkspaceDir","resolve","json","esbuild","postcss","autoprefixer","dts"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,uBAAA,CAAyB,QAAkB,EAAA;AAOzC,EAAI,IAAA,QAAA,CAAS,UAAW,CAAA,OAAO,CAAG,EAAA;AAChC,IAAO,OAAA,QAAA,CAAS,MAAM,CAAC,CAAA,CAAA;AAAA,GACzB;AAC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GAAK,EAAA,MAAA;AAAA,UACL,cAAA,EAAgB,CAAC,EAAE,IAAK,EAAA,KAAM,GAAG,IAAK,CAAA,OAAA,CAAQ,QAAU,EAAA,EAAE,CAAC,CAAA,SAAA,CAAA;AAAA,UAC3D,eAAiB,EAAA,IAAA;AAAA,SACnB;AAAA,QACA;AAAA,UACE,GAAK,EAAA,MAAA;AAAA,SACP;AAAA,OACF;AAAA,MACA,OAAS,EAAA;AAAA,QACP,aAAA;AAAA,QACA,UAAU,IAAK,CAAA,EAAE,UAAU,CAAC,UAAU,GAAG,CAAA;AAAA,QACzCG,oBAAI,EAAE,QAAA,EAAU,oBAAqB,CAAA,mBAAmB,GAAG,CAAA;AAAA,QAC3D;AAAA,UACE,IAAM,EAAA,uCAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAKN,cAAA,CAAe,GAAG,MAAQ,EAAA;AACxB,YAAA,KAAA,MAAW,IAAQ,IAAA,MAAA,CAAO,MAAO,CAAA,MAAM,CAAG,EAAA;AACxC,cAAA,IAAI,EAAE,MAAU,IAAA,IAAA,CAAA;AAAO,gBAAA,SAAA;AAEvB,cAAK,IAAA,CAAA,IAAA,GAAO,KAAK,IAAK,CAAA,OAAA;AAAA,gBACpB,gCAAA;AAAA,gBACA,CAAA,gBAAA,EAAmB,IAAI,IAAI,CAAA,CAAA,CAAA;AAAA,eAC7B,CAAA;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,QACA,UAAA;AAAA,OACF;AAAA,MACA,QAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";var e=require("node:path"),t=require("@jiek/utils/getWorkspaceDir"),r=require("@rollup/plugin-json"),s=require("autoprefixer"),n=require("rollup-plugin-dts"),i=require("rollup-plugin-esbuild"),o=require("rollup-plugin-postcss"),a=require("@rollup/plugin-terser");function l(e){return e&&e.__esModule?e:{default:e}}var u=l(r),p=l(s),c=l(i),d=l(o),m=l(a);function f(e){return e.startsWith("node:")?e.slice(5):e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase()))}var g=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const j={dir:"dist",exports:"named",interop:"auto",sourcemap:!0};function x(e){return[e,{...e,entryFileNames:e.entryFileNames?.replace(/(\.js)$/,".min$1"),plugins:[...e.plugins??[],m.default()]}]}const y=t.getWorkspaceDir();exports.template=({styled:t=!1,plugins:{index:r=[],entry:s=[],dts:i=[]}={}}={},o)=>{const{jiek:{browser:a=!1}={}}=o;if(!o.name)throw new Error("pkg.name is required");const l=o.name.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())),m=Object.fromEntries(Object.entries(o.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"]]))),[$,b]=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]:f(t)})),{}),{...r,globals:e})}),{outputOptions:t=>({...t,globals:e})}]}(),k=function(){const e=process.cwd(),t=require(`${e}/package.json`),{dependencies:r={},peerDependencies:s={},optionalDependencies:n={}}=t;return Object.keys(r).concat(Object.keys(s)).concat(Object.keys(n)).map((e=>new RegExp(`^${e}(/.*)?$`))).concat([/^node:/])}(),q=[u.default()];return[{input:m,output:[...x({...j,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[q,$({external:k}),t&&g({patterns:[/\.s?css$/]}),c.default(),r]},...Object.entries(m).map((([e,r])=>{const n=l+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())));return{input:r,output:a?[...x({...j,name:n,format:"iife",entryFileNames:`${e}.iife.js`}),...x({...j,name:n,format:"umd",entryFileNames:`${e}.umd.js`})]:[...x({...j,name:n,format:"cjs",entryFileNames:`${e}.cjs.js`})],plugins:[q,b,t&&d.default({plugins:[p.default],minimize:!0,sourceMap:!0,extract:`${e}.css`}),c.default(),s],external:k}})),{input:m,output:[{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0},{dir:"dist"}],plugins:[q,t&&g({patterns:[/\.s?css$/]}),n.dts({tsconfig:(v="tsconfig.dts.json",e.resolve(y,v))}),{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 '${o.name}'`))}},i],external:k}];var v};
|
2
|
+
//# sourceMappingURL=rollup.cjs.min.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"rollup.cjs.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 // a/b => AB\n // a-b => AB\n // a@b => AB\n // a@b/c => ABC\n // node:a => a\n // node:a_b => a_b\n if (external.startsWith('node:')) {\n return external.slice(5)\n }\n return external\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\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 jiek?: {\n browser?: boolean\n }\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n const { jiek: {\n browser = false\n } = {} } = pkg\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: browser ? [\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 ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs.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 = {}, optionalDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n .concat(Object.keys(optionalDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n .concat([\n /^node:/\n ])\n}\n"],"names":["globalResolver","external","startsWith","slice","replace","_","$1","toUpperCase","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","jiek","browser","Error","namePrefix","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","optionalDependencies","keys","concat","externalResolver","commonPlugins","json","input","format","preserveModules","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","tsconfig","p","resolve","generateBundle","bundle","file","values","code"],"mappings":"8WAAA,SAAAA,EAAyBC,GAOnB,OAAAA,EAASC,WAAW,SACfD,EAASE,MAAM,GAEjBF,EACJG,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,eAC1C,CCNA,IAAAC,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,gBAAgBrB,QAAQ,UAAW,UAC1DsB,QAAS,IAAKF,EAAOE,SAAW,GAAKC,cAG3C,CCCA,MAAMC,EAAgBC,EAAgBA,mCAKd,EAEpBC,UAAS,EACTJ,SACEK,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KAWA,MAAQC,MAAMC,QACZA,GAAU,GACR,CAAA,GAAOF,EACP,IAACA,EAAI3B,KACD,MAAA,IAAI8B,MAAM,wBAEZ,MAAAC,EAAaJ,EAChB3B,KACAN,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,gBAClCmC,EAAiBC,OAAOC,YAC5BD,OAAOE,QAAQR,EAAIjB,SAAW,CAAA,GAE3B0B,QAAO,EAAEC,MAAU,qBAAqB9B,KAAK8B,KAE7CD,QAAO,EAAI,CAAAE,KAA4B,iBAAVA,GAAsBA,EAAM,cAAgBA,EAAc,SACvFC,KAAI,EAAEF,EAAK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UAAT/B,EAAmB,GACjBA,EAAKN,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,iBAGvC,MAAA,CACLkE,QACAjD,OAAQe,EAAU,IACbhB,EAAW,IACTL,EACHR,KAAMmE,EACNH,OAAQ,OACRjD,eAAgB,GAAGf,iBAElBa,EAAW,IACTL,EACHR,KAAMmE,EACNH,OAAQ,MACRjD,eAAgB,GAAGf,cAEnB,IACCa,EAAW,IACTL,EACHR,KAAMmE,EACNH,OAAQ,MACRjD,eAAgB,GAAGf,cAGvBgB,QAAS,CACP6C,EACApB,EACArB,GAAUgD,EAAAA,QAAQ,CAChBpD,QAAS,CAACqD,EAAAA,SACVC,UAAU,EACVC,WAAW,EACXC,QAAS,GAAGxE,UAEdkE,YACA1C,GAEFjC,WACF,IAEF,CACEwE,MAAO/B,EACPlB,OAAQ,CACN,CACEL,IAAK,OACLM,eAAgB,EAAGf,UAAW,GAAGA,EAAKN,QAAQ,SAAU,eACxDuE,iBAAiB,GAEnB,CACExD,IAAK,SAGTO,QAAS,CACP6C,EACAzC,GAAUtB,EAAK,CAAEK,SAAU,CAAC,cAC5BsB,EAAAA,IAAI,CAAEgD,UA7IgBC,EA6Ie,oBA5IpCC,EAAAA,QAAQzD,EAAewD,MA6IxB,CACE1E,KAAM,wCAKN,cAAA4E,CAAejF,EAAGkF,GAChB,IAAA,MAAWC,KAAQ7C,OAAO8C,OAAOF,GACzB,SAAUC,IAEXA,EAAAE,KAAOF,EAAKE,KAAKtF,QACpB,iCACA,mBAAmBiC,EAAI3B,SAG7B,GAEF0B,GAEFnC,aAjKN,IAA8BmF,CAmK5B"}
|
package/dist/rollup.d.ts
CHANGED
@@ -12,6 +12,9 @@ declare const template: ({ styled, plugins: { index: indexPlugins, entry: entryP
|
|
12
12
|
} | undefined;
|
13
13
|
} | undefined, pkg: {
|
14
14
|
name?: string;
|
15
|
+
jiek?: {
|
16
|
+
browser?: boolean;
|
17
|
+
};
|
15
18
|
exports?: Record<string, string | {
|
16
19
|
import: string;
|
17
20
|
'inner-src': string;
|
package/dist/rollup.esm.d.ts
CHANGED
@@ -12,6 +12,9 @@ declare const template: ({ styled, plugins: { index: indexPlugins, entry: entryP
|
|
12
12
|
} | undefined;
|
13
13
|
} | undefined, pkg: {
|
14
14
|
name?: string;
|
15
|
+
jiek?: {
|
16
|
+
browser?: boolean;
|
17
|
+
};
|
15
18
|
exports?: Record<string, string | {
|
16
19
|
import: string;
|
17
20
|
'inner-src': string;
|
package/dist/rollup.esm.js
CHANGED
@@ -23,6 +23,9 @@ const template = ({
|
|
23
23
|
dts: dtsPlugins = []
|
24
24
|
} = {}
|
25
25
|
} = {}, pkg) => {
|
26
|
+
const { jiek: {
|
27
|
+
browser = false
|
28
|
+
} = {} } = pkg;
|
26
29
|
if (!pkg.name) {
|
27
30
|
throw new Error("pkg.name is required");
|
28
31
|
}
|
@@ -61,7 +64,7 @@ const template = ({
|
|
61
64
|
const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
|
62
65
|
return {
|
63
66
|
input,
|
64
|
-
output: [
|
67
|
+
output: browser ? [
|
65
68
|
...withMinify({
|
66
69
|
...commonOutputOptions,
|
67
70
|
name: outputName,
|
@@ -74,6 +77,13 @@ const template = ({
|
|
74
77
|
format: "umd",
|
75
78
|
entryFileNames: `${name}.umd.js`
|
76
79
|
})
|
80
|
+
] : [
|
81
|
+
...withMinify({
|
82
|
+
...commonOutputOptions,
|
83
|
+
name: outputName,
|
84
|
+
format: "cjs",
|
85
|
+
entryFileNames: `${name}.cjs.js`
|
86
|
+
})
|
77
87
|
],
|
78
88
|
plugins: [
|
79
89
|
commonPlugins,
|
package/dist/rollup.esm.js.map
CHANGED
@@ -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 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,KAAA,EAAO,eAAe,EAAC;AAAA,IACvB,KAAA,EAAO,eAAe,EAAC;AAAA,IACvB,GAAA,EAAK,aAAa,EAAC;AAAA,MACjB,EAAC;AACP,CAUI,GAAA,IACJ,
|
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 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 jiek?: {\n browser?: boolean\n }\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n const { jiek: {\n browser = false\n } = {} } = pkg\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: browser ? [\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 ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs.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 }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A,MAAA;AAAA,SACP;AAAA,OACF;AAAA,MACA,OAAS,EAAA;AAAA,QACP,aAAA;AAAA,QACA,UAAU,IAAK,CAAA,EAAE,UAAU,CAAC,UAAU,GAAG,CAAA;AAAA,QACzC,IAAI,EAAE,QAAA,EAAU,oBAAqB,CAAA,mBAAmB,GAAG,CAAA;AAAA,QAC3D;AAAA,UACE,IAAM,EAAA,uCAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAKN,cAAA,CAAe,GAAG,MAAQ,EAAA;AACxB,YAAA,KAAA,MAAW,IAAQ,IAAA,MAAA,CAAO,MAAO,CAAA,MAAM,CAAG,EAAA;AACxC,cAAA,IAAI,EAAE,MAAU,IAAA,IAAA,CAAA;AAAO,gBAAA,SAAA;AAEvB,cAAK,IAAA,CAAA,IAAA,GAAO,KAAK,IAAK,CAAA,OAAA;AAAA,gBACpB,gCAAA;AAAA,gBACA,CAAA,gBAAA,EAAmB,IAAI,IAAI,CAAA,CAAA,CAAA;AAAA,eAC7B,CAAA;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,QACA,UAAA;AAAA,OACF;AAAA,MACA,QAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
|
package/dist/rollup.esm.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
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
|
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 f=({styled:r=!1,plugins:{index:f=[],entry:d=[],dts:g=[]}={}}={},j)=>{const{jiek:{browser:x=!1}={}}=j;if(!j.name)throw new Error("pkg.name is required");const y=j.name.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())),$=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,w]=p(),k=u(),v=[s()];return[{input:$,output:[...a({...m,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[v,b({external:k}),r&&l({patterns:[/\.s?css$/]}),i(),f]},...Object.entries($).map((([e,s])=>{const o=y+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())));return{input:s,output:x?[...a({...m,name:o,format:"iife",entryFileNames:`${e}.iife.js`}),...a({...m,name:o,format:"umd",entryFileNames:`${e}.umd.js`})]:[...a({...m,name:o,format:"cjs",entryFileNames:`${e}.cjs.js`})],plugins:[v,w,r&&n({plugins:[t],minimize:!0,sourceMap:!0,extract:`${e}.css`}),i(),d],external:k}})),{input:$,output:[{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0},{dir:"dist"}],plugins:[v,r&&l({patterns:[/\.s?css$/]}),o({tsconfig:(F="tsconfig.dts.json",e(c,F))}),{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:k}];var F};export{f 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 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,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,
|
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 jiek?: {\n browser?: boolean\n }\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n const { jiek: {\n browser = false\n } = {} } = pkg\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: browser ? [\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 ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs.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","jiek","browser","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,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KAWA,MAAQC,MAAMC,QACZA,GAAU,GACR,CAAA,GAAOF,EACP,IAACA,EAAIG,KACD,MAAA,IAAIC,MAAM,wBAEZ,MAAAC,EAAaL,EAChBG,KACAG,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,gBAClCC,EAAiBC,OAAOC,YAC5BD,OAAOE,QAAQb,EAAIc,SAAW,CAAA,GAE3BC,QAAO,EAAEC,MAAU,qBAAqBC,KAAKD,KAE7CD,QAAO,EAAI,CAAA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