unplugin-atscript 0.1.109 → 0.1.110
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/dist/esbuild.cjs +9 -2
- package/dist/esbuild.d.ts +11 -0
- package/dist/esbuild.mjs +10 -3
- package/dist/farm.cjs +9 -2
- package/dist/farm.d.ts +11 -0
- package/dist/farm.mjs +10 -3
- package/dist/index.cjs +9 -2
- package/dist/index.d.ts +11 -0
- package/dist/index.mjs +10 -3
- package/dist/rolldown.cjs +9 -2
- package/dist/rolldown.d.ts +11 -0
- package/dist/rolldown.mjs +10 -3
- package/dist/rollup.cjs +9 -2
- package/dist/rollup.d.ts +11 -0
- package/dist/rollup.mjs +10 -3
- package/dist/rspack.cjs +9 -2
- package/dist/rspack.d.ts +11 -0
- package/dist/rspack.mjs +10 -3
- package/dist/vite.cjs +9 -2
- package/dist/vite.d.ts +11 -0
- package/dist/vite.mjs +10 -3
- package/dist/webpack.cjs +9 -2
- package/dist/webpack.d.ts +11 -0
- package/dist/webpack.mjs +10 -3
- package/package.json +3 -3
package/dist/esbuild.cjs
CHANGED
|
@@ -34,6 +34,10 @@ let _atscript_core = require("@atscript/core");
|
|
|
34
34
|
let _atscript_typescript = require("@atscript/typescript");
|
|
35
35
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
38
|
+
if (options?.ssr === true) return true;
|
|
39
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
40
|
+
}
|
|
37
41
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
42
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
43
|
/**
|
|
@@ -95,7 +99,7 @@ const unpluginFactory = (opts) => {
|
|
|
95
99
|
return resolved;
|
|
96
100
|
}
|
|
97
101
|
},
|
|
98
|
-
async load(id) {
|
|
102
|
+
async load(id, options) {
|
|
99
103
|
const isDts = id.endsWith(".as.d.ts");
|
|
100
104
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
101
105
|
if (sourceId.endsWith(".as")) {
|
|
@@ -119,7 +123,10 @@ const unpluginFactory = (opts) => {
|
|
|
119
123
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
120
124
|
map: null
|
|
121
125
|
};
|
|
122
|
-
const
|
|
126
|
+
const compile = opts?.compileValidators;
|
|
127
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? _atscript_typescript.JS_COMPILED_FORMAT : _atscript_typescript.JS_INTERPRETED_FORMAT;
|
|
128
|
+
let out = await doc.render(format);
|
|
129
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
123
130
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
124
131
|
return {
|
|
125
132
|
code: out?.[0]?.content || "",
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -20,6 +20,17 @@ interface atscriptPluginOptions {
|
|
|
20
20
|
* config-provided plugins (`@db.*`, `@ui.*`, …) are reported as unknown.
|
|
21
21
|
*/
|
|
22
22
|
root?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Overrides `tsPlugin({ compileValidators })` of the atscript config for the modules
|
|
25
|
+
* this plugin renders:
|
|
26
|
+
* - `true` / `false` — always / never emit build-time compiled validator checks.
|
|
27
|
+
* - `'ssr'` — only for server builds: Vite's SSR / server environments get compiled
|
|
28
|
+
* checks, client bundles stay lean (one Vite config for both). Bundlers that do not
|
|
29
|
+
* report a server build (everything but Vite) get none.
|
|
30
|
+
*
|
|
31
|
+
* Unset: the atscript config decides (default: off).
|
|
32
|
+
*/
|
|
33
|
+
compileValidators?: boolean | 'ssr';
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
declare const _default: (options?: atscriptPluginOptions | undefined) => _unplugin.EsbuildPlugin;
|
package/dist/esbuild.mjs
CHANGED
|
@@ -3,9 +3,13 @@ import { readFile } from "fs/promises";
|
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
|
-
import { tsPlugin } from "@atscript/typescript";
|
|
6
|
+
import { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
10
|
+
if (options?.ssr === true) return true;
|
|
11
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
12
|
+
}
|
|
9
13
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
14
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
15
|
/**
|
|
@@ -67,7 +71,7 @@ const unpluginFactory = (opts) => {
|
|
|
67
71
|
return resolved;
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
|
-
async load(id) {
|
|
74
|
+
async load(id, options) {
|
|
71
75
|
const isDts = id.endsWith(".as.d.ts");
|
|
72
76
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
73
77
|
if (sourceId.endsWith(".as")) {
|
|
@@ -91,7 +95,10 @@ const unpluginFactory = (opts) => {
|
|
|
91
95
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
92
96
|
map: null
|
|
93
97
|
};
|
|
94
|
-
const
|
|
98
|
+
const compile = opts?.compileValidators;
|
|
99
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? JS_COMPILED_FORMAT : JS_INTERPRETED_FORMAT;
|
|
100
|
+
let out = await doc.render(format);
|
|
101
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
95
102
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
96
103
|
return {
|
|
97
104
|
code: out?.[0]?.content || "",
|
package/dist/farm.cjs
CHANGED
|
@@ -34,6 +34,10 @@ let _atscript_core = require("@atscript/core");
|
|
|
34
34
|
let _atscript_typescript = require("@atscript/typescript");
|
|
35
35
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
38
|
+
if (options?.ssr === true) return true;
|
|
39
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
40
|
+
}
|
|
37
41
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
42
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
43
|
/**
|
|
@@ -95,7 +99,7 @@ const unpluginFactory = (opts) => {
|
|
|
95
99
|
return resolved;
|
|
96
100
|
}
|
|
97
101
|
},
|
|
98
|
-
async load(id) {
|
|
102
|
+
async load(id, options) {
|
|
99
103
|
const isDts = id.endsWith(".as.d.ts");
|
|
100
104
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
101
105
|
if (sourceId.endsWith(".as")) {
|
|
@@ -119,7 +123,10 @@ const unpluginFactory = (opts) => {
|
|
|
119
123
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
120
124
|
map: null
|
|
121
125
|
};
|
|
122
|
-
const
|
|
126
|
+
const compile = opts?.compileValidators;
|
|
127
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? _atscript_typescript.JS_COMPILED_FORMAT : _atscript_typescript.JS_INTERPRETED_FORMAT;
|
|
128
|
+
let out = await doc.render(format);
|
|
129
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
123
130
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
124
131
|
return {
|
|
125
132
|
code: out?.[0]?.content || "",
|
package/dist/farm.d.ts
CHANGED
|
@@ -18,6 +18,17 @@ interface atscriptPluginOptions {
|
|
|
18
18
|
* config-provided plugins (`@db.*`, `@ui.*`, …) are reported as unknown.
|
|
19
19
|
*/
|
|
20
20
|
root?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Overrides `tsPlugin({ compileValidators })` of the atscript config for the modules
|
|
23
|
+
* this plugin renders:
|
|
24
|
+
* - `true` / `false` — always / never emit build-time compiled validator checks.
|
|
25
|
+
* - `'ssr'` — only for server builds: Vite's SSR / server environments get compiled
|
|
26
|
+
* checks, client bundles stay lean (one Vite config for both). Bundlers that do not
|
|
27
|
+
* report a server build (everything but Vite) get none.
|
|
28
|
+
*
|
|
29
|
+
* Unset: the atscript config decides (default: off).
|
|
30
|
+
*/
|
|
31
|
+
compileValidators?: boolean | 'ssr';
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
declare const _default: (options?: atscriptPluginOptions | undefined) => JsPlugin;
|
package/dist/farm.mjs
CHANGED
|
@@ -3,9 +3,13 @@ import { readFile } from "fs/promises";
|
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
|
-
import { tsPlugin } from "@atscript/typescript";
|
|
6
|
+
import { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
10
|
+
if (options?.ssr === true) return true;
|
|
11
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
12
|
+
}
|
|
9
13
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
14
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
15
|
/**
|
|
@@ -67,7 +71,7 @@ const unpluginFactory = (opts) => {
|
|
|
67
71
|
return resolved;
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
|
-
async load(id) {
|
|
74
|
+
async load(id, options) {
|
|
71
75
|
const isDts = id.endsWith(".as.d.ts");
|
|
72
76
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
73
77
|
if (sourceId.endsWith(".as")) {
|
|
@@ -91,7 +95,10 @@ const unpluginFactory = (opts) => {
|
|
|
91
95
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
92
96
|
map: null
|
|
93
97
|
};
|
|
94
|
-
const
|
|
98
|
+
const compile = opts?.compileValidators;
|
|
99
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? JS_COMPILED_FORMAT : JS_INTERPRETED_FORMAT;
|
|
100
|
+
let out = await doc.render(format);
|
|
101
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
95
102
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
96
103
|
return {
|
|
97
104
|
code: out?.[0]?.content || "",
|
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,10 @@ let _atscript_typescript = require("@atscript/typescript");
|
|
|
35
35
|
let unplugin = require("unplugin");
|
|
36
36
|
|
|
37
37
|
//#region packages/unplugin/src/index.ts
|
|
38
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
39
|
+
if (options?.ssr === true) return true;
|
|
40
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
41
|
+
}
|
|
38
42
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
39
43
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
40
44
|
/**
|
|
@@ -96,7 +100,7 @@ const unpluginFactory = (opts) => {
|
|
|
96
100
|
return resolved;
|
|
97
101
|
}
|
|
98
102
|
},
|
|
99
|
-
async load(id) {
|
|
103
|
+
async load(id, options) {
|
|
100
104
|
const isDts = id.endsWith(".as.d.ts");
|
|
101
105
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
102
106
|
if (sourceId.endsWith(".as")) {
|
|
@@ -120,7 +124,10 @@ const unpluginFactory = (opts) => {
|
|
|
120
124
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
121
125
|
map: null
|
|
122
126
|
};
|
|
123
|
-
const
|
|
127
|
+
const compile = opts?.compileValidators;
|
|
128
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? _atscript_typescript.JS_COMPILED_FORMAT : _atscript_typescript.JS_INTERPRETED_FORMAT;
|
|
129
|
+
let out = await doc.render(format);
|
|
130
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
124
131
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
125
132
|
return {
|
|
126
133
|
code: out?.[0]?.content || "",
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,17 @@ interface atscriptPluginOptions {
|
|
|
21
21
|
* config-provided plugins (`@db.*`, `@ui.*`, …) are reported as unknown.
|
|
22
22
|
*/
|
|
23
23
|
root?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Overrides `tsPlugin({ compileValidators })` of the atscript config for the modules
|
|
26
|
+
* this plugin renders:
|
|
27
|
+
* - `true` / `false` — always / never emit build-time compiled validator checks.
|
|
28
|
+
* - `'ssr'` — only for server builds: Vite's SSR / server environments get compiled
|
|
29
|
+
* checks, client bundles stay lean (one Vite config for both). Bundlers that do not
|
|
30
|
+
* report a server build (everything but Vite) get none.
|
|
31
|
+
*
|
|
32
|
+
* Unset: the atscript config decides (default: off).
|
|
33
|
+
*/
|
|
34
|
+
compileValidators?: boolean | 'ssr';
|
|
24
35
|
}
|
|
25
36
|
declare const unpluginFactory: UnpluginFactory<atscriptPluginOptions | undefined>;
|
|
26
37
|
declare const unplugin: _unplugin.UnpluginInstance<atscriptPluginOptions | undefined, boolean>;
|
package/dist/index.mjs
CHANGED
|
@@ -2,10 +2,14 @@ import { readFile } from "fs/promises";
|
|
|
2
2
|
import { createRequire } from "module";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
-
import { tsPlugin } from "@atscript/typescript";
|
|
5
|
+
import { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin } from "@atscript/typescript";
|
|
6
6
|
import { createUnplugin } from "unplugin";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
10
|
+
if (options?.ssr === true) return true;
|
|
11
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
12
|
+
}
|
|
9
13
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
14
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
15
|
/**
|
|
@@ -67,7 +71,7 @@ const unpluginFactory = (opts) => {
|
|
|
67
71
|
return resolved;
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
|
-
async load(id) {
|
|
74
|
+
async load(id, options) {
|
|
71
75
|
const isDts = id.endsWith(".as.d.ts");
|
|
72
76
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
73
77
|
if (sourceId.endsWith(".as")) {
|
|
@@ -91,7 +95,10 @@ const unpluginFactory = (opts) => {
|
|
|
91
95
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
92
96
|
map: null
|
|
93
97
|
};
|
|
94
|
-
const
|
|
98
|
+
const compile = opts?.compileValidators;
|
|
99
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? JS_COMPILED_FORMAT : JS_INTERPRETED_FORMAT;
|
|
100
|
+
let out = await doc.render(format);
|
|
101
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
95
102
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
96
103
|
return {
|
|
97
104
|
code: out?.[0]?.content || "",
|
package/dist/rolldown.cjs
CHANGED
|
@@ -34,6 +34,10 @@ let _atscript_core = require("@atscript/core");
|
|
|
34
34
|
let _atscript_typescript = require("@atscript/typescript");
|
|
35
35
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
38
|
+
if (options?.ssr === true) return true;
|
|
39
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
40
|
+
}
|
|
37
41
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
42
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
43
|
/**
|
|
@@ -95,7 +99,7 @@ const unpluginFactory = (opts) => {
|
|
|
95
99
|
return resolved;
|
|
96
100
|
}
|
|
97
101
|
},
|
|
98
|
-
async load(id) {
|
|
102
|
+
async load(id, options) {
|
|
99
103
|
const isDts = id.endsWith(".as.d.ts");
|
|
100
104
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
101
105
|
if (sourceId.endsWith(".as")) {
|
|
@@ -119,7 +123,10 @@ const unpluginFactory = (opts) => {
|
|
|
119
123
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
120
124
|
map: null
|
|
121
125
|
};
|
|
122
|
-
const
|
|
126
|
+
const compile = opts?.compileValidators;
|
|
127
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? _atscript_typescript.JS_COMPILED_FORMAT : _atscript_typescript.JS_INTERPRETED_FORMAT;
|
|
128
|
+
let out = await doc.render(format);
|
|
129
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
123
130
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
124
131
|
return {
|
|
125
132
|
code: out?.[0]?.content || "",
|
package/dist/rolldown.d.ts
CHANGED
|
@@ -20,6 +20,17 @@ interface atscriptPluginOptions {
|
|
|
20
20
|
* config-provided plugins (`@db.*`, `@ui.*`, …) are reported as unknown.
|
|
21
21
|
*/
|
|
22
22
|
root?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Overrides `tsPlugin({ compileValidators })` of the atscript config for the modules
|
|
25
|
+
* this plugin renders:
|
|
26
|
+
* - `true` / `false` — always / never emit build-time compiled validator checks.
|
|
27
|
+
* - `'ssr'` — only for server builds: Vite's SSR / server environments get compiled
|
|
28
|
+
* checks, client bundles stay lean (one Vite config for both). Bundlers that do not
|
|
29
|
+
* report a server build (everything but Vite) get none.
|
|
30
|
+
*
|
|
31
|
+
* Unset: the atscript config decides (default: off).
|
|
32
|
+
*/
|
|
33
|
+
compileValidators?: boolean | 'ssr';
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
declare const _default: (options?: atscriptPluginOptions | undefined) => rolldown.Plugin<any> | rolldown.Plugin<any>[];
|
package/dist/rolldown.mjs
CHANGED
|
@@ -3,9 +3,13 @@ import { readFile } from "fs/promises";
|
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
|
-
import { tsPlugin } from "@atscript/typescript";
|
|
6
|
+
import { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
10
|
+
if (options?.ssr === true) return true;
|
|
11
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
12
|
+
}
|
|
9
13
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
14
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
15
|
/**
|
|
@@ -67,7 +71,7 @@ const unpluginFactory = (opts) => {
|
|
|
67
71
|
return resolved;
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
|
-
async load(id) {
|
|
74
|
+
async load(id, options) {
|
|
71
75
|
const isDts = id.endsWith(".as.d.ts");
|
|
72
76
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
73
77
|
if (sourceId.endsWith(".as")) {
|
|
@@ -91,7 +95,10 @@ const unpluginFactory = (opts) => {
|
|
|
91
95
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
92
96
|
map: null
|
|
93
97
|
};
|
|
94
|
-
const
|
|
98
|
+
const compile = opts?.compileValidators;
|
|
99
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? JS_COMPILED_FORMAT : JS_INTERPRETED_FORMAT;
|
|
100
|
+
let out = await doc.render(format);
|
|
101
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
95
102
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
96
103
|
return {
|
|
97
104
|
code: out?.[0]?.content || "",
|
package/dist/rollup.cjs
CHANGED
|
@@ -34,6 +34,10 @@ let _atscript_core = require("@atscript/core");
|
|
|
34
34
|
let _atscript_typescript = require("@atscript/typescript");
|
|
35
35
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
38
|
+
if (options?.ssr === true) return true;
|
|
39
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
40
|
+
}
|
|
37
41
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
42
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
43
|
/**
|
|
@@ -95,7 +99,7 @@ const unpluginFactory = (opts) => {
|
|
|
95
99
|
return resolved;
|
|
96
100
|
}
|
|
97
101
|
},
|
|
98
|
-
async load(id) {
|
|
102
|
+
async load(id, options) {
|
|
99
103
|
const isDts = id.endsWith(".as.d.ts");
|
|
100
104
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
101
105
|
if (sourceId.endsWith(".as")) {
|
|
@@ -119,7 +123,10 @@ const unpluginFactory = (opts) => {
|
|
|
119
123
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
120
124
|
map: null
|
|
121
125
|
};
|
|
122
|
-
const
|
|
126
|
+
const compile = opts?.compileValidators;
|
|
127
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? _atscript_typescript.JS_COMPILED_FORMAT : _atscript_typescript.JS_INTERPRETED_FORMAT;
|
|
128
|
+
let out = await doc.render(format);
|
|
129
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
123
130
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
124
131
|
return {
|
|
125
132
|
code: out?.[0]?.content || "",
|
package/dist/rollup.d.ts
CHANGED
|
@@ -20,6 +20,17 @@ interface atscriptPluginOptions {
|
|
|
20
20
|
* config-provided plugins (`@db.*`, `@ui.*`, …) are reported as unknown.
|
|
21
21
|
*/
|
|
22
22
|
root?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Overrides `tsPlugin({ compileValidators })` of the atscript config for the modules
|
|
25
|
+
* this plugin renders:
|
|
26
|
+
* - `true` / `false` — always / never emit build-time compiled validator checks.
|
|
27
|
+
* - `'ssr'` — only for server builds: Vite's SSR / server environments get compiled
|
|
28
|
+
* checks, client bundles stay lean (one Vite config for both). Bundlers that do not
|
|
29
|
+
* report a server build (everything but Vite) get none.
|
|
30
|
+
*
|
|
31
|
+
* Unset: the atscript config decides (default: off).
|
|
32
|
+
*/
|
|
33
|
+
compileValidators?: boolean | 'ssr';
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
declare const _default: (options?: atscriptPluginOptions | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
|
package/dist/rollup.mjs
CHANGED
|
@@ -3,9 +3,13 @@ import { readFile } from "fs/promises";
|
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
|
-
import { tsPlugin } from "@atscript/typescript";
|
|
6
|
+
import { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
10
|
+
if (options?.ssr === true) return true;
|
|
11
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
12
|
+
}
|
|
9
13
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
14
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
15
|
/**
|
|
@@ -67,7 +71,7 @@ const unpluginFactory = (opts) => {
|
|
|
67
71
|
return resolved;
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
|
-
async load(id) {
|
|
74
|
+
async load(id, options) {
|
|
71
75
|
const isDts = id.endsWith(".as.d.ts");
|
|
72
76
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
73
77
|
if (sourceId.endsWith(".as")) {
|
|
@@ -91,7 +95,10 @@ const unpluginFactory = (opts) => {
|
|
|
91
95
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
92
96
|
map: null
|
|
93
97
|
};
|
|
94
|
-
const
|
|
98
|
+
const compile = opts?.compileValidators;
|
|
99
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? JS_COMPILED_FORMAT : JS_INTERPRETED_FORMAT;
|
|
100
|
+
let out = await doc.render(format);
|
|
101
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
95
102
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
96
103
|
return {
|
|
97
104
|
code: out?.[0]?.content || "",
|
package/dist/rspack.cjs
CHANGED
|
@@ -34,6 +34,10 @@ let _atscript_core = require("@atscript/core");
|
|
|
34
34
|
let _atscript_typescript = require("@atscript/typescript");
|
|
35
35
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
38
|
+
if (options?.ssr === true) return true;
|
|
39
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
40
|
+
}
|
|
37
41
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
42
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
43
|
/**
|
|
@@ -95,7 +99,7 @@ const unpluginFactory = (opts) => {
|
|
|
95
99
|
return resolved;
|
|
96
100
|
}
|
|
97
101
|
},
|
|
98
|
-
async load(id) {
|
|
102
|
+
async load(id, options) {
|
|
99
103
|
const isDts = id.endsWith(".as.d.ts");
|
|
100
104
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
101
105
|
if (sourceId.endsWith(".as")) {
|
|
@@ -119,7 +123,10 @@ const unpluginFactory = (opts) => {
|
|
|
119
123
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
120
124
|
map: null
|
|
121
125
|
};
|
|
122
|
-
const
|
|
126
|
+
const compile = opts?.compileValidators;
|
|
127
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? _atscript_typescript.JS_COMPILED_FORMAT : _atscript_typescript.JS_INTERPRETED_FORMAT;
|
|
128
|
+
let out = await doc.render(format);
|
|
129
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
123
130
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
124
131
|
return {
|
|
125
132
|
code: out?.[0]?.content || "",
|
package/dist/rspack.d.ts
CHANGED
|
@@ -18,6 +18,17 @@ interface atscriptPluginOptions {
|
|
|
18
18
|
* config-provided plugins (`@db.*`, `@ui.*`, …) are reported as unknown.
|
|
19
19
|
*/
|
|
20
20
|
root?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Overrides `tsPlugin({ compileValidators })` of the atscript config for the modules
|
|
23
|
+
* this plugin renders:
|
|
24
|
+
* - `true` / `false` — always / never emit build-time compiled validator checks.
|
|
25
|
+
* - `'ssr'` — only for server builds: Vite's SSR / server environments get compiled
|
|
26
|
+
* checks, client bundles stay lean (one Vite config for both). Bundlers that do not
|
|
27
|
+
* report a server build (everything but Vite) get none.
|
|
28
|
+
*
|
|
29
|
+
* Unset: the atscript config decides (default: off).
|
|
30
|
+
*/
|
|
31
|
+
compileValidators?: boolean | 'ssr';
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
declare const _default: (options?: atscriptPluginOptions | undefined) => RspackPluginInstance;
|
package/dist/rspack.mjs
CHANGED
|
@@ -3,9 +3,13 @@ import { readFile } from "fs/promises";
|
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
|
-
import { tsPlugin } from "@atscript/typescript";
|
|
6
|
+
import { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
10
|
+
if (options?.ssr === true) return true;
|
|
11
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
12
|
+
}
|
|
9
13
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
14
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
15
|
/**
|
|
@@ -67,7 +71,7 @@ const unpluginFactory = (opts) => {
|
|
|
67
71
|
return resolved;
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
|
-
async load(id) {
|
|
74
|
+
async load(id, options) {
|
|
71
75
|
const isDts = id.endsWith(".as.d.ts");
|
|
72
76
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
73
77
|
if (sourceId.endsWith(".as")) {
|
|
@@ -91,7 +95,10 @@ const unpluginFactory = (opts) => {
|
|
|
91
95
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
92
96
|
map: null
|
|
93
97
|
};
|
|
94
|
-
const
|
|
98
|
+
const compile = opts?.compileValidators;
|
|
99
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? JS_COMPILED_FORMAT : JS_INTERPRETED_FORMAT;
|
|
100
|
+
let out = await doc.render(format);
|
|
101
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
95
102
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
96
103
|
return {
|
|
97
104
|
code: out?.[0]?.content || "",
|
package/dist/vite.cjs
CHANGED
|
@@ -34,6 +34,10 @@ let _atscript_core = require("@atscript/core");
|
|
|
34
34
|
let _atscript_typescript = require("@atscript/typescript");
|
|
35
35
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
38
|
+
if (options?.ssr === true) return true;
|
|
39
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
40
|
+
}
|
|
37
41
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
42
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
43
|
/**
|
|
@@ -95,7 +99,7 @@ const unpluginFactory = (opts) => {
|
|
|
95
99
|
return resolved;
|
|
96
100
|
}
|
|
97
101
|
},
|
|
98
|
-
async load(id) {
|
|
102
|
+
async load(id, options) {
|
|
99
103
|
const isDts = id.endsWith(".as.d.ts");
|
|
100
104
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
101
105
|
if (sourceId.endsWith(".as")) {
|
|
@@ -119,7 +123,10 @@ const unpluginFactory = (opts) => {
|
|
|
119
123
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
120
124
|
map: null
|
|
121
125
|
};
|
|
122
|
-
const
|
|
126
|
+
const compile = opts?.compileValidators;
|
|
127
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? _atscript_typescript.JS_COMPILED_FORMAT : _atscript_typescript.JS_INTERPRETED_FORMAT;
|
|
128
|
+
let out = await doc.render(format);
|
|
129
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
123
130
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
124
131
|
return {
|
|
125
132
|
code: out?.[0]?.content || "",
|
package/dist/vite.d.ts
CHANGED
|
@@ -20,6 +20,17 @@ interface atscriptPluginOptions {
|
|
|
20
20
|
* config-provided plugins (`@db.*`, `@ui.*`, …) are reported as unknown.
|
|
21
21
|
*/
|
|
22
22
|
root?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Overrides `tsPlugin({ compileValidators })` of the atscript config for the modules
|
|
25
|
+
* this plugin renders:
|
|
26
|
+
* - `true` / `false` — always / never emit build-time compiled validator checks.
|
|
27
|
+
* - `'ssr'` — only for server builds: Vite's SSR / server environments get compiled
|
|
28
|
+
* checks, client bundles stay lean (one Vite config for both). Bundlers that do not
|
|
29
|
+
* report a server build (everything but Vite) get none.
|
|
30
|
+
*
|
|
31
|
+
* Unset: the atscript config decides (default: off).
|
|
32
|
+
*/
|
|
33
|
+
compileValidators?: boolean | 'ssr';
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
declare const _default: (options?: atscriptPluginOptions | undefined) => _unplugin.VitePlugin<any> | _unplugin.VitePlugin<any>[];
|
package/dist/vite.mjs
CHANGED
|
@@ -3,9 +3,13 @@ import { readFile } from "fs/promises";
|
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
|
-
import { tsPlugin } from "@atscript/typescript";
|
|
6
|
+
import { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
10
|
+
if (options?.ssr === true) return true;
|
|
11
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
12
|
+
}
|
|
9
13
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
14
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
15
|
/**
|
|
@@ -67,7 +71,7 @@ const unpluginFactory = (opts) => {
|
|
|
67
71
|
return resolved;
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
|
-
async load(id) {
|
|
74
|
+
async load(id, options) {
|
|
71
75
|
const isDts = id.endsWith(".as.d.ts");
|
|
72
76
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
73
77
|
if (sourceId.endsWith(".as")) {
|
|
@@ -91,7 +95,10 @@ const unpluginFactory = (opts) => {
|
|
|
91
95
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
92
96
|
map: null
|
|
93
97
|
};
|
|
94
|
-
const
|
|
98
|
+
const compile = opts?.compileValidators;
|
|
99
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? JS_COMPILED_FORMAT : JS_INTERPRETED_FORMAT;
|
|
100
|
+
let out = await doc.render(format);
|
|
101
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
95
102
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
96
103
|
return {
|
|
97
104
|
code: out?.[0]?.content || "",
|
package/dist/webpack.cjs
CHANGED
|
@@ -34,6 +34,10 @@ let _atscript_core = require("@atscript/core");
|
|
|
34
34
|
let _atscript_typescript = require("@atscript/typescript");
|
|
35
35
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
38
|
+
if (options?.ssr === true) return true;
|
|
39
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
40
|
+
}
|
|
37
41
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
42
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
43
|
/**
|
|
@@ -95,7 +99,7 @@ const unpluginFactory = (opts) => {
|
|
|
95
99
|
return resolved;
|
|
96
100
|
}
|
|
97
101
|
},
|
|
98
|
-
async load(id) {
|
|
102
|
+
async load(id, options) {
|
|
99
103
|
const isDts = id.endsWith(".as.d.ts");
|
|
100
104
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
101
105
|
if (sourceId.endsWith(".as")) {
|
|
@@ -119,7 +123,10 @@ const unpluginFactory = (opts) => {
|
|
|
119
123
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
120
124
|
map: null
|
|
121
125
|
};
|
|
122
|
-
const
|
|
126
|
+
const compile = opts?.compileValidators;
|
|
127
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? _atscript_typescript.JS_COMPILED_FORMAT : _atscript_typescript.JS_INTERPRETED_FORMAT;
|
|
128
|
+
let out = await doc.render(format);
|
|
129
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
123
130
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
124
131
|
return {
|
|
125
132
|
code: out?.[0]?.content || "",
|
package/dist/webpack.d.ts
CHANGED
|
@@ -18,6 +18,17 @@ interface atscriptPluginOptions {
|
|
|
18
18
|
* config-provided plugins (`@db.*`, `@ui.*`, …) are reported as unknown.
|
|
19
19
|
*/
|
|
20
20
|
root?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Overrides `tsPlugin({ compileValidators })` of the atscript config for the modules
|
|
23
|
+
* this plugin renders:
|
|
24
|
+
* - `true` / `false` — always / never emit build-time compiled validator checks.
|
|
25
|
+
* - `'ssr'` — only for server builds: Vite's SSR / server environments get compiled
|
|
26
|
+
* checks, client bundles stay lean (one Vite config for both). Bundlers that do not
|
|
27
|
+
* report a server build (everything but Vite) get none.
|
|
28
|
+
*
|
|
29
|
+
* Unset: the atscript config decides (default: off).
|
|
30
|
+
*/
|
|
31
|
+
compileValidators?: boolean | 'ssr';
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
declare const _default: (options?: atscriptPluginOptions | undefined) => WebpackPluginInstance;
|
package/dist/webpack.mjs
CHANGED
|
@@ -3,9 +3,13 @@ import { readFile } from "fs/promises";
|
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
|
-
import { tsPlugin } from "@atscript/typescript";
|
|
6
|
+
import { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
|
+
/** `true` when Vite is loading the module for a server (SSR) build / environment. */ function isServerLoad(ctx, options) {
|
|
10
|
+
if (options?.ssr === true) return true;
|
|
11
|
+
return ctx?.environment?.config?.consumer === "server";
|
|
12
|
+
}
|
|
9
13
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
14
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
15
|
/**
|
|
@@ -67,7 +71,7 @@ const unpluginFactory = (opts) => {
|
|
|
67
71
|
return resolved;
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
|
-
async load(id) {
|
|
74
|
+
async load(id, options) {
|
|
71
75
|
const isDts = id.endsWith(".as.d.ts");
|
|
72
76
|
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
73
77
|
if (sourceId.endsWith(".as")) {
|
|
@@ -91,7 +95,10 @@ const unpluginFactory = (opts) => {
|
|
|
91
95
|
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
92
96
|
map: null
|
|
93
97
|
};
|
|
94
|
-
const
|
|
98
|
+
const compile = opts?.compileValidators;
|
|
99
|
+
const format = compile === void 0 ? "js" : compile === true || compile === "ssr" && isServerLoad(this, options) ? JS_COMPILED_FORMAT : JS_INTERPRETED_FORMAT;
|
|
100
|
+
let out = await doc.render(format);
|
|
101
|
+
if (!out?.[0]?.content && format !== "js") out = await doc.render("js");
|
|
95
102
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
96
103
|
return {
|
|
97
104
|
code: out?.[0]?.content || "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-atscript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.110",
|
|
4
4
|
"description": "Atscript: Configuration and build plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"vitest": "3.2.7"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
|
-
"@atscript/core": "^0.1.
|
|
86
|
-
"@atscript/typescript": "^0.1.
|
|
85
|
+
"@atscript/core": "^0.1.110",
|
|
86
|
+
"@atscript/typescript": "^0.1.110"
|
|
87
87
|
},
|
|
88
88
|
"build": [
|
|
89
89
|
{},
|