@decohere/forge 0.0.1-dev.105 → 0.0.1-dev.107

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/README.md CHANGED
@@ -8,7 +8,7 @@ Build system (SWC). `forge build --configuration debug` rewrites workspace impor
8
8
 
9
9
  ## Debug path aliases (not `node_modules` links)
10
10
 
11
- Forge debug (`aliasPaths: true`) asks Mesh for a map of `package.json` `name` → source `main` (`Workspace.getPackageAliases`) and feeds it to SWC as `jsc.paths`. Flux’s resolve hook uses that same map so dynamic `import("@scope/pkg")` hits source too.
11
+ Forge debug (`aliasPaths: true`) asks Mesh for a map of `package.json` `name` → source `main` (`Workspace.getPackageAliases`) and feeds it to SWC as `jsc.paths`. Flux uses the same map in its resolve hook only, and compiles without `jsc.paths` or `resolveFully`, so imports are resolved once (#513).
12
12
 
13
13
  That is a **debug** rule. Release does not rewrite aliases: production must resolve like any other Node app (installed packages, `exports` / `main` pointing at emitted JS).
14
14
 
@@ -88,12 +88,19 @@ class SwcTranspiler extends (0, _extensibility.mixwith)(_cachesoutputsmixin.Cach
88
88
  const responses = this.transformTarget(files, buildTarget, options);
89
89
  return responses;
90
90
  }
91
+ /**
92
+ * The SWC options for one project and target, without a filename. Building them reads the
93
+ * workspace's aliases and merges configs, so a caller that transpiles many files builds them
94
+ * once and passes them to {@link transformFileSync}.
95
+ */ createBaseConfig(buildTarget, options = {}) {
96
+ return this.#swcConfigFactory.createBaseConfig(buildTarget, this.withAliasContext(options));
97
+ }
91
98
  /**
92
99
  * Synchronous, single-file variant of `transformFile`.
93
100
  * Reads the file with `fs.readFileSync` and transpiles via `swc.transformSync`.
94
101
  * Intended for callers that cannot await (e.g. Node.js `registerHooks` load hook).
95
- */ transformFileSync(file, buildTarget, options = {}) {
96
- const baseConfig = this.#swcConfigFactory.createBaseConfig(buildTarget, this.withAliasContext(options));
102
+ * Pass `baseConfig` from {@link createBaseConfig} to skip rebuilding it for every file.
103
+ */ transformFileSync(file, buildTarget, options = {}, baseConfig = this.createBaseConfig(buildTarget, options)) {
97
104
  const swcOptions = this.#swcConfigFactory.createFileConfig(file, baseConfig);
98
105
  let content;
99
106
  try {
@@ -73,12 +73,19 @@ export class SwcTranspiler extends mixwith(CachesOutputs, IncrementalTransform)
73
73
  const responses = this.transformTarget(files, buildTarget, options);
74
74
  return responses;
75
75
  }
76
+ /**
77
+ * The SWC options for one project and target, without a filename. Building them reads the
78
+ * workspace's aliases and merges configs, so a caller that transpiles many files builds them
79
+ * once and passes them to {@link transformFileSync}.
80
+ */ createBaseConfig(buildTarget, options = {}) {
81
+ return this.#swcConfigFactory.createBaseConfig(buildTarget, this.withAliasContext(options));
82
+ }
76
83
  /**
77
84
  * Synchronous, single-file variant of `transformFile`.
78
85
  * Reads the file with `fs.readFileSync` and transpiles via `swc.transformSync`.
79
86
  * Intended for callers that cannot await (e.g. Node.js `registerHooks` load hook).
80
- */ transformFileSync(file, buildTarget, options = {}) {
81
- const baseConfig = this.#swcConfigFactory.createBaseConfig(buildTarget, this.withAliasContext(options));
87
+ * Pass `baseConfig` from {@link createBaseConfig} to skip rebuilding it for every file.
88
+ */ transformFileSync(file, buildTarget, options = {}, baseConfig = this.createBaseConfig(buildTarget, options)) {
82
89
  const swcOptions = this.#swcConfigFactory.createFileConfig(file, baseConfig);
83
90
  let content;
84
91
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/forge",
3
- "version": "0.0.1-dev.105",
3
+ "version": "0.0.1-dev.107",
4
4
  "description": "TypeScript monorepo build system — zero config, fast compilation, streamlined developer workflow",
5
5
  "keywords": [
6
6
  "typescript",
@@ -29,10 +29,10 @@
29
29
  "test": "echo \"Error: no test specified\" && exit 1"
30
30
  },
31
31
  "dependencies": {
32
- "@decohere/crucible": "0.0.1-dev.105",
33
- "@decohere/mesh": "0.0.1-dev.105",
34
- "@decohere/nexus": "0.0.1-dev.105",
35
- "@decohere/scribe": "0.0.1-dev.105",
32
+ "@decohere/crucible": "0.0.1-dev.107",
33
+ "@decohere/mesh": "0.0.1-dev.107",
34
+ "@decohere/nexus": "0.0.1-dev.107",
35
+ "@decohere/scribe": "0.0.1-dev.107",
36
36
  "@swc/core": "^1.11.11",
37
37
  "async": "^3.2.6",
38
38
  "parse-imports": "^2.2.1",
@@ -1,5 +1,6 @@
1
1
  import type { Project, ProjectFileEvent, Tsconfig, Workspace } from "@decohere/mesh";
2
2
  import type { FileEx } from "@decohere/nexus/io";
3
+ import { type Options } from "@swc/core";
3
4
  import { type BuildTarget, type TranspileTarget } from "../types/build-target.type.js";
4
5
  import "../extensions/project.extensions.js";
5
6
  import { CachesOutputs } from "../mixins/caches-outputs.mixin.js";
@@ -23,12 +24,19 @@ export declare class SwcTranspiler extends SwcTranspiler_base implements Transfo
23
24
  private withAliasContext;
24
25
  transformProject(projectArrayLike: Project | Project[], fileFilter?: (project: Project) => Promise<FileEx[]>, onOutput?: (response: TransformResponse) => void): Promise<TransformResponse[]>;
25
26
  transformFile(fileArrayLike: FileEx[] | FileEx, buildTarget: TranspileTarget, options?: TranspileOptions): Promise<TransformResponse[]>;
27
+ /**
28
+ * The SWC options for one project and target, without a filename. Building them reads the
29
+ * workspace's aliases and merges configs, so a caller that transpiles many files builds them
30
+ * once and passes them to {@link transformFileSync}.
31
+ */
32
+ createBaseConfig(buildTarget: TranspileTarget, options?: TranspileOptions): Options;
26
33
  /**
27
34
  * Synchronous, single-file variant of `transformFile`.
28
35
  * Reads the file with `fs.readFileSync` and transpiles via `swc.transformSync`.
29
36
  * Intended for callers that cannot await (e.g. Node.js `registerHooks` load hook).
37
+ * Pass `baseConfig` from {@link createBaseConfig} to skip rebuilding it for every file.
30
38
  */
31
- transformFileSync(file: FileEx, buildTarget: TranspileTarget, options?: TranspileOptions): TransformResponse;
39
+ transformFileSync(file: FileEx, buildTarget: TranspileTarget, options?: TranspileOptions, baseConfig?: Options): TransformResponse;
32
40
  private transformTarget;
33
41
  private runTransform;
34
42
  protected onIncrementalFileEvent(evt: ProjectFileEvent): Promise<TransformResponse[]>;