@visulima/packem 2.0.0-alpha.43 → 2.0.0-alpha.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/LICENSE.md +156 -102
- package/dist/builder/typedoc/generate-reference-documentation.d.ts +4 -0
- package/dist/builder/typedoc/index.js +3 -160
- package/dist/cli/commands/add.d.ts +4 -0
- package/dist/cli/commands/build.d.ts +21 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/migrate.d.ts +21 -0
- package/dist/cli/commands/utils/css-loader-dependencies.d.ts +2 -0
- package/dist/cli/index.js +52 -1377
- package/dist/config/index.js +1 -4
- package/dist/config/preset/auto.d.ts +3 -0
- package/dist/config/preset/react.js +1 -43
- package/dist/config/preset/solid.js +1 -72
- package/dist/config/preset/svelte.d.ts +1 -1
- package/dist/config/preset/svelte.js +1 -44
- package/dist/config/preset/utils/infer-entries.d.ts +12 -0
- package/dist/config/preset/utils/overwrite-with-publish-config.d.ts +4 -0
- package/dist/config/preset/vue.js +1 -33
- package/dist/config/utils/find-packem-file.d.ts +2 -0
- package/dist/config/utils/load-package-json.d.ts +6 -0
- package/dist/config/utils/load-packem-config.d.ts +7 -0
- package/dist/config/utils/load-preset.d.ts +4 -0
- package/dist/config/utils/load-tsconfig.d.ts +5 -0
- package/dist/config/utils/prepare-entries.d.ts +4 -0
- package/dist/index.js +1 -30
- package/dist/jit/create-stub.d.ts +4 -0
- package/dist/packem/build.d.ts +21 -0
- package/dist/packem/index.d.ts +25 -0
- package/dist/packem/utils/brotli-size.d.ts +2 -0
- package/dist/packem/utils/group-by-keys.d.ts +3 -0
- package/dist/packem/utils/gzip-size.d.ts +2 -0
- package/dist/packem_shared/browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js +1 -0
- package/dist/packem_shared/create-or-update-key-storage-C0tWtgSr.js +3 -0
- package/dist/packem_shared/default-5XUc-qHw.js +1 -0
- package/dist/packem_shared/default-B2EOH52z.js +1 -0
- package/dist/packem_shared/default-BYM_JvQL.js +1 -0
- package/dist/packem_shared/default-B_dUKZ_J.js +1 -0
- package/dist/packem_shared/default-DsjSAv7m.js +1 -0
- package/dist/packem_shared/esbuildPlugin-pPPsJB9N-YI_X-5wr.js +3 -0
- package/dist/packem_shared/index-CUp9WuCG.js +1 -0
- package/dist/packem_shared/index-ChtiNkgT.js +174 -0
- package/dist/packem_shared/isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js +1 -0
- package/dist/packem_shared/isolatedDeclarationsSwcTransformer-Ch2AgtWC-B-0lOgFf.js +1 -0
- package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.js +3 -0
- package/dist/packem_shared/oxcResolvePlugin-Ccef6pyL-D14z9S9i.js +1 -0
- package/dist/packem_shared/oxcTransformPlugin-DfVQouIB-Cpfv95eA.js +4 -0
- package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-CauidYR5.js +6 -0
- package/dist/packem_shared/swcPlugin-Boip4lWG-CwJ-HVJc.js +1 -0
- package/dist/rollup/build-types.d.ts +5 -0
- package/dist/rollup/build.d.ts +5 -0
- package/dist/rollup/get-rollup-options.d.ts +5 -0
- package/dist/rollup/plugins/css/loaders/less.js +1 -1
- package/dist/rollup/plugins/css/loaders/lightningcss.js +1 -1
- package/dist/rollup/plugins/css/loaders/postcss.js +1 -1
- package/dist/rollup/plugins/css/loaders/sass.js +1 -1
- package/dist/rollup/plugins/css/loaders/sourcemap.js +1 -1
- package/dist/rollup/plugins/css/loaders/stylus.js +1 -1
- package/dist/rollup/plugins/css/loaders/tailwindcss.js +1 -1
- package/dist/rollup/plugins/css/minifiers/cssnano.js +1 -1
- package/dist/rollup/plugins/css/minifiers/lightningcss.js +1 -1
- package/dist/rollup/plugins/esbuild/index.js +1 -1
- package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.js +1 -1
- package/dist/rollup/plugins/oxc/oxc-transformer.js +1 -1
- package/dist/rollup/plugins/sucrase/index.js +1 -1
- package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.js +1 -1
- package/dist/rollup/plugins/swc/swc-plugin.js +1 -1
- package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -1
- package/dist/rollup/utils/resolve-aliases.d.ts +4 -0
- package/dist/rollup/watch.d.ts +5 -0
- package/dist/utils/clean-distribution-directories.d.ts +4 -0
- package/dist/utils/create-or-update-key-storage.d.ts +3 -0
- package/dist/utils/extract-export-filenames.d.ts +16 -0
- package/dist/utils/find-alternatives.d.ts +2 -0
- package/dist/utils/get-package-side-effect.d.ts +3 -0
- package/dist/utils/infer-export-type.d.ts +3 -0
- package/dist/utils/kill-process.d.ts +14 -0
- package/dist/utils/log-build-errors.d.ts +4 -0
- package/dist/utils/remove-old-cache-folders.d.ts +3 -0
- package/dist/utils/warn-legacy-cjs.d.ts +8 -0
- package/dist/validator/attw.d.ts +7 -0
- package/dist/validator/package-json/index.d.ts +4 -0
- package/dist/validator/package-json/validate-dependencies.d.ts +4 -0
- package/dist/validator/package-json/validate-engines.d.ts +4 -0
- package/dist/validator/package-json/validate-package-entries.d.ts +4 -0
- package/dist/validator/package-json/validate-package-fields.d.ts +4 -0
- package/dist/validator/validate-alias-entries.d.ts +3 -0
- package/dist/validator/validate-bundle-size.d.ts +4 -0
- package/package.json +1 -111
- package/dist/packem_shared/create-or-update-key-storage-Dd7b8-t1.js +0 -36
- package/dist/packem_shared/default-79SPobLI.js +0 -12
- package/dist/packem_shared/default-DWBYeUSC.js +0 -210
- package/dist/packem_shared/default-DaU6CQEi.js +0 -28
- package/dist/packem_shared/default-DavaZMwC.js +0 -32
- package/dist/packem_shared/default-DeYZ934H.js +0 -32
- package/dist/packem_shared/default-tUOOZ8w7.js +0 -42
- package/dist/packem_shared/default-wScAfTaq.js +0 -27
- package/dist/packem_shared/index-CTIRxV2x.js +0 -63
- package/dist/packem_shared/index-DzTDn4ad.js +0 -9521
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Pail } from "@visulima/pail";
|
|
2
|
+
import type { BuildEntry, TypeDocumentOptions } from "../../types.d.ts";
|
|
3
|
+
declare const generateReferenceDocumentation: (options: TypeDocumentOptions, entries: BuildEntry[], outputDirectory: string, logger: Pail) => Promise<void>;
|
|
4
|
+
export default generateReferenceDocumentation;
|
|
@@ -1,160 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { readdirSync } from 'node:fs';
|
|
5
|
-
import { readFileSync, writeFileSync } from '@visulima/fs';
|
|
6
|
-
import { Application } from 'typedoc';
|
|
7
|
-
|
|
8
|
-
const generateReferenceDocumentation = async (options, entries, outputDirectory, logger) => {
|
|
9
|
-
if (entries.length === 0) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const { format, jsonFileName, marker, output, plugin, readmePath, ...typedocOptions } = options;
|
|
13
|
-
if (format === "inline" && readmePath === void 0) {
|
|
14
|
-
throw new Error("The `readmePath` option is required when using the `inline` format.");
|
|
15
|
-
}
|
|
16
|
-
if (format !== "inline" && typeof readmePath === "string") {
|
|
17
|
-
logger.warn({
|
|
18
|
-
message: "The `readmePath` option is only used when the `inline` format is used.",
|
|
19
|
-
prefix: "typedoc"
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
if (format === "json") {
|
|
23
|
-
if (jsonFileName === void 0) {
|
|
24
|
-
throw new Error("The `jsonFileName` option is required when using the `json` format.");
|
|
25
|
-
} else if (!jsonFileName.endsWith(".json")) {
|
|
26
|
-
throw new Error("The `jsonFileName` option must end with `.json`.");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (format !== "json" && typeof jsonFileName === "string") {
|
|
30
|
-
logger.warn({
|
|
31
|
-
message: "The `jsonFileName` option is only used when the `json` format is used.",
|
|
32
|
-
prefix: "typedoc"
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
const entryPoints = entries.map((entry) => entry.input);
|
|
36
|
-
const plugins = plugin ?? [];
|
|
37
|
-
plugins.push("typedoc-plugin-rename-defaults");
|
|
38
|
-
if (format === "inline" || format === "markdown") {
|
|
39
|
-
plugins.push("typedoc-plugin-markdown");
|
|
40
|
-
}
|
|
41
|
-
const app = await Application.bootstrapWithPlugins(
|
|
42
|
-
{
|
|
43
|
-
...typedocOptions,
|
|
44
|
-
compilerOptions: {
|
|
45
|
-
allowJs: true,
|
|
46
|
-
declaration: false,
|
|
47
|
-
declarationMap: false,
|
|
48
|
-
esModuleInterop: true,
|
|
49
|
-
module: 99,
|
|
50
|
-
// "ESNext"
|
|
51
|
-
moduleResolution: 100,
|
|
52
|
-
// Bundler,
|
|
53
|
-
noEmit: true,
|
|
54
|
-
noImplicitAny: false,
|
|
55
|
-
skipLibCheck: true,
|
|
56
|
-
sourceMap: false,
|
|
57
|
-
// Ensure we can parse the latest code
|
|
58
|
-
target: 99,
|
|
59
|
-
// ESNext
|
|
60
|
-
...typedocOptions.compilerOptions
|
|
61
|
-
},
|
|
62
|
-
entryPoints,
|
|
63
|
-
hideGenerator: true,
|
|
64
|
-
out: outputDirectory,
|
|
65
|
-
plugin: plugins,
|
|
66
|
-
...format === "inline" ? {
|
|
67
|
-
hideBreadcrumbs: true,
|
|
68
|
-
hidePageHeader: true,
|
|
69
|
-
navigation: false,
|
|
70
|
-
outputFileStrategy: "modules",
|
|
71
|
-
useCodeBlocks: true
|
|
72
|
-
} : {}
|
|
73
|
-
// we dont need the default loader
|
|
74
|
-
},
|
|
75
|
-
[]
|
|
76
|
-
);
|
|
77
|
-
const project = await app.convert();
|
|
78
|
-
if (project) {
|
|
79
|
-
if (format === "json") {
|
|
80
|
-
await app.generateJson(project, jsonFileName);
|
|
81
|
-
} else if (format === "html") {
|
|
82
|
-
await app.generateDocs(project, outputDirectory);
|
|
83
|
-
} else {
|
|
84
|
-
await app.generateOutputs(project);
|
|
85
|
-
if (format === "inline") {
|
|
86
|
-
if (marker === void 0) {
|
|
87
|
-
throw new Error("The `marker` option is required when using the `inline` format.");
|
|
88
|
-
}
|
|
89
|
-
const markdownPathsList = readdirSync(outputDirectory, {
|
|
90
|
-
withFileTypes: true
|
|
91
|
-
}).filter((item) => item.isFile());
|
|
92
|
-
let markdownContent = "";
|
|
93
|
-
for (const item of markdownPathsList) {
|
|
94
|
-
if (item.name === "README.md" && entries.length > 1) {
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
markdownContent += readFileSync(join(outputDirectory, item.name)).replaceAll(`<!-- ${marker}`, `<!-- _REPLACE_${marker}`).replaceAll(`<!-- \${marker}`, `<!-- _REPLACE_\\${marker}`);
|
|
98
|
-
}
|
|
99
|
-
if (markdownContent !== "") {
|
|
100
|
-
const readmeContent = readFileSync(readmePath);
|
|
101
|
-
const updatedReadmeContent = replaceContentWithinMarker(readmeContent, marker, `
|
|
102
|
-
${markdownContent}`);
|
|
103
|
-
if (!updatedReadmeContent) {
|
|
104
|
-
logger.error({
|
|
105
|
-
message: `Could not find the typedoc marker: <!-- ${marker} --><!-- /${marker} --> in ${readmePath}`,
|
|
106
|
-
prefix: "typedoc"
|
|
107
|
-
});
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (readmeContent === updatedReadmeContent) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (updatedReadmeContent) {
|
|
114
|
-
writeFileSync(
|
|
115
|
-
readmePath,
|
|
116
|
-
updatedReadmeContent.replaceAll(`<!-- _REPLACE_${marker}`, `<!-- ${marker}`).replaceAll(`<!-- _REPLACE_\\${marker}`, `<!-- \${marker}`),
|
|
117
|
-
{
|
|
118
|
-
overwrite: true
|
|
119
|
-
}
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const builder = async (context, cachePath, _, logged) => {
|
|
129
|
-
if (context.options.typedoc && context.options.typedoc.format !== void 0) {
|
|
130
|
-
let typedocVersion = "unknown";
|
|
131
|
-
if (context.pkg.dependencies?.typedoc) {
|
|
132
|
-
typedocVersion = context.pkg.dependencies.typedoc;
|
|
133
|
-
} else if (context.pkg.devDependencies?.typedoc) {
|
|
134
|
-
typedocVersion = context.pkg.devDependencies.typedoc;
|
|
135
|
-
}
|
|
136
|
-
if (cachePath) {
|
|
137
|
-
createOrUpdateKeyStorage("typedoc", cachePath, context.logger, true);
|
|
138
|
-
}
|
|
139
|
-
if (logged) {
|
|
140
|
-
context.logger.raw("\n");
|
|
141
|
-
}
|
|
142
|
-
context.logger.info({
|
|
143
|
-
message: `Using ${cyan("typedoc")} ${typedocVersion} to generate reference documentation`,
|
|
144
|
-
prefix: "typedoc"
|
|
145
|
-
});
|
|
146
|
-
await context.hooks.callHook("typedoc:before", context);
|
|
147
|
-
let outputDirectory = context.options.rootDir;
|
|
148
|
-
if (context.options.typedoc.output) {
|
|
149
|
-
outputDirectory = context.options.typedoc.output;
|
|
150
|
-
} else if (context.options.typedoc.format === "inline" && cachePath) {
|
|
151
|
-
outputDirectory = join(cachePath, "typedoc");
|
|
152
|
-
} else if (context.options.typedoc.format !== "json") {
|
|
153
|
-
outputDirectory = join(outputDirectory, "api-docs");
|
|
154
|
-
}
|
|
155
|
-
await generateReferenceDocumentation(context.options.typedoc, context.options.entries, outputDirectory, context.logger);
|
|
156
|
-
await context.hooks.callHook("typedoc:done", context);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export { builder as default };
|
|
1
|
+
var j=Object.defineProperty;var g=(e,o)=>j(e,"name",{value:o,configurable:!0});import{cyan as v}from"@visulima/colorize";import{join as h}from"@visulima/path";import{g as $,d as P}from"../../packem_shared/create-or-update-key-storage-C0tWtgSr.js";import{readdirSync as A}from"node:fs";import{readFileSync as w,writeFileSync as F}from"@visulima/fs";import{Application as b}from"typedoc";var T=Object.defineProperty,_=g((e,o)=>T(e,"name",{value:o,configurable:!0}),"w");const C=_(async(e,o,a,s)=>{if(o.length===0)return;const{format:t,jsonFileName:n,marker:i,output:x,plugin:k,readmePath:p,...y}=e;if(t==="inline"&&p===void 0)throw new Error("The `readmePath` option is required when using the `inline` format.");if(t!=="inline"&&typeof p=="string"&&s.warn({message:"The `readmePath` option is only used when the `inline` format is used.",prefix:"typedoc"}),t==="json"){if(n===void 0)throw new Error("The `jsonFileName` option is required when using the `json` format.");if(!n.endsWith(".json"))throw new Error("The `jsonFileName` option must end with `.json`.")}t!=="json"&&typeof n=="string"&&s.warn({message:"The `jsonFileName` option is only used when the `json` format is used.",prefix:"typedoc"});const E=o.map(m=>m.input),u=k??[];u.push("typedoc-plugin-rename-defaults"),(t==="inline"||t==="markdown")&&u.push("typedoc-plugin-markdown");const l=await b.bootstrapWithPlugins({...y,compilerOptions:{allowJs:!0,declaration:!1,declarationMap:!1,esModuleInterop:!0,module:99,moduleResolution:100,noEmit:!0,noImplicitAny:!1,skipLibCheck:!0,sourceMap:!1,target:99,...y.compilerOptions},entryPoints:E,hideGenerator:!0,out:a,plugin:u,...t==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),d=await l.convert();if(d){if(t==="json")await l.generateJson(d,n);else if(t==="html")await l.generateDocs(d,a);else if(await l.generateOutputs(d),t==="inline"){if(i===void 0)throw new Error("The `marker` option is required when using the `inline` format.");const m=A(a,{withFileTypes:!0}).filter(r=>r.isFile());let f="";for(const r of m)r.name==="README.md"&&o.length>1||(f+=w(h(a,r.name)).replaceAll(`<!-- ${i}`,`<!-- _REPLACE_${i}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${i}`));if(f!==""){const r=w(p),c=$(r,i,`
|
|
2
|
+
${f}`);if(!c){s.error({message:`Could not find the typedoc marker: <!-- ${i} --><!-- /${i} --> in ${p}`,prefix:"typedoc"});return}if(r===c)return;c&&F(p,c.replaceAll(`<!-- _REPLACE_${i}`,`<!-- ${i}`).replaceAll(`<!-- _REPLACE_\\${i}`,"<!-- ${marker}"),{overwrite:!0})}}}},"generateReferenceDocumentation");var R=Object.defineProperty,D=g((e,o)=>R(e,"name",{value:o,configurable:!0}),"r");const B=D(async(e,o,a,s)=>{if(e.options.typedoc&&e.options.typedoc.format!==void 0){let t="unknown";e.pkg.dependencies?.typedoc?t=e.pkg.dependencies.typedoc:e.pkg.devDependencies?.typedoc&&(t=e.pkg.devDependencies.typedoc),o&&P("typedoc",o,e.logger,!0),s&&e.logger.raw(`
|
|
3
|
+
`),e.logger.info({message:`Using ${v("typedoc")} ${t} to generate reference documentation`,prefix:"typedoc"}),await e.hooks.callHook("typedoc:before",e);let n=e.options.rootDir;e.options.typedoc.output?n=e.options.typedoc.output:e.options.typedoc.format==="inline"&&o?n=h(o,"typedoc"):e.options.typedoc.format!=="json"&&(n=h(n,"api-docs")),await C(e.options.typedoc,e.options.entries,n,e.logger),await e.hooks.callHook("typedoc:done",e)}},"builder");export{B as default};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Cli } from "@visulima/cerebro";
|
|
2
|
+
/**
|
|
3
|
+
* Creates and registers the build command with the CLI.
|
|
4
|
+
* Handles various build modes, environment variables, and build configurations.
|
|
5
|
+
* @param cli CLI instance to register the command with
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // Usage from command line:
|
|
9
|
+
* // Build for production:
|
|
10
|
+
* // packem build --production
|
|
11
|
+
*
|
|
12
|
+
* // Watch mode with development environment:
|
|
13
|
+
* // packem build --watch --development
|
|
14
|
+
*
|
|
15
|
+
* // With custom environment variables:
|
|
16
|
+
* // packem build --env.API_URL=http://api.example.com
|
|
17
|
+
* ```
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
declare const createBuildCommand: (cli: Cli) => void;
|
|
21
|
+
export default createBuildCommand;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Cli } from "@visulima/cerebro";
|
|
2
|
+
/**
|
|
3
|
+
* Creates and registers the migrate command with the CLI.
|
|
4
|
+
* Handles migration from other bundlers (tsup, unbuild, bunchee, etc.) to packem.
|
|
5
|
+
* @param cli CLI instance to register the command with
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // From command line:
|
|
9
|
+
* // Migrate from tsup to packem:
|
|
10
|
+
* // packem migrate
|
|
11
|
+
*
|
|
12
|
+
* // Dry run to preview changes:
|
|
13
|
+
* // packem migrate --dry-run
|
|
14
|
+
*
|
|
15
|
+
* // Specify custom directory:
|
|
16
|
+
* // packem migrate --cwd /path/to/project
|
|
17
|
+
* ```
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
declare const createMigrateCommand: (cli: Cli) => void;
|
|
21
|
+
export default createMigrateCommand;
|