@visulima/packem 2.0.0-alpha.4 → 2.0.0-alpha.43
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 +480 -1
- package/LICENSE.md +6393 -1445
- package/README.md +16 -12
- package/dist/builder/typedoc/index.d.ts +3 -26
- package/dist/builder/typedoc/index.js +160 -3
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1379 -43
- package/dist/config/index.d.ts +48 -28
- package/dist/config/index.js +4 -1
- package/dist/config/preset/react.d.ts +59 -0
- package/dist/config/preset/react.js +43 -0
- package/dist/config/preset/solid.d.ts +101 -0
- package/dist/config/preset/solid.js +72 -0
- package/dist/config/preset/svelte.d.ts +71 -0
- package/dist/config/preset/svelte.js +44 -0
- package/dist/config/preset/vue.d.ts +53 -0
- package/dist/config/preset/vue.js +33 -0
- package/dist/index.d.ts +45 -32
- package/dist/index.js +30 -1
- package/dist/packem/node10-compatibility.d.ts +7 -0
- package/dist/packem_shared/create-or-update-key-storage-Dd7b8-t1.js +36 -0
- package/dist/packem_shared/default-79SPobLI.js +12 -0
- package/dist/packem_shared/default-DWBYeUSC.js +210 -0
- package/dist/packem_shared/default-DaU6CQEi.js +28 -0
- package/dist/packem_shared/default-DavaZMwC.js +32 -0
- package/dist/packem_shared/default-DeYZ934H.js +32 -0
- package/dist/packem_shared/default-tUOOZ8w7.js +42 -0
- package/dist/packem_shared/default-wScAfTaq.js +27 -0
- package/dist/packem_shared/index-CTIRxV2x.js +63 -0
- package/dist/packem_shared/index-DzTDn4ad.js +9521 -0
- package/dist/rollup/plugins/css/loaders/less.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/less.js +1 -1
- package/dist/rollup/plugins/css/loaders/lightningcss.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/lightningcss.js +1 -1
- package/dist/rollup/plugins/css/loaders/postcss.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/postcss.js +1 -1
- package/dist/rollup/plugins/css/loaders/sass.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/sass.js +1 -1
- package/dist/rollup/plugins/css/loaders/sourcemap.d.ts +1 -8
- package/dist/rollup/plugins/css/loaders/sourcemap.js +1 -1
- package/dist/rollup/plugins/css/loaders/stylus.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/stylus.js +1 -1
- package/dist/rollup/plugins/css/loaders/tailwindcss.d.ts +1 -0
- package/dist/rollup/plugins/css/loaders/tailwindcss.js +1 -0
- package/dist/rollup/plugins/css/minifiers/cssnano.d.ts +1 -1
- package/dist/rollup/plugins/css/minifiers/cssnano.js +1 -1
- package/dist/rollup/plugins/css/minifiers/lightningcss.d.ts +1 -1
- package/dist/rollup/plugins/css/minifiers/lightningcss.js +1 -1
- package/dist/rollup/plugins/esbuild/index.d.ts +2 -24
- package/dist/rollup/plugins/esbuild/index.js +1 -1
- package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +1 -25
- package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.js +1 -1
- package/dist/rollup/plugins/oxc/oxc-transformer.d.ts +2 -20
- package/dist/rollup/plugins/oxc/oxc-transformer.js +1 -1
- package/dist/rollup/plugins/resolve-externals-plugin.d.ts +60 -0
- package/dist/rollup/plugins/sucrase/index.d.ts +2 -19
- package/dist/rollup/plugins/sucrase/index.js +1 -1
- package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +1 -20
- package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.js +1 -1
- package/dist/rollup/plugins/swc/swc-plugin.d.ts +2 -26
- package/dist/rollup/plugins/swc/swc-plugin.js +1 -1
- package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +1 -24
- package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -1
- package/dist/types.d.ts +329 -0
- package/files.d.ts +37 -0
- package/package.json +190 -29
- package/dist/packem_shared/browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js +0 -1
- package/dist/packem_shared/create-or-update-key-storage-GwAIWW7R.js +0 -3
- package/dist/packem_shared/default-B6X7-Lx3.js +0 -1
- package/dist/packem_shared/default-B_dUKZ_J.js +0 -1
- package/dist/packem_shared/default-C3sdXf4G.js +0 -1
- package/dist/packem_shared/default-DR5Fia_R.js +0 -1
- package/dist/packem_shared/default-DqRcOUe1.js +0 -1
- package/dist/packem_shared/esbuildPlugin-BAwyhG6L-yty60jMl.js +0 -3
- package/dist/packem_shared/index-CUp9WuCG.js +0 -1
- package/dist/packem_shared/index-DySckW0r.d.ts +0 -5227
- package/dist/packem_shared/index-VKZ7e6tb.js +0 -138
- package/dist/packem_shared/isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js +0 -1
- package/dist/packem_shared/isolatedDeclarationsSwcTransformer-Ch2AgtWC-B-0lOgFf.js +0 -1
- package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.js +0 -3
- package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG-BsYx9cDO.js +0 -1
- package/dist/packem_shared/oxcTransformPlugin-DfVQouIB-Cpfv95eA.js +0 -4
- package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-BEkYWTsH.js +0 -6
- package/dist/packem_shared/swcPlugin-Boip4lWG-CwJ-HVJc.js +0 -1
- package/dist/packem_shared/types-CaBbG-vU.d.ts +0 -163
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ It uses the `exports` configuration in `package.json` and recognizes entry file
|
|
|
53
53
|
- ✅ Supports react server and client components
|
|
54
54
|
- ✅ Supports shared modules
|
|
55
55
|
- ✅ Supports dynamic import
|
|
56
|
-
- ✅ Supports `tsconfig.json` paths and `package.json` imports resolution
|
|
56
|
+
- ✅ Supports `tsconfig.json` paths and `package.json`, `package.yml`, `package.yaml` and `package.json5` imports resolution
|
|
57
57
|
- ✅ ESM ⇄ CJS interoperability
|
|
58
58
|
- ✅ Supports isolated declaration types (experimental) (Typescript version 5.5 or higher)
|
|
59
59
|
- ✅ Supports wasm [WebAssembly modules](http://webassembly.org)
|
|
@@ -163,13 +163,9 @@ Enable the automatic `node 10` typesVersions generation in packem.config.js:
|
|
|
163
163
|
```js
|
|
164
164
|
export default defineConfig({
|
|
165
165
|
// ...
|
|
166
|
-
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
typeScriptVersion: ">=5.0", // Chose the version of TypeScript you want to support
|
|
170
|
-
writeToPackageJson: true,
|
|
171
|
-
},
|
|
172
|
-
// ...
|
|
166
|
+
node10Compatibility: {
|
|
167
|
+
typeScriptVersion: ">=5.0", // Chose the version of TypeScript you want to support
|
|
168
|
+
writeToPackageJson: true,
|
|
173
169
|
},
|
|
174
170
|
transformer,
|
|
175
171
|
});
|
|
@@ -454,13 +450,13 @@ Native Node.js import mapping supports conditional imports (eg. resolving differ
|
|
|
454
450
|
{
|
|
455
451
|
// ...
|
|
456
452
|
|
|
457
|
-
|
|
453
|
+
imports: {
|
|
458
454
|
// Mapping '~utils' to './src/utils.js'
|
|
459
455
|
"~utils": "./src/utils.js",
|
|
460
456
|
|
|
461
457
|
// Native Node.js import mapping (can't reference ./src)
|
|
462
|
-
"#internal-package": "./vendors/package/index.js"
|
|
463
|
-
}
|
|
458
|
+
"#internal-package": "./vendors/package/index.js",
|
|
459
|
+
},
|
|
464
460
|
}
|
|
465
461
|
```
|
|
466
462
|
|
|
@@ -895,7 +891,15 @@ Will look for `_custom` first (_with the appropriate extension(s)_), and then fo
|
|
|
895
891
|
styles({
|
|
896
892
|
mode: "inject", // Unnecessary, set by default
|
|
897
893
|
// ...or with custom options for injector
|
|
898
|
-
mode: [
|
|
894
|
+
mode: [
|
|
895
|
+
"inject",
|
|
896
|
+
{
|
|
897
|
+
attributes: { id: "global" },
|
|
898
|
+
container: "body",
|
|
899
|
+
prepend: true,
|
|
900
|
+
singleTag: true,
|
|
901
|
+
},
|
|
902
|
+
],
|
|
899
903
|
// ...or with custom injector
|
|
900
904
|
mode: ["inject", (varname, id) => `console.log(${varname},${JSON.stringify(id)})`],
|
|
901
905
|
});
|
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '@rollup/plugin-alias';
|
|
4
|
-
import '@rollup/plugin-commonjs';
|
|
5
|
-
import '@rollup/plugin-json';
|
|
6
|
-
import '@rollup/plugin-node-resolve';
|
|
7
|
-
import '@rollup/plugin-replace';
|
|
8
|
-
import '@rollup/plugin-wasm';
|
|
9
|
-
import '@rollup/pluginutils';
|
|
10
|
-
import 'rollup';
|
|
11
|
-
import 'rollup-plugin-dts';
|
|
12
|
-
import 'rollup-plugin-polyfill-node';
|
|
13
|
-
import 'rollup-plugin-pure';
|
|
14
|
-
import 'rollup-plugin-visualizer';
|
|
15
|
-
import 'esbuild';
|
|
16
|
-
import '@visulima/package';
|
|
17
|
-
import '@visulima/colorize';
|
|
18
|
-
import 'oxc-resolver';
|
|
19
|
-
import 'oxc-transform';
|
|
20
|
-
import 'sucrase';
|
|
21
|
-
import '@visulima/rollup-css-plugin';
|
|
22
|
-
import 'jiti';
|
|
23
|
-
import 'typedoc';
|
|
24
|
-
|
|
1
|
+
import type { BuildContext } from "@visulima/packem-share/types";
|
|
2
|
+
import type { InternalBuildOptions } from "../../types.d.ts";
|
|
25
3
|
declare const builder: (context: BuildContext<InternalBuildOptions>, cachePath: string | undefined, _: never, logged: boolean) => Promise<void>;
|
|
26
|
-
|
|
27
|
-
export { builder as default };
|
|
4
|
+
export default builder;
|
|
@@ -1,3 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { cyan } from '@visulima/colorize';
|
|
2
|
+
import { join } from '@visulima/path';
|
|
3
|
+
import { r as replaceContentWithinMarker, c as createOrUpdateKeyStorage } from '../../packem_shared/create-or-update-key-storage-Dd7b8-t1.js';
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|