@mosetta/build 0.0.38 → 0.0.40

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.
@@ -1,56 +0,0 @@
1
- import { path } from '../nodeApi.mjs';
2
-
3
- const TS_RE = /\.(ts|tsx)$/;
4
- const LOADER = { '.ts': 'ts', '.tsx': 'tsx' };
5
-
6
- // Transpile policy belongs to the BUILD, not the engine: the engine only knows "string in, string out".
7
- const TRANSFORM = {
8
- jsx: 'automatic',
9
- target: 'es2020',
10
- tsconfigRaw: { compilerOptions: { experimentalDecorators: true } },
11
- };
12
-
13
- /**
14
- * TS/TSX transpilation as an ENGINE CAPABILITY, not a binding to a native binary.
15
- *
16
- * This used to be `rollup-plugin-esbuild`, pulling the platform esbuild binary — the last
17
- * engine-bound node of the client path, not portable into an isolate. Now the plugin asks the
18
- * engine for `transform(code, opts)`; which esbuild stands behind it — native or wasm — is
19
- * decided by whoever injected the engine. Resolution is not part of this: `portResolve`
20
- * covers it entirely.
21
- */
22
- export function transformTs(engine) {
23
- return {
24
- name: 'mosetta-transform',
25
- async transform(code, id) {
26
- if (!TS_RE.test(id)) return null;
27
- const r = await engine.transform(code, {
28
- ...TRANSFORM,
29
- loader: LOADER[path.extname(id)],
30
- sourcefile: id,
31
- sourcemap: true,
32
- });
33
- return { code: r.code, map: r.map || null };
34
- },
35
- };
36
- }
37
-
38
- /**
39
- * Minification — a post-pass over the finished chunk (prod). Mangling touches only the
40
- * artifact's internal scope: the `System.register` name, dependency specifiers and export names
41
- * are string literals, so cross-artifact linkage survives it unchanged.
42
- */
43
- export function minifyChunk(engine) {
44
- return {
45
- name: 'mosetta-minify',
46
- async renderChunk(code) {
47
- const r = await engine.transform(code, {
48
- loader: 'js',
49
- minify: true,
50
- target: TRANSFORM.target,
51
- sourcemap: true,
52
- });
53
- return { code: r.code, map: r.map || null };
54
- },
55
- };
56
- }