@trebired/bundler 2.0.0 → 3.1.0
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 +21 -0
- package/README.md +286 -283
- package/dist/backend/utils/normalize.d.ts +2 -0
- package/dist/backend/utils/normalize.d.ts.map +1 -0
- package/dist/backend/utils/normalize.js +4 -0
- package/dist/backend/utils/normalize.js.map +1 -0
- package/dist/backend/utils/object.d.ts +3 -0
- package/dist/backend/utils/object.d.ts.map +1 -0
- package/dist/backend/utils/object.js +12 -0
- package/dist/backend/utils/object.js.map +1 -0
- package/dist/backend/utils/time.d.ts +3 -0
- package/dist/backend/utils/time.d.ts.map +1 -0
- package/dist/backend/utils/time.js +7 -0
- package/dist/backend/utils/time.js.map +1 -0
- package/dist/cli/run-cli.d.ts +1 -13
- package/dist/cli/run-cli.d.ts.map +1 -1
- package/dist/cli/run-cli.js +1 -103
- package/dist/cli/run-cli.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/core/asset-manifest.d.ts +1 -4
- package/dist/core/asset-manifest.d.ts.map +1 -1
- package/dist/core/asset-manifest.js +1 -256
- package/dist/core/asset-manifest.js.map +1 -1
- package/dist/core/build.d.ts +1 -3
- package/dist/core/build.d.ts.map +1 -1
- package/dist/core/build.js +1 -53
- package/dist/core/build.js.map +1 -1
- package/dist/core/derive-manifest.d.ts +1 -9
- package/dist/core/derive-manifest.d.ts.map +1 -1
- package/dist/core/derive-manifest.js +1 -149
- package/dist/core/derive-manifest.js.map +1 -1
- package/dist/core/discovery-watch.d.ts +1 -8
- package/dist/core/discovery-watch.d.ts.map +1 -1
- package/dist/core/discovery-watch.js +1 -100
- package/dist/core/discovery-watch.js.map +1 -1
- package/dist/core/discovery.d.ts +1 -35
- package/dist/core/discovery.d.ts.map +1 -1
- package/dist/core/discovery.js +1 -469
- package/dist/core/discovery.js.map +1 -1
- package/dist/core/esbuild-options.d.ts +1 -31
- package/dist/core/esbuild-options.d.ts.map +1 -1
- package/dist/core/esbuild-options.js +1 -109
- package/dist/core/esbuild-options.js.map +1 -1
- package/dist/core/import-graph.d.ts +1 -3
- package/dist/core/import-graph.d.ts.map +1 -1
- package/dist/core/import-graph.js +1 -409
- package/dist/core/import-graph.js.map +1 -1
- package/dist/core/manifest.d.ts +1 -14
- package/dist/core/manifest.d.ts.map +1 -1
- package/dist/core/manifest.js +1 -37
- package/dist/core/manifest.js.map +1 -1
- package/dist/core/shared.d.ts +1 -21
- package/dist/core/shared.d.ts.map +1 -1
- package/dist/core/shared.js +1 -79
- package/dist/core/shared.js.map +1 -1
- package/dist/core/watch.d.ts +1 -3
- package/dist/core/watch.d.ts.map +1 -1
- package/dist/core/watch.js +1 -188
- package/dist/core/watch.js.map +1 -1
- package/dist/frontend/js/utils/text.d.ts +2 -0
- package/dist/frontend/js/utils/text.d.ts.map +1 -0
- package/dist/frontend/js/utils/text.js +4 -0
- package/dist/frontend/js/utils/text.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/cli/run-cli.d.ts +14 -0
- package/dist/internal/cli/run-cli.d.ts.map +1 -0
- package/dist/internal/cli/run-cli.js +108 -0
- package/dist/internal/cli/run-cli.js.map +1 -0
- package/dist/internal/core/asset-manifest.d.ts +2 -0
- package/dist/internal/core/asset-manifest.d.ts.map +1 -0
- package/dist/internal/core/asset-manifest.js +2 -0
- package/dist/internal/core/asset-manifest.js.map +1 -0
- package/dist/internal/core/asset_manifest/runtime.d.ts +5 -0
- package/dist/internal/core/asset_manifest/runtime.d.ts.map +1 -0
- package/dist/internal/core/asset_manifest/runtime.js +252 -0
- package/dist/internal/core/asset_manifest/runtime.js.map +1 -0
- package/dist/internal/core/build.d.ts +4 -0
- package/dist/internal/core/build.d.ts.map +1 -0
- package/dist/internal/core/build.js +49 -0
- package/dist/internal/core/build.js.map +1 -0
- package/dist/internal/core/derive-manifest.d.ts +3 -0
- package/dist/internal/core/derive-manifest.d.ts.map +1 -0
- package/dist/internal/core/derive-manifest.js +2 -0
- package/dist/internal/core/derive-manifest.js.map +1 -0
- package/dist/internal/core/derive_manifest/runtime.d.ts +10 -0
- package/dist/internal/core/derive_manifest/runtime.d.ts.map +1 -0
- package/dist/internal/core/derive_manifest/runtime.js +133 -0
- package/dist/internal/core/derive_manifest/runtime.js.map +1 -0
- package/dist/internal/core/discovery/aggregate.d.ts +32 -0
- package/dist/internal/core/discovery/aggregate.d.ts.map +1 -0
- package/dist/internal/core/discovery/aggregate.js +124 -0
- package/dist/internal/core/discovery/aggregate.js.map +1 -0
- package/dist/internal/core/discovery/emit.d.ts +22 -0
- package/dist/internal/core/discovery/emit.d.ts.map +1 -0
- package/dist/internal/core/discovery/emit.js +37 -0
- package/dist/internal/core/discovery/emit.js.map +1 -0
- package/dist/internal/core/discovery/normalize.d.ts +8 -0
- package/dist/internal/core/discovery/normalize.d.ts.map +1 -0
- package/dist/internal/core/discovery/normalize.js +130 -0
- package/dist/internal/core/discovery/normalize.js.map +1 -0
- package/dist/internal/core/discovery/public.d.ts +5 -0
- package/dist/internal/core/discovery/public.d.ts.map +1 -0
- package/dist/internal/core/discovery/public.js +25 -0
- package/dist/internal/core/discovery/public.js.map +1 -0
- package/dist/internal/core/discovery/resolve.d.ts +9 -0
- package/dist/internal/core/discovery/resolve.d.ts.map +1 -0
- package/dist/internal/core/discovery/resolve.js +235 -0
- package/dist/internal/core/discovery/resolve.js.map +1 -0
- package/dist/internal/core/discovery/scan.d.ts +29 -0
- package/dist/internal/core/discovery/scan.d.ts.map +1 -0
- package/dist/internal/core/discovery/scan.js +105 -0
- package/dist/internal/core/discovery/scan.js.map +1 -0
- package/dist/internal/core/discovery/shared.d.ts +100 -0
- package/dist/internal/core/discovery/shared.d.ts.map +1 -0
- package/dist/internal/core/discovery/shared.js +187 -0
- package/dist/internal/core/discovery/shared.js.map +1 -0
- package/dist/internal/core/discovery-watch.d.ts +2 -0
- package/dist/internal/core/discovery-watch.d.ts.map +1 -0
- package/dist/internal/core/discovery-watch.js +2 -0
- package/dist/internal/core/discovery-watch.js.map +1 -0
- package/dist/internal/core/discovery.d.ts +5 -0
- package/dist/internal/core/discovery.d.ts.map +1 -0
- package/dist/internal/core/discovery.js +4 -0
- package/dist/internal/core/discovery.js.map +1 -0
- package/dist/internal/core/discovery_watch/runtime.d.ts +9 -0
- package/dist/internal/core/discovery_watch/runtime.d.ts.map +1 -0
- package/dist/internal/core/discovery_watch/runtime.js +127 -0
- package/dist/internal/core/discovery_watch/runtime.js.map +1 -0
- package/dist/internal/core/esbuild-options.d.ts +30 -0
- package/dist/internal/core/esbuild-options.d.ts.map +1 -0
- package/dist/internal/core/esbuild-options.js +93 -0
- package/dist/internal/core/esbuild-options.js.map +1 -0
- package/dist/internal/core/import-graph.d.ts +2 -0
- package/dist/internal/core/import-graph.d.ts.map +1 -0
- package/dist/internal/core/import-graph.js +2 -0
- package/dist/internal/core/import-graph.js.map +1 -0
- package/dist/internal/core/import_graph/parse.d.ts +6 -0
- package/dist/internal/core/import_graph/parse.d.ts.map +1 -0
- package/dist/internal/core/import_graph/parse.js +134 -0
- package/dist/internal/core/import_graph/parse.js.map +1 -0
- package/dist/internal/core/import_graph/resolve.d.ts +4 -0
- package/dist/internal/core/import_graph/resolve.d.ts.map +1 -0
- package/dist/internal/core/import_graph/resolve.js +105 -0
- package/dist/internal/core/import_graph/resolve.js.map +1 -0
- package/dist/internal/core/import_graph/shared.d.ts +21 -0
- package/dist/internal/core/import_graph/shared.d.ts.map +1 -0
- package/dist/internal/core/import_graph/shared.js +27 -0
- package/dist/internal/core/import_graph/shared.js.map +1 -0
- package/dist/internal/core/import_graph/tsconfig.d.ts +7 -0
- package/dist/internal/core/import_graph/tsconfig.d.ts.map +1 -0
- package/dist/internal/core/import_graph/tsconfig.js +111 -0
- package/dist/internal/core/import_graph/tsconfig.js.map +1 -0
- package/dist/internal/core/manifest.d.ts +15 -0
- package/dist/internal/core/manifest.d.ts.map +1 -0
- package/dist/internal/core/manifest.js +29 -0
- package/dist/internal/core/manifest.js.map +1 -0
- package/dist/internal/core/shared.d.ts +17 -0
- package/dist/internal/core/shared.d.ts.map +1 -0
- package/dist/internal/core/shared.js +63 -0
- package/dist/internal/core/shared.js.map +1 -0
- package/dist/internal/core/watch.d.ts +4 -0
- package/dist/internal/core/watch.d.ts.map +1 -0
- package/dist/internal/core/watch.js +185 -0
- package/dist/internal/core/watch.js.map +1 -0
- package/dist/internal/types/discovery.d.ts +91 -0
- package/dist/internal/types/discovery.d.ts.map +1 -0
- package/dist/internal/types/discovery.js +2 -0
- package/dist/internal/types/discovery.js.map +1 -0
- package/dist/internal/types/import_graph.d.ts +29 -0
- package/dist/internal/types/import_graph.d.ts.map +1 -0
- package/dist/internal/types/import_graph.js +2 -0
- package/dist/internal/types/import_graph.js.map +1 -0
- package/dist/internal/types/logging.d.ts +9 -0
- package/dist/internal/types/logging.d.ts.map +1 -0
- package/dist/internal/types/logging.js +2 -0
- package/dist/internal/types/logging.js.map +1 -0
- package/dist/internal/types/manifest.d.ts +106 -0
- package/dist/internal/types/manifest.d.ts.map +1 -0
- package/dist/internal/types/manifest.js +2 -0
- package/dist/internal/types/manifest.js.map +1 -0
- package/dist/internal/types/runtime.d.ts +47 -0
- package/dist/internal/types/runtime.d.ts.map +1 -0
- package/dist/internal/types/runtime.js +2 -0
- package/dist/internal/types/runtime.js.map +1 -0
- package/dist/internal/types.d.ts +6 -0
- package/dist/internal/types.d.ts.map +1 -0
- package/dist/internal/types.js +2 -0
- package/dist/internal/types.js.map +1 -0
- package/dist/logging.d.ts.map +1 -1
- package/dist/logging.js.map +1 -1
- package/dist/plugins/scss.d.ts +1 -1
- package/dist/plugins/scss.d.ts.map +1 -1
- package/dist/plugins/scss.js.map +1 -1
- package/dist/plugins/source-annotations.d.ts +1 -1
- package/dist/plugins/source-annotations.d.ts.map +1 -1
- package/dist/plugins/source-annotations.js.map +1 -1
- package/dist/plugins/virtual-entries.d.ts +1 -1
- package/dist/plugins/virtual-entries.d.ts.map +1 -1
- package/dist/plugins/virtual-entries.js +2 -2
- package/dist/plugins/virtual-entries.js.map +1 -1
- package/dist/src/backend/utils/normalize.d.ts +2 -0
- package/dist/src/backend/utils/normalize.d.ts.map +1 -0
- package/dist/src/backend/utils/normalize.js +4 -0
- package/dist/src/backend/utils/normalize.js.map +1 -0
- package/dist/src/backend/utils/object.d.ts +3 -0
- package/dist/src/backend/utils/object.d.ts.map +1 -0
- package/dist/src/backend/utils/object.js +12 -0
- package/dist/src/backend/utils/object.js.map +1 -0
- package/dist/src/backend/utils/time.d.ts +3 -0
- package/dist/src/backend/utils/time.d.ts.map +1 -0
- package/dist/src/backend/utils/time.js +7 -0
- package/dist/src/backend/utils/time.js.map +1 -0
- package/dist/src/cli/run-cli.d.ts +2 -0
- package/dist/src/cli/run-cli.d.ts.map +1 -0
- package/dist/src/cli/run-cli.js +2 -0
- package/dist/src/cli/run-cli.js.map +1 -0
- package/dist/src/cli.d.ts +5 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +10 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/config/index.d.ts +5 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +32 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/constants.d.ts +4 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +4 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/core/asset-manifest.d.ts +2 -0
- package/dist/src/core/asset-manifest.d.ts.map +1 -0
- package/dist/src/core/asset-manifest.js +2 -0
- package/dist/src/core/asset-manifest.js.map +1 -0
- package/dist/src/core/build.d.ts +2 -0
- package/dist/src/core/build.d.ts.map +1 -0
- package/dist/src/core/build.js +2 -0
- package/dist/src/core/build.js.map +1 -0
- package/dist/src/core/derive-manifest.d.ts +2 -0
- package/dist/src/core/derive-manifest.d.ts.map +1 -0
- package/dist/src/core/derive-manifest.js +2 -0
- package/dist/src/core/derive-manifest.js.map +1 -0
- package/dist/src/core/discovery-watch.d.ts +2 -0
- package/dist/src/core/discovery-watch.d.ts.map +1 -0
- package/dist/src/core/discovery-watch.js +2 -0
- package/dist/src/core/discovery-watch.js.map +1 -0
- package/dist/src/core/discovery.d.ts +2 -0
- package/dist/src/core/discovery.d.ts.map +1 -0
- package/dist/src/core/discovery.js +2 -0
- package/dist/src/core/discovery.js.map +1 -0
- package/dist/src/core/esbuild-options.d.ts +2 -0
- package/dist/src/core/esbuild-options.d.ts.map +1 -0
- package/dist/src/core/esbuild-options.js +2 -0
- package/dist/src/core/esbuild-options.js.map +1 -0
- package/dist/src/core/import-graph.d.ts +2 -0
- package/dist/src/core/import-graph.d.ts.map +1 -0
- package/dist/src/core/import-graph.js +2 -0
- package/dist/src/core/import-graph.js.map +1 -0
- package/dist/src/core/manifest.d.ts +2 -0
- package/dist/src/core/manifest.d.ts.map +1 -0
- package/dist/src/core/manifest.js +2 -0
- package/dist/src/core/manifest.js.map +1 -0
- package/dist/src/core/shared.d.ts +2 -0
- package/dist/src/core/shared.d.ts.map +1 -0
- package/dist/src/core/shared.js +2 -0
- package/dist/src/core/shared.js.map +1 -0
- package/dist/src/core/watch.d.ts +2 -0
- package/dist/src/core/watch.d.ts.map +1 -0
- package/dist/src/core/watch.js +2 -0
- package/dist/src/core/watch.js.map +1 -0
- package/dist/src/frontend/js/utils/text.d.ts +2 -0
- package/dist/src/frontend/js/utils/text.d.ts.map +1 -0
- package/dist/src/frontend/js/utils/text.js +4 -0
- package/dist/src/frontend/js/utils/text.js.map +1 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +13 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/logging.d.ts +5 -0
- package/dist/src/logging.d.ts.map +1 -0
- package/dist/src/logging.js +35 -0
- package/dist/src/logging.js.map +1 -0
- package/dist/src/plugins/scss.d.ts +11 -0
- package/dist/src/plugins/scss.d.ts.map +1 -0
- package/dist/src/plugins/scss.js +44 -0
- package/dist/src/plugins/scss.js.map +1 -0
- package/dist/src/plugins/source-annotations.d.ts +17 -0
- package/dist/src/plugins/source-annotations.d.ts.map +1 -0
- package/dist/src/plugins/source-annotations.js +78 -0
- package/dist/src/plugins/source-annotations.js.map +1 -0
- package/dist/src/plugins/virtual-entries.d.ts +11 -0
- package/dist/src/plugins/virtual-entries.d.ts.map +1 -0
- package/dist/src/plugins/virtual-entries.js +39 -0
- package/dist/src/plugins/virtual-entries.js.map +1 -0
- package/dist/src/types.d.ts +2 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/types.d.ts +1 -181
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +108 -41
|
@@ -1,150 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { toPosixPath } from "./discovery.js";
|
|
3
|
-
import { VIRTUAL_ENTRY_PREFIX } from "./discovery.js";
|
|
4
|
-
function normalizeFilePath(filePath, rootDir) {
|
|
5
|
-
if (filePath.startsWith(VIRTUAL_ENTRY_PREFIX)) {
|
|
6
|
-
return `virtual:${filePath.slice(VIRTUAL_ENTRY_PREFIX.length)}`;
|
|
7
|
-
}
|
|
8
|
-
const absolute = path.isAbsolute(filePath) ? filePath : path.resolve(rootDir, filePath);
|
|
9
|
-
return toPosixPath(path.relative(rootDir, absolute));
|
|
10
|
-
}
|
|
11
|
-
function normalizeInputPaths(inputs, rootDir) {
|
|
12
|
-
return Object.keys(inputs)
|
|
13
|
-
.map((value) => normalizeFilePath(value, rootDir))
|
|
14
|
-
.sort();
|
|
15
|
-
}
|
|
16
|
-
function normalizeImportedOutputPaths(metafile, outputPath, rootDir) {
|
|
17
|
-
const output = metafile.outputs[outputPath];
|
|
18
|
-
if (!output)
|
|
19
|
-
return [];
|
|
20
|
-
return output.imports
|
|
21
|
-
.filter((item) => !item.external && Boolean(metafile.outputs[item.path]))
|
|
22
|
-
.map((item) => normalizeFilePath(item.path, rootDir))
|
|
23
|
-
.sort();
|
|
24
|
-
}
|
|
25
|
-
function resolveOutputKind(args) {
|
|
26
|
-
if (args.outputValue.entryPoint)
|
|
27
|
-
return "entry";
|
|
28
|
-
if (args.importedOutputs.has(args.outputRel) || /\.(?:[mc]?js)$/i.test(args.outputRel))
|
|
29
|
-
return "chunk";
|
|
30
|
-
return "asset";
|
|
31
|
-
}
|
|
32
|
-
function deriveEntryName(args) {
|
|
33
|
-
if (args.outputValue.entryPoint) {
|
|
34
|
-
const entryRel = normalizeFilePath(args.outputValue.entryPoint, args.rootDir);
|
|
35
|
-
const ext = path.extname(entryRel);
|
|
36
|
-
return toPosixPath(ext ? entryRel.slice(0, -ext.length) : entryRel);
|
|
37
|
-
}
|
|
38
|
-
const absoluteOutDir = path.resolve(args.rootDir, args.outDir);
|
|
39
|
-
const absoluteOutput = path.resolve(args.rootDir, args.entryOutput);
|
|
40
|
-
const relOut = toPosixPath(path.relative(absoluteOutDir, absoluteOutput));
|
|
41
|
-
if (!relOut || relOut.startsWith(".."))
|
|
42
|
-
return undefined;
|
|
43
|
-
const ext = path.extname(relOut);
|
|
44
|
-
return ext ? relOut.slice(0, -ext.length) : relOut;
|
|
45
|
-
}
|
|
46
|
-
function collectReachableOutputs(args) {
|
|
47
|
-
const seen = new Set();
|
|
48
|
-
const stack = [args.outputPath];
|
|
49
|
-
while (stack.length) {
|
|
50
|
-
const current = stack.pop();
|
|
51
|
-
if (seen.has(current))
|
|
52
|
-
continue;
|
|
53
|
-
seen.add(current);
|
|
54
|
-
const currentOutput = args.metafile.outputs[current];
|
|
55
|
-
if (!currentOutput)
|
|
56
|
-
continue;
|
|
57
|
-
for (const imported of currentOutput.imports) {
|
|
58
|
-
if (imported.external || !args.metafile.outputs[imported.path])
|
|
59
|
-
continue;
|
|
60
|
-
stack.push(imported.path);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return Array.from(seen).sort().map((value) => normalizeFilePath(value, args.rootDir));
|
|
64
|
-
}
|
|
65
|
-
function deriveManifest(metafile, options) {
|
|
66
|
-
const outputs = Object.entries(metafile.outputs).sort(([a], [b]) => a.localeCompare(b));
|
|
67
|
-
const importedOutputs = new Set();
|
|
68
|
-
for (const [, output] of outputs) {
|
|
69
|
-
for (const imported of output.imports) {
|
|
70
|
-
if (!imported.external && metafile.outputs[imported.path]) {
|
|
71
|
-
importedOutputs.add(normalizeFilePath(imported.path, options.rootDir));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const entries = {};
|
|
76
|
-
const chunks = {};
|
|
77
|
-
const allOutputs = {};
|
|
78
|
-
for (const [outputPath, outputValue] of outputs) {
|
|
79
|
-
const outputRel = normalizeFilePath(outputPath, options.rootDir);
|
|
80
|
-
const imports = normalizeImportedOutputPaths(metafile, outputPath, options.rootDir);
|
|
81
|
-
const css = outputValue.cssBundle
|
|
82
|
-
? [normalizeFilePath(outputValue.cssBundle, options.rootDir)]
|
|
83
|
-
: outputRel.endsWith(".css")
|
|
84
|
-
? [outputRel]
|
|
85
|
-
: [];
|
|
86
|
-
const outputInfo = {
|
|
87
|
-
output: outputRel,
|
|
88
|
-
kind: resolveOutputKind({
|
|
89
|
-
importedOutputs,
|
|
90
|
-
outputPath,
|
|
91
|
-
outputRel,
|
|
92
|
-
outputValue,
|
|
93
|
-
}),
|
|
94
|
-
entryPoint: outputValue.entryPoint ? normalizeFilePath(outputValue.entryPoint, options.rootDir) : undefined,
|
|
95
|
-
entryName: deriveEntryName({
|
|
96
|
-
entryOutput: outputPath,
|
|
97
|
-
outputValue,
|
|
98
|
-
outDir: options.outDir,
|
|
99
|
-
rootDir: options.rootDir,
|
|
100
|
-
}),
|
|
101
|
-
inputs: normalizeInputPaths(outputValue.inputs, options.rootDir),
|
|
102
|
-
css,
|
|
103
|
-
imports,
|
|
104
|
-
bytes: outputValue.bytes,
|
|
105
|
-
};
|
|
106
|
-
allOutputs[outputRel] = outputInfo;
|
|
107
|
-
}
|
|
108
|
-
for (const [outputPath] of outputs) {
|
|
109
|
-
const outputRel = normalizeFilePath(outputPath, options.rootDir);
|
|
110
|
-
const outputInfo = allOutputs[outputRel];
|
|
111
|
-
if (!outputInfo)
|
|
112
|
-
continue;
|
|
113
|
-
if (outputInfo.kind === "entry") {
|
|
114
|
-
const reachable = collectReachableOutputs({
|
|
115
|
-
metafile,
|
|
116
|
-
outputPath,
|
|
117
|
-
rootDir: options.rootDir,
|
|
118
|
-
});
|
|
119
|
-
const js = reachable.filter((value) => /\.(?:[mc]?js)$/i.test(value));
|
|
120
|
-
const reachableCss = Array.from(new Set(reachable.flatMap((value) => {
|
|
121
|
-
const info = allOutputs[value];
|
|
122
|
-
return info ? info.css : value.endsWith(".css") ? [value] : [];
|
|
123
|
-
}))).sort();
|
|
124
|
-
entries[outputRel] = {
|
|
125
|
-
entryOutput: outputRel,
|
|
126
|
-
entryName: outputInfo.entryName,
|
|
127
|
-
inputs: outputInfo.inputs,
|
|
128
|
-
js,
|
|
129
|
-
css: reachableCss,
|
|
130
|
-
imports: outputInfo.imports,
|
|
131
|
-
};
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
if (outputInfo.kind === "chunk") {
|
|
135
|
-
chunks[outputRel] = {
|
|
136
|
-
output: outputRel,
|
|
137
|
-
inputs: outputInfo.inputs,
|
|
138
|
-
css: outputInfo.css,
|
|
139
|
-
imports: outputInfo.imports,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
entries: Object.fromEntries(Object.entries(entries).sort(([a], [b]) => a.localeCompare(b))),
|
|
145
|
-
chunks: Object.fromEntries(Object.entries(chunks).sort(([a], [b]) => a.localeCompare(b))),
|
|
146
|
-
allOutputs: Object.fromEntries(Object.entries(allOutputs).sort(([a], [b]) => a.localeCompare(b))),
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
export { deriveManifest };
|
|
1
|
+
export * from "../internal/core/derive-manifest.js";
|
|
150
2
|
//# sourceMappingURL=derive-manifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive-manifest.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"derive-manifest.js","sourceRoot":"","sources":["../../../src/core/derive-manifest.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
close(): void;
|
|
3
|
-
};
|
|
4
|
-
declare function createDiscoveryWatcher(args: {
|
|
5
|
-
dirs: string[];
|
|
6
|
-
onChange: () => void;
|
|
7
|
-
}): DiscoveryWatcher;
|
|
8
|
-
export { createDiscoveryWatcher };
|
|
1
|
+
export * from "../internal/core/discovery-watch.d.ts";
|
|
9
2
|
//# sourceMappingURL=discovery-watch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-watch.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"discovery-watch.d.ts","sourceRoot":"","sources":["../../../src/core/discovery-watch.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
|
@@ -1,101 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
function createDiscoveryWatcher(args) {
|
|
4
|
-
const watchers = new Map();
|
|
5
|
-
let closed = false;
|
|
6
|
-
let timer = null;
|
|
7
|
-
const interval = setInterval(() => {
|
|
8
|
-
if (refreshAll()) {
|
|
9
|
-
emitChange();
|
|
10
|
-
}
|
|
11
|
-
}, 250);
|
|
12
|
-
const emitChange = () => {
|
|
13
|
-
if (closed)
|
|
14
|
-
return;
|
|
15
|
-
if (timer)
|
|
16
|
-
clearTimeout(timer);
|
|
17
|
-
timer = setTimeout(() => {
|
|
18
|
-
timer = null;
|
|
19
|
-
args.onChange();
|
|
20
|
-
}, 80);
|
|
21
|
-
};
|
|
22
|
-
const ensureWatch = (dir) => {
|
|
23
|
-
if (closed || watchers.has(dir) || !fs.existsSync(dir))
|
|
24
|
-
return false;
|
|
25
|
-
let stats;
|
|
26
|
-
try {
|
|
27
|
-
stats = fs.statSync(dir);
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
if (!stats.isDirectory())
|
|
33
|
-
return false;
|
|
34
|
-
const watcher = fs.watch(dir, () => {
|
|
35
|
-
refreshAll();
|
|
36
|
-
emitChange();
|
|
37
|
-
});
|
|
38
|
-
watcher.on("error", () => {
|
|
39
|
-
watchers.delete(dir);
|
|
40
|
-
});
|
|
41
|
-
watchers.set(dir, watcher);
|
|
42
|
-
return true;
|
|
43
|
-
};
|
|
44
|
-
const collectDirs = (startDir, found) => {
|
|
45
|
-
if (closed || !fs.existsSync(startDir))
|
|
46
|
-
return;
|
|
47
|
-
const stack = [startDir];
|
|
48
|
-
while (stack.length) {
|
|
49
|
-
const current = stack.pop();
|
|
50
|
-
if (!fs.existsSync(current))
|
|
51
|
-
continue;
|
|
52
|
-
found.add(current);
|
|
53
|
-
try {
|
|
54
|
-
for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
|
|
55
|
-
if (!entry.isDirectory())
|
|
56
|
-
continue;
|
|
57
|
-
const child = path.join(current, entry.name);
|
|
58
|
-
stack.push(child);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const refreshAll = () => {
|
|
67
|
-
let changed = false;
|
|
68
|
-
const found = new Set();
|
|
69
|
-
for (const dir of args.dirs) {
|
|
70
|
-
collectDirs(dir, found);
|
|
71
|
-
}
|
|
72
|
-
for (const dir of found) {
|
|
73
|
-
if (ensureWatch(dir)) {
|
|
74
|
-
changed = true;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
for (const [dir, watcher] of watchers.entries()) {
|
|
78
|
-
if (found.has(dir))
|
|
79
|
-
continue;
|
|
80
|
-
watcher.close();
|
|
81
|
-
watchers.delete(dir);
|
|
82
|
-
changed = true;
|
|
83
|
-
}
|
|
84
|
-
return changed;
|
|
85
|
-
};
|
|
86
|
-
refreshAll();
|
|
87
|
-
return {
|
|
88
|
-
close() {
|
|
89
|
-
closed = true;
|
|
90
|
-
clearInterval(interval);
|
|
91
|
-
if (timer)
|
|
92
|
-
clearTimeout(timer);
|
|
93
|
-
for (const watcher of watchers.values()) {
|
|
94
|
-
watcher.close();
|
|
95
|
-
}
|
|
96
|
-
watchers.clear();
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
export { createDiscoveryWatcher };
|
|
1
|
+
export * from "../internal/core/discovery-watch.js";
|
|
101
2
|
//# sourceMappingURL=discovery-watch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-watch.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"discovery-watch.js","sourceRoot":"","sources":["../../../src/core/discovery-watch.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
package/dist/core/discovery.d.ts
CHANGED
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare const VIRTUAL_ENTRY_PREFIX = "trebired-virtual:";
|
|
3
|
-
type NormalizedDiscoverOptions = {
|
|
4
|
-
dir: string;
|
|
5
|
-
dirAbs: string;
|
|
6
|
-
exclude: string[];
|
|
7
|
-
extensions: string[];
|
|
8
|
-
ignoreDirs: Set<string>;
|
|
9
|
-
include: string[];
|
|
10
|
-
maxBundleSize: number;
|
|
11
|
-
namePrefix: string;
|
|
12
|
-
};
|
|
13
|
-
type ResolvedEntries = {
|
|
14
|
-
duplicates: DuplicateBundlerEntryRecord[];
|
|
15
|
-
records: BundlerEntryRecord[];
|
|
16
|
-
signature: string;
|
|
17
|
-
};
|
|
18
|
-
type DuplicateBundlerEntryRecord = {
|
|
19
|
-
dropped: BundlerEntryRecord;
|
|
20
|
-
kept: BundlerEntryRecord;
|
|
21
|
-
};
|
|
22
|
-
type NormalizedManifestOptions = {
|
|
23
|
-
enabled: boolean;
|
|
24
|
-
file?: string;
|
|
25
|
-
};
|
|
26
|
-
declare function toPosixPath(value: string): string;
|
|
27
|
-
declare function resolveBundlerEntries(options: BundlerOptions, rootDir: string, settings?: {
|
|
28
|
-
allowEmpty?: boolean;
|
|
29
|
-
}): Promise<ResolvedEntries>;
|
|
30
|
-
declare function toEntryPointMap(records: BundlerEntryRecord[], rootDir: string): Record<string, string>;
|
|
31
|
-
declare function toPublicEntryMap(records: BundlerEntryRecord[], rootDir: string): Record<string, string>;
|
|
32
|
-
declare function normalizeManifestOptions(manifest: BundlerManifestOptions | undefined): NormalizedManifestOptions;
|
|
33
|
-
declare function normalizeDiscoverRoots(rootDir: string, discover: BundlerOptions["discover"]): string[];
|
|
34
|
-
export { normalizeDiscoverRoots, normalizeManifestOptions, resolveBundlerEntries, toPublicEntryMap, toEntryPointMap, toPosixPath, VIRTUAL_ENTRY_PREFIX, };
|
|
35
|
-
export type { DuplicateBundlerEntryRecord, NormalizedDiscoverOptions, NormalizedManifestOptions, ResolvedEntries, };
|
|
1
|
+
export * from "../internal/core/discovery.d.ts";
|
|
36
2
|
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/core/discovery.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|