unplugin-atscript 0.1.91 → 0.1.92
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 +1 -0
- package/dist/esbuild.cjs +25 -0
- package/dist/esbuild.mjs +26 -1
- package/dist/farm.cjs +25 -0
- package/dist/farm.mjs +26 -1
- package/dist/index.cjs +25 -0
- package/dist/index.mjs +26 -1
- package/dist/rolldown.cjs +25 -0
- package/dist/rolldown.mjs +26 -1
- package/dist/rollup.cjs +25 -0
- package/dist/rollup.mjs +26 -1
- package/dist/rspack.cjs +25 -0
- package/dist/rspack.mjs +26 -1
- package/dist/vite.cjs +25 -0
- package/dist/vite.mjs +26 -1
- package/dist/webpack.cjs +25 -0
- package/dist/webpack.mjs +26 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -58,6 +58,7 @@ Vite picks the root up automatically (from `configResolved`); other bundlers nee
|
|
|
58
58
|
- Strict validation — build fails on `.as` errors by default (`strict: false` to disable)
|
|
59
59
|
- Tree-shaking aware — marks non-mutating modules as side-effect-free
|
|
60
60
|
- On Vite, prebundles `@atscript/typescript/utils` so the first `.as`-backed route does not trigger a dep re-optimization reload
|
|
61
|
+
- Watch-safe in dev — a changed `.as` file is dropped from the document cache and every transitive `.as` import is registered as a watch file, so dependants are re-checked against the new definition on the next reload (esbuild excepted: unplugin has no `watchChange` for it, so under esbuild watch a changed `.as` import still needs a restart)
|
|
61
62
|
|
|
62
63
|
## Documentation
|
|
63
64
|
|
package/dist/esbuild.cjs
CHANGED
|
@@ -36,6 +36,26 @@ let _atscript_typescript = require("@atscript/typescript");
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
37
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
38
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
|
+
/**
|
|
40
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
41
|
+
*
|
|
42
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
43
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
44
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
45
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
46
|
+
* whenever any of them changes.
|
|
47
|
+
*
|
|
48
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
49
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
50
|
+
* it would prune the edge.
|
|
51
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
52
|
+
for (const dep of doc.dependencies) {
|
|
53
|
+
if (visited.has(dep)) continue;
|
|
54
|
+
visited.add(dep);
|
|
55
|
+
ctx.addWatchFile((0, _atscript_core.fileUriToPath)(dep.id));
|
|
56
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
39
59
|
function isResolvableFrom(specifier, from) {
|
|
40
60
|
try {
|
|
41
61
|
(0, module$1.createRequire)(path.default.join(from, "package.json")).resolve(specifier);
|
|
@@ -87,6 +107,7 @@ const unpluginFactory = (opts) => {
|
|
|
87
107
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
88
108
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
89
109
|
await repo.checkDoc(doc);
|
|
110
|
+
addTransitiveWatchFiles(this, doc);
|
|
90
111
|
const messages = doc.getDiagMessages().reverse();
|
|
91
112
|
let error = "";
|
|
92
113
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -107,6 +128,10 @@ const unpluginFactory = (opts) => {
|
|
|
107
128
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
108
129
|
};
|
|
109
130
|
}
|
|
131
|
+
},
|
|
132
|
+
watchChange(id) {
|
|
133
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
134
|
+
repo.closeDocument(`file://${id}`);
|
|
110
135
|
}
|
|
111
136
|
};
|
|
112
137
|
};
|
package/dist/esbuild.mjs
CHANGED
|
@@ -2,12 +2,32 @@ import { createEsbuildPlugin } from "unplugin";
|
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
6
|
import { tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
9
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
10
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
|
+
/**
|
|
12
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
13
|
+
*
|
|
14
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
15
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
16
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
17
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
18
|
+
* whenever any of them changes.
|
|
19
|
+
*
|
|
20
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
21
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
22
|
+
* it would prune the edge.
|
|
23
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
24
|
+
for (const dep of doc.dependencies) {
|
|
25
|
+
if (visited.has(dep)) continue;
|
|
26
|
+
visited.add(dep);
|
|
27
|
+
ctx.addWatchFile(fileUriToPath(dep.id));
|
|
28
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
11
31
|
function isResolvableFrom(specifier, from) {
|
|
12
32
|
try {
|
|
13
33
|
createRequire(path.join(from, "package.json")).resolve(specifier);
|
|
@@ -59,6 +79,7 @@ const unpluginFactory = (opts) => {
|
|
|
59
79
|
const code = (await readFile(sourceId, "utf8")).toString();
|
|
60
80
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
61
81
|
await repo.checkDoc(doc);
|
|
82
|
+
addTransitiveWatchFiles(this, doc);
|
|
62
83
|
const messages = doc.getDiagMessages().reverse();
|
|
63
84
|
let error = "";
|
|
64
85
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -79,6 +100,10 @@ const unpluginFactory = (opts) => {
|
|
|
79
100
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
80
101
|
};
|
|
81
102
|
}
|
|
103
|
+
},
|
|
104
|
+
watchChange(id) {
|
|
105
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
106
|
+
repo.closeDocument(`file://${id}`);
|
|
82
107
|
}
|
|
83
108
|
};
|
|
84
109
|
};
|
package/dist/farm.cjs
CHANGED
|
@@ -36,6 +36,26 @@ let _atscript_typescript = require("@atscript/typescript");
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
37
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
38
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
|
+
/**
|
|
40
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
41
|
+
*
|
|
42
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
43
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
44
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
45
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
46
|
+
* whenever any of them changes.
|
|
47
|
+
*
|
|
48
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
49
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
50
|
+
* it would prune the edge.
|
|
51
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
52
|
+
for (const dep of doc.dependencies) {
|
|
53
|
+
if (visited.has(dep)) continue;
|
|
54
|
+
visited.add(dep);
|
|
55
|
+
ctx.addWatchFile((0, _atscript_core.fileUriToPath)(dep.id));
|
|
56
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
39
59
|
function isResolvableFrom(specifier, from) {
|
|
40
60
|
try {
|
|
41
61
|
(0, module$1.createRequire)(path.default.join(from, "package.json")).resolve(specifier);
|
|
@@ -87,6 +107,7 @@ const unpluginFactory = (opts) => {
|
|
|
87
107
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
88
108
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
89
109
|
await repo.checkDoc(doc);
|
|
110
|
+
addTransitiveWatchFiles(this, doc);
|
|
90
111
|
const messages = doc.getDiagMessages().reverse();
|
|
91
112
|
let error = "";
|
|
92
113
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -107,6 +128,10 @@ const unpluginFactory = (opts) => {
|
|
|
107
128
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
108
129
|
};
|
|
109
130
|
}
|
|
131
|
+
},
|
|
132
|
+
watchChange(id) {
|
|
133
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
134
|
+
repo.closeDocument(`file://${id}`);
|
|
110
135
|
}
|
|
111
136
|
};
|
|
112
137
|
};
|
package/dist/farm.mjs
CHANGED
|
@@ -2,12 +2,32 @@ import { createFarmPlugin } from "unplugin";
|
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
6
|
import { tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
9
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
10
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
|
+
/**
|
|
12
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
13
|
+
*
|
|
14
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
15
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
16
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
17
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
18
|
+
* whenever any of them changes.
|
|
19
|
+
*
|
|
20
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
21
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
22
|
+
* it would prune the edge.
|
|
23
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
24
|
+
for (const dep of doc.dependencies) {
|
|
25
|
+
if (visited.has(dep)) continue;
|
|
26
|
+
visited.add(dep);
|
|
27
|
+
ctx.addWatchFile(fileUriToPath(dep.id));
|
|
28
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
11
31
|
function isResolvableFrom(specifier, from) {
|
|
12
32
|
try {
|
|
13
33
|
createRequire(path.join(from, "package.json")).resolve(specifier);
|
|
@@ -59,6 +79,7 @@ const unpluginFactory = (opts) => {
|
|
|
59
79
|
const code = (await readFile(sourceId, "utf8")).toString();
|
|
60
80
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
61
81
|
await repo.checkDoc(doc);
|
|
82
|
+
addTransitiveWatchFiles(this, doc);
|
|
62
83
|
const messages = doc.getDiagMessages().reverse();
|
|
63
84
|
let error = "";
|
|
64
85
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -79,6 +100,10 @@ const unpluginFactory = (opts) => {
|
|
|
79
100
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
80
101
|
};
|
|
81
102
|
}
|
|
103
|
+
},
|
|
104
|
+
watchChange(id) {
|
|
105
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
106
|
+
repo.closeDocument(`file://${id}`);
|
|
82
107
|
}
|
|
83
108
|
};
|
|
84
109
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,26 @@ let unplugin = require("unplugin");
|
|
|
37
37
|
//#region packages/unplugin/src/index.ts
|
|
38
38
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
39
39
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
40
|
+
/**
|
|
41
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
42
|
+
*
|
|
43
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
44
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
45
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
46
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
47
|
+
* whenever any of them changes.
|
|
48
|
+
*
|
|
49
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
50
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
51
|
+
* it would prune the edge.
|
|
52
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
53
|
+
for (const dep of doc.dependencies) {
|
|
54
|
+
if (visited.has(dep)) continue;
|
|
55
|
+
visited.add(dep);
|
|
56
|
+
ctx.addWatchFile((0, _atscript_core.fileUriToPath)(dep.id));
|
|
57
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
40
60
|
function isResolvableFrom(specifier, from) {
|
|
41
61
|
try {
|
|
42
62
|
(0, module$1.createRequire)(path.default.join(from, "package.json")).resolve(specifier);
|
|
@@ -88,6 +108,7 @@ const unpluginFactory = (opts) => {
|
|
|
88
108
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
89
109
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
90
110
|
await repo.checkDoc(doc);
|
|
111
|
+
addTransitiveWatchFiles(this, doc);
|
|
91
112
|
const messages = doc.getDiagMessages().reverse();
|
|
92
113
|
let error = "";
|
|
93
114
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -108,6 +129,10 @@ const unpluginFactory = (opts) => {
|
|
|
108
129
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
109
130
|
};
|
|
110
131
|
}
|
|
132
|
+
},
|
|
133
|
+
watchChange(id) {
|
|
134
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
135
|
+
repo.closeDocument(`file://${id}`);
|
|
111
136
|
}
|
|
112
137
|
};
|
|
113
138
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import { readFile } from "fs/promises";
|
|
2
2
|
import { createRequire } from "module";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
4
|
+
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
5
|
import { tsPlugin } from "@atscript/typescript";
|
|
6
6
|
import { createUnplugin } from "unplugin";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
9
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
10
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
|
+
/**
|
|
12
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
13
|
+
*
|
|
14
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
15
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
16
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
17
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
18
|
+
* whenever any of them changes.
|
|
19
|
+
*
|
|
20
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
21
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
22
|
+
* it would prune the edge.
|
|
23
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
24
|
+
for (const dep of doc.dependencies) {
|
|
25
|
+
if (visited.has(dep)) continue;
|
|
26
|
+
visited.add(dep);
|
|
27
|
+
ctx.addWatchFile(fileUriToPath(dep.id));
|
|
28
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
11
31
|
function isResolvableFrom(specifier, from) {
|
|
12
32
|
try {
|
|
13
33
|
createRequire(path.join(from, "package.json")).resolve(specifier);
|
|
@@ -59,6 +79,7 @@ const unpluginFactory = (opts) => {
|
|
|
59
79
|
const code = (await readFile(sourceId, "utf8")).toString();
|
|
60
80
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
61
81
|
await repo.checkDoc(doc);
|
|
82
|
+
addTransitiveWatchFiles(this, doc);
|
|
62
83
|
const messages = doc.getDiagMessages().reverse();
|
|
63
84
|
let error = "";
|
|
64
85
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -79,6 +100,10 @@ const unpluginFactory = (opts) => {
|
|
|
79
100
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
80
101
|
};
|
|
81
102
|
}
|
|
103
|
+
},
|
|
104
|
+
watchChange(id) {
|
|
105
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
106
|
+
repo.closeDocument(`file://${id}`);
|
|
82
107
|
}
|
|
83
108
|
};
|
|
84
109
|
};
|
package/dist/rolldown.cjs
CHANGED
|
@@ -36,6 +36,26 @@ let _atscript_typescript = require("@atscript/typescript");
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
37
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
38
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
|
+
/**
|
|
40
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
41
|
+
*
|
|
42
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
43
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
44
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
45
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
46
|
+
* whenever any of them changes.
|
|
47
|
+
*
|
|
48
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
49
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
50
|
+
* it would prune the edge.
|
|
51
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
52
|
+
for (const dep of doc.dependencies) {
|
|
53
|
+
if (visited.has(dep)) continue;
|
|
54
|
+
visited.add(dep);
|
|
55
|
+
ctx.addWatchFile((0, _atscript_core.fileUriToPath)(dep.id));
|
|
56
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
39
59
|
function isResolvableFrom(specifier, from) {
|
|
40
60
|
try {
|
|
41
61
|
(0, module$1.createRequire)(path.default.join(from, "package.json")).resolve(specifier);
|
|
@@ -87,6 +107,7 @@ const unpluginFactory = (opts) => {
|
|
|
87
107
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
88
108
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
89
109
|
await repo.checkDoc(doc);
|
|
110
|
+
addTransitiveWatchFiles(this, doc);
|
|
90
111
|
const messages = doc.getDiagMessages().reverse();
|
|
91
112
|
let error = "";
|
|
92
113
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -107,6 +128,10 @@ const unpluginFactory = (opts) => {
|
|
|
107
128
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
108
129
|
};
|
|
109
130
|
}
|
|
131
|
+
},
|
|
132
|
+
watchChange(id) {
|
|
133
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
134
|
+
repo.closeDocument(`file://${id}`);
|
|
110
135
|
}
|
|
111
136
|
};
|
|
112
137
|
};
|
package/dist/rolldown.mjs
CHANGED
|
@@ -2,12 +2,32 @@ import { createRolldownPlugin } from "unplugin";
|
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
6
|
import { tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
9
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
10
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
|
+
/**
|
|
12
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
13
|
+
*
|
|
14
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
15
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
16
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
17
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
18
|
+
* whenever any of them changes.
|
|
19
|
+
*
|
|
20
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
21
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
22
|
+
* it would prune the edge.
|
|
23
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
24
|
+
for (const dep of doc.dependencies) {
|
|
25
|
+
if (visited.has(dep)) continue;
|
|
26
|
+
visited.add(dep);
|
|
27
|
+
ctx.addWatchFile(fileUriToPath(dep.id));
|
|
28
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
11
31
|
function isResolvableFrom(specifier, from) {
|
|
12
32
|
try {
|
|
13
33
|
createRequire(path.join(from, "package.json")).resolve(specifier);
|
|
@@ -59,6 +79,7 @@ const unpluginFactory = (opts) => {
|
|
|
59
79
|
const code = (await readFile(sourceId, "utf8")).toString();
|
|
60
80
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
61
81
|
await repo.checkDoc(doc);
|
|
82
|
+
addTransitiveWatchFiles(this, doc);
|
|
62
83
|
const messages = doc.getDiagMessages().reverse();
|
|
63
84
|
let error = "";
|
|
64
85
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -79,6 +100,10 @@ const unpluginFactory = (opts) => {
|
|
|
79
100
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
80
101
|
};
|
|
81
102
|
}
|
|
103
|
+
},
|
|
104
|
+
watchChange(id) {
|
|
105
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
106
|
+
repo.closeDocument(`file://${id}`);
|
|
82
107
|
}
|
|
83
108
|
};
|
|
84
109
|
};
|
package/dist/rollup.cjs
CHANGED
|
@@ -36,6 +36,26 @@ let _atscript_typescript = require("@atscript/typescript");
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
37
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
38
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
|
+
/**
|
|
40
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
41
|
+
*
|
|
42
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
43
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
44
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
45
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
46
|
+
* whenever any of them changes.
|
|
47
|
+
*
|
|
48
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
49
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
50
|
+
* it would prune the edge.
|
|
51
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
52
|
+
for (const dep of doc.dependencies) {
|
|
53
|
+
if (visited.has(dep)) continue;
|
|
54
|
+
visited.add(dep);
|
|
55
|
+
ctx.addWatchFile((0, _atscript_core.fileUriToPath)(dep.id));
|
|
56
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
39
59
|
function isResolvableFrom(specifier, from) {
|
|
40
60
|
try {
|
|
41
61
|
(0, module$1.createRequire)(path.default.join(from, "package.json")).resolve(specifier);
|
|
@@ -87,6 +107,7 @@ const unpluginFactory = (opts) => {
|
|
|
87
107
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
88
108
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
89
109
|
await repo.checkDoc(doc);
|
|
110
|
+
addTransitiveWatchFiles(this, doc);
|
|
90
111
|
const messages = doc.getDiagMessages().reverse();
|
|
91
112
|
let error = "";
|
|
92
113
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -107,6 +128,10 @@ const unpluginFactory = (opts) => {
|
|
|
107
128
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
108
129
|
};
|
|
109
130
|
}
|
|
131
|
+
},
|
|
132
|
+
watchChange(id) {
|
|
133
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
134
|
+
repo.closeDocument(`file://${id}`);
|
|
110
135
|
}
|
|
111
136
|
};
|
|
112
137
|
};
|
package/dist/rollup.mjs
CHANGED
|
@@ -2,12 +2,32 @@ import { createRollupPlugin } from "unplugin";
|
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
6
|
import { tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
9
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
10
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
|
+
/**
|
|
12
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
13
|
+
*
|
|
14
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
15
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
16
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
17
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
18
|
+
* whenever any of them changes.
|
|
19
|
+
*
|
|
20
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
21
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
22
|
+
* it would prune the edge.
|
|
23
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
24
|
+
for (const dep of doc.dependencies) {
|
|
25
|
+
if (visited.has(dep)) continue;
|
|
26
|
+
visited.add(dep);
|
|
27
|
+
ctx.addWatchFile(fileUriToPath(dep.id));
|
|
28
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
11
31
|
function isResolvableFrom(specifier, from) {
|
|
12
32
|
try {
|
|
13
33
|
createRequire(path.join(from, "package.json")).resolve(specifier);
|
|
@@ -59,6 +79,7 @@ const unpluginFactory = (opts) => {
|
|
|
59
79
|
const code = (await readFile(sourceId, "utf8")).toString();
|
|
60
80
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
61
81
|
await repo.checkDoc(doc);
|
|
82
|
+
addTransitiveWatchFiles(this, doc);
|
|
62
83
|
const messages = doc.getDiagMessages().reverse();
|
|
63
84
|
let error = "";
|
|
64
85
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -79,6 +100,10 @@ const unpluginFactory = (opts) => {
|
|
|
79
100
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
80
101
|
};
|
|
81
102
|
}
|
|
103
|
+
},
|
|
104
|
+
watchChange(id) {
|
|
105
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
106
|
+
repo.closeDocument(`file://${id}`);
|
|
82
107
|
}
|
|
83
108
|
};
|
|
84
109
|
};
|
package/dist/rspack.cjs
CHANGED
|
@@ -36,6 +36,26 @@ let _atscript_typescript = require("@atscript/typescript");
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
37
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
38
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
|
+
/**
|
|
40
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
41
|
+
*
|
|
42
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
43
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
44
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
45
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
46
|
+
* whenever any of them changes.
|
|
47
|
+
*
|
|
48
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
49
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
50
|
+
* it would prune the edge.
|
|
51
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
52
|
+
for (const dep of doc.dependencies) {
|
|
53
|
+
if (visited.has(dep)) continue;
|
|
54
|
+
visited.add(dep);
|
|
55
|
+
ctx.addWatchFile((0, _atscript_core.fileUriToPath)(dep.id));
|
|
56
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
39
59
|
function isResolvableFrom(specifier, from) {
|
|
40
60
|
try {
|
|
41
61
|
(0, module$1.createRequire)(path.default.join(from, "package.json")).resolve(specifier);
|
|
@@ -87,6 +107,7 @@ const unpluginFactory = (opts) => {
|
|
|
87
107
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
88
108
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
89
109
|
await repo.checkDoc(doc);
|
|
110
|
+
addTransitiveWatchFiles(this, doc);
|
|
90
111
|
const messages = doc.getDiagMessages().reverse();
|
|
91
112
|
let error = "";
|
|
92
113
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -107,6 +128,10 @@ const unpluginFactory = (opts) => {
|
|
|
107
128
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
108
129
|
};
|
|
109
130
|
}
|
|
131
|
+
},
|
|
132
|
+
watchChange(id) {
|
|
133
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
134
|
+
repo.closeDocument(`file://${id}`);
|
|
110
135
|
}
|
|
111
136
|
};
|
|
112
137
|
};
|
package/dist/rspack.mjs
CHANGED
|
@@ -2,12 +2,32 @@ import { createRspackPlugin } from "unplugin";
|
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
6
|
import { tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
9
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
10
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
|
+
/**
|
|
12
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
13
|
+
*
|
|
14
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
15
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
16
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
17
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
18
|
+
* whenever any of them changes.
|
|
19
|
+
*
|
|
20
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
21
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
22
|
+
* it would prune the edge.
|
|
23
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
24
|
+
for (const dep of doc.dependencies) {
|
|
25
|
+
if (visited.has(dep)) continue;
|
|
26
|
+
visited.add(dep);
|
|
27
|
+
ctx.addWatchFile(fileUriToPath(dep.id));
|
|
28
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
11
31
|
function isResolvableFrom(specifier, from) {
|
|
12
32
|
try {
|
|
13
33
|
createRequire(path.join(from, "package.json")).resolve(specifier);
|
|
@@ -59,6 +79,7 @@ const unpluginFactory = (opts) => {
|
|
|
59
79
|
const code = (await readFile(sourceId, "utf8")).toString();
|
|
60
80
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
61
81
|
await repo.checkDoc(doc);
|
|
82
|
+
addTransitiveWatchFiles(this, doc);
|
|
62
83
|
const messages = doc.getDiagMessages().reverse();
|
|
63
84
|
let error = "";
|
|
64
85
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -79,6 +100,10 @@ const unpluginFactory = (opts) => {
|
|
|
79
100
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
80
101
|
};
|
|
81
102
|
}
|
|
103
|
+
},
|
|
104
|
+
watchChange(id) {
|
|
105
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
106
|
+
repo.closeDocument(`file://${id}`);
|
|
82
107
|
}
|
|
83
108
|
};
|
|
84
109
|
};
|
package/dist/vite.cjs
CHANGED
|
@@ -36,6 +36,26 @@ let _atscript_typescript = require("@atscript/typescript");
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
37
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
38
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
|
+
/**
|
|
40
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
41
|
+
*
|
|
42
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
43
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
44
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
45
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
46
|
+
* whenever any of them changes.
|
|
47
|
+
*
|
|
48
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
49
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
50
|
+
* it would prune the edge.
|
|
51
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
52
|
+
for (const dep of doc.dependencies) {
|
|
53
|
+
if (visited.has(dep)) continue;
|
|
54
|
+
visited.add(dep);
|
|
55
|
+
ctx.addWatchFile((0, _atscript_core.fileUriToPath)(dep.id));
|
|
56
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
39
59
|
function isResolvableFrom(specifier, from) {
|
|
40
60
|
try {
|
|
41
61
|
(0, module$1.createRequire)(path.default.join(from, "package.json")).resolve(specifier);
|
|
@@ -87,6 +107,7 @@ const unpluginFactory = (opts) => {
|
|
|
87
107
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
88
108
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
89
109
|
await repo.checkDoc(doc);
|
|
110
|
+
addTransitiveWatchFiles(this, doc);
|
|
90
111
|
const messages = doc.getDiagMessages().reverse();
|
|
91
112
|
let error = "";
|
|
92
113
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -107,6 +128,10 @@ const unpluginFactory = (opts) => {
|
|
|
107
128
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
108
129
|
};
|
|
109
130
|
}
|
|
131
|
+
},
|
|
132
|
+
watchChange(id) {
|
|
133
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
134
|
+
repo.closeDocument(`file://${id}`);
|
|
110
135
|
}
|
|
111
136
|
};
|
|
112
137
|
};
|
package/dist/vite.mjs
CHANGED
|
@@ -2,12 +2,32 @@ import { createVitePlugin } from "unplugin";
|
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
6
|
import { tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
9
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
10
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
|
+
/**
|
|
12
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
13
|
+
*
|
|
14
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
15
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
16
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
17
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
18
|
+
* whenever any of them changes.
|
|
19
|
+
*
|
|
20
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
21
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
22
|
+
* it would prune the edge.
|
|
23
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
24
|
+
for (const dep of doc.dependencies) {
|
|
25
|
+
if (visited.has(dep)) continue;
|
|
26
|
+
visited.add(dep);
|
|
27
|
+
ctx.addWatchFile(fileUriToPath(dep.id));
|
|
28
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
11
31
|
function isResolvableFrom(specifier, from) {
|
|
12
32
|
try {
|
|
13
33
|
createRequire(path.join(from, "package.json")).resolve(specifier);
|
|
@@ -59,6 +79,7 @@ const unpluginFactory = (opts) => {
|
|
|
59
79
|
const code = (await readFile(sourceId, "utf8")).toString();
|
|
60
80
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
61
81
|
await repo.checkDoc(doc);
|
|
82
|
+
addTransitiveWatchFiles(this, doc);
|
|
62
83
|
const messages = doc.getDiagMessages().reverse();
|
|
63
84
|
let error = "";
|
|
64
85
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -79,6 +100,10 @@ const unpluginFactory = (opts) => {
|
|
|
79
100
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
80
101
|
};
|
|
81
102
|
}
|
|
103
|
+
},
|
|
104
|
+
watchChange(id) {
|
|
105
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
106
|
+
repo.closeDocument(`file://${id}`);
|
|
82
107
|
}
|
|
83
108
|
};
|
|
84
109
|
};
|
package/dist/webpack.cjs
CHANGED
|
@@ -36,6 +36,26 @@ let _atscript_typescript = require("@atscript/typescript");
|
|
|
36
36
|
//#region packages/unplugin/src/index.ts
|
|
37
37
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
38
38
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
39
|
+
/**
|
|
40
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
41
|
+
*
|
|
42
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
43
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
44
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
45
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
46
|
+
* whenever any of them changes.
|
|
47
|
+
*
|
|
48
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
49
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
50
|
+
* it would prune the edge.
|
|
51
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
52
|
+
for (const dep of doc.dependencies) {
|
|
53
|
+
if (visited.has(dep)) continue;
|
|
54
|
+
visited.add(dep);
|
|
55
|
+
ctx.addWatchFile((0, _atscript_core.fileUriToPath)(dep.id));
|
|
56
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
39
59
|
function isResolvableFrom(specifier, from) {
|
|
40
60
|
try {
|
|
41
61
|
(0, module$1.createRequire)(path.default.join(from, "package.json")).resolve(specifier);
|
|
@@ -87,6 +107,7 @@ const unpluginFactory = (opts) => {
|
|
|
87
107
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
88
108
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
89
109
|
await repo.checkDoc(doc);
|
|
110
|
+
addTransitiveWatchFiles(this, doc);
|
|
90
111
|
const messages = doc.getDiagMessages().reverse();
|
|
91
112
|
let error = "";
|
|
92
113
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -107,6 +128,10 @@ const unpluginFactory = (opts) => {
|
|
|
107
128
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
108
129
|
};
|
|
109
130
|
}
|
|
131
|
+
},
|
|
132
|
+
watchChange(id) {
|
|
133
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
134
|
+
repo.closeDocument(`file://${id}`);
|
|
110
135
|
}
|
|
111
136
|
};
|
|
112
137
|
};
|
package/dist/webpack.mjs
CHANGED
|
@@ -2,12 +2,32 @@ import { createWebpackPlugin } from "unplugin";
|
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import { AtscriptRepo, fileUriToPath, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
6
6
|
import { tsPlugin } from "@atscript/typescript";
|
|
7
7
|
|
|
8
8
|
//#region packages/unplugin/src/index.ts
|
|
9
9
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
10
10
|
const RUNTIME_ENTRY = "@atscript/typescript/utils";
|
|
11
|
+
/**
|
|
12
|
+
* Registers every transitive `.as` dependency of `doc` as a watch file.
|
|
13
|
+
*
|
|
14
|
+
* The bundler's module graph only knows the imports the rendered output keeps:
|
|
15
|
+
* the JS renderer drops imports it does not use, and the dts graph and
|
|
16
|
+
* non-Vite watchers never see the JS import list at all. Watching the whole
|
|
17
|
+
* `.as` closure explicitly makes the bundler re-run `load` for the importer
|
|
18
|
+
* whenever any of them changes.
|
|
19
|
+
*
|
|
20
|
+
* Re-registering on every `load` is required: Vite replaces a module's watch
|
|
21
|
+
* edges on each transform, so a repeat registration is deduped while skipping
|
|
22
|
+
* it would prune the edge.
|
|
23
|
+
*/ function addTransitiveWatchFiles(ctx, doc, visited = new Set([doc])) {
|
|
24
|
+
for (const dep of doc.dependencies) {
|
|
25
|
+
if (visited.has(dep)) continue;
|
|
26
|
+
visited.add(dep);
|
|
27
|
+
ctx.addWatchFile(fileUriToPath(dep.id));
|
|
28
|
+
addTransitiveWatchFiles(ctx, dep, visited);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
11
31
|
function isResolvableFrom(specifier, from) {
|
|
12
32
|
try {
|
|
13
33
|
createRequire(path.join(from, "package.json")).resolve(specifier);
|
|
@@ -59,6 +79,7 @@ const unpluginFactory = (opts) => {
|
|
|
59
79
|
const code = (await readFile(sourceId, "utf8")).toString();
|
|
60
80
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
61
81
|
await repo.checkDoc(doc);
|
|
82
|
+
addTransitiveWatchFiles(this, doc);
|
|
62
83
|
const messages = doc.getDiagMessages().reverse();
|
|
63
84
|
let error = "";
|
|
64
85
|
for (const m of messages) if (m.severity === 1) {
|
|
@@ -79,6 +100,10 @@ const unpluginFactory = (opts) => {
|
|
|
79
100
|
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
80
101
|
};
|
|
81
102
|
}
|
|
103
|
+
},
|
|
104
|
+
watchChange(id) {
|
|
105
|
+
if (!repo || !id.endsWith(".as")) return;
|
|
106
|
+
repo.closeDocument(`file://${id}`);
|
|
82
107
|
}
|
|
83
108
|
};
|
|
84
109
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-atscript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.92",
|
|
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.92",
|
|
86
|
+
"@atscript/typescript": "^0.1.92"
|
|
87
87
|
},
|
|
88
88
|
"build": [
|
|
89
89
|
{},
|