@danielx/civet 0.6.36 → 0.6.38
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 -1
- package/dist/browser.js +218 -94
- package/dist/bun-civet.mjs +4 -4
- package/dist/civet +60 -30
- package/dist/esbuild.js +74 -23
- package/dist/main.js +219 -94
- package/dist/main.mjs +218 -94
- package/dist/rollup.js +74 -23
- package/dist/ts-diagnostic.js +149 -0
- package/dist/ts-diagnostic.mjs +111 -0
- package/dist/unplugin-shared.mjs +80 -24
- package/dist/unplugin.d.mts +2 -0
- package/dist/unplugin.d.ts +2 -0
- package/dist/unplugin.js +74 -23
- package/dist/vite.js +74 -23
- package/dist/webpack.js +74 -23
- package/package.json +7 -1
package/dist/unplugin.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(src_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(src_exports);
|
|
36
36
|
var import_unplugin = require("unplugin");
|
|
37
37
|
var import_civet = __toESM(require("@danielx/civet"));
|
|
38
|
+
var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
|
|
38
39
|
var fs = __toESM(require("fs"));
|
|
39
40
|
var import_path = __toESM(require("path"));
|
|
40
41
|
var import_typescript = __toESM(require("typescript"));
|
|
@@ -50,15 +51,19 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
50
51
|
if (options.dts && options.js) {
|
|
51
52
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
if (options.typecheck && options.js) {
|
|
55
|
+
throw new Error("Can't have both `typecheck` and `js` be set to `true`.");
|
|
56
|
+
}
|
|
57
|
+
const transpileToJS = options.js ?? !(options.dts || options.typecheck);
|
|
54
58
|
const outExt = options.outputExtension ?? (transpileToJS ? ".jsx" : ".tsx");
|
|
55
59
|
let fsMap = /* @__PURE__ */ new Map();
|
|
60
|
+
const sourceMaps = /* @__PURE__ */ new Map();
|
|
56
61
|
let compilerOptions;
|
|
57
62
|
return {
|
|
58
63
|
name: "unplugin-civet",
|
|
59
64
|
enforce: "pre",
|
|
60
65
|
async buildStart() {
|
|
61
|
-
if (options.dts) {
|
|
66
|
+
if (options.dts || options.typecheck) {
|
|
62
67
|
const configPath = import_typescript.default.findConfigFile(process.cwd(), import_typescript.default.sys.fileExists);
|
|
63
68
|
if (!configPath) {
|
|
64
69
|
throw new Error("Could not find 'tsconfig.json'");
|
|
@@ -84,7 +89,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
84
89
|
}
|
|
85
90
|
},
|
|
86
91
|
buildEnd() {
|
|
87
|
-
if (options.dts) {
|
|
92
|
+
if (options.dts || options.typecheck) {
|
|
88
93
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), import_typescript.default);
|
|
89
94
|
const host = tsvfs.createVirtualCompilerHost(
|
|
90
95
|
system,
|
|
@@ -96,20 +101,55 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
96
101
|
options: compilerOptions,
|
|
97
102
|
host: host.compilerHost
|
|
98
103
|
});
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
const diagnostics = import_typescript.default.getPreEmitDiagnostics(program).map((diagnostic) => {
|
|
105
|
+
const file = diagnostic.file;
|
|
106
|
+
if (!file)
|
|
107
|
+
return diagnostic;
|
|
108
|
+
const sourceMap = sourceMaps.get(file.fileName);
|
|
109
|
+
if (!sourceMap)
|
|
110
|
+
return diagnostic;
|
|
111
|
+
const sourcemapLines = sourceMap.data.lines;
|
|
112
|
+
const range = (0, import_ts_diagnostic.remapRange)(
|
|
113
|
+
{
|
|
114
|
+
start: diagnostic.start || 0,
|
|
115
|
+
end: (diagnostic.start || 0) + (diagnostic.length || 1)
|
|
109
116
|
},
|
|
110
|
-
|
|
111
|
-
true
|
|
117
|
+
sourcemapLines
|
|
112
118
|
);
|
|
119
|
+
return {
|
|
120
|
+
...diagnostic,
|
|
121
|
+
messageText: (0, import_ts_diagnostic.flattenDiagnosticMessageText)(diagnostic.messageText),
|
|
122
|
+
length: diagnostic.length,
|
|
123
|
+
start: range.start
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
if (diagnostics.length > 0) {
|
|
127
|
+
console.error(
|
|
128
|
+
import_typescript.default.formatDiagnosticsWithColorAndContext(diagnostics, formatHost)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if (options.dts) {
|
|
132
|
+
for (const file of fsMap.keys()) {
|
|
133
|
+
const sourceFile = program.getSourceFile(file);
|
|
134
|
+
program.emit(
|
|
135
|
+
sourceFile,
|
|
136
|
+
async (filePath, content) => {
|
|
137
|
+
const dir = import_path.default.dirname(filePath);
|
|
138
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
139
|
+
const pathFromDistDir = import_path.default.relative(
|
|
140
|
+
compilerOptions.outDir ?? process.cwd(),
|
|
141
|
+
filePath
|
|
142
|
+
);
|
|
143
|
+
this.emitFile({
|
|
144
|
+
source: content,
|
|
145
|
+
fileName: pathFromDistDir,
|
|
146
|
+
type: "asset"
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
void 0,
|
|
150
|
+
true
|
|
151
|
+
);
|
|
152
|
+
}
|
|
113
153
|
}
|
|
114
154
|
}
|
|
115
155
|
},
|
|
@@ -133,13 +173,20 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
133
173
|
return null;
|
|
134
174
|
const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
|
|
135
175
|
const code = await fs.promises.readFile(filename, "utf-8");
|
|
176
|
+
const compiled = import_civet.default.compile(code, {
|
|
177
|
+
// inlineMap: true,
|
|
178
|
+
filename: id,
|
|
179
|
+
js: transpileToJS,
|
|
180
|
+
sourceMap: true
|
|
181
|
+
});
|
|
182
|
+
sourceMaps.set(import_path.default.resolve(process.cwd(), id), compiled.sourceMap);
|
|
183
|
+
const jsonSourceMap = compiled.sourceMap.json(
|
|
184
|
+
import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
|
|
185
|
+
import_path.default.basename(id)
|
|
186
|
+
);
|
|
136
187
|
let transformed = {
|
|
137
|
-
code:
|
|
138
|
-
|
|
139
|
-
filename: id,
|
|
140
|
-
js: transpileToJS
|
|
141
|
-
}),
|
|
142
|
-
map: null
|
|
188
|
+
code: compiled.code,
|
|
189
|
+
map: jsonSourceMap
|
|
143
190
|
};
|
|
144
191
|
if (options.transformOutput)
|
|
145
192
|
transformed = await options.transformOutput(transformed.code, id);
|
|
@@ -148,8 +195,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
148
195
|
transform(code, id) {
|
|
149
196
|
if (!/\.civet\.tsx?$/.test(id))
|
|
150
197
|
return null;
|
|
151
|
-
if (options.dts) {
|
|
152
|
-
|
|
198
|
+
if (options.dts || options.typecheck) {
|
|
199
|
+
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
200
|
+
fsMap.set(resolved, code);
|
|
201
|
+
const slash = resolved.replace(/\\/g, "/");
|
|
202
|
+
if (resolved !== slash)
|
|
203
|
+
fsMap.set(slash, code);
|
|
153
204
|
}
|
|
154
205
|
return null;
|
|
155
206
|
},
|
package/dist/vite.js
CHANGED
|
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(vite_exports);
|
|
|
37
37
|
// src/index.ts
|
|
38
38
|
var import_unplugin = require("unplugin");
|
|
39
39
|
var import_civet = __toESM(require("@danielx/civet"));
|
|
40
|
+
var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
|
|
40
41
|
var fs = __toESM(require("fs"));
|
|
41
42
|
var import_path = __toESM(require("path"));
|
|
42
43
|
var import_typescript = __toESM(require("typescript"));
|
|
@@ -52,15 +53,19 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
52
53
|
if (options.dts && options.js) {
|
|
53
54
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
if (options.typecheck && options.js) {
|
|
57
|
+
throw new Error("Can't have both `typecheck` and `js` be set to `true`.");
|
|
58
|
+
}
|
|
59
|
+
const transpileToJS = options.js ?? !(options.dts || options.typecheck);
|
|
56
60
|
const outExt = options.outputExtension ?? (transpileToJS ? ".jsx" : ".tsx");
|
|
57
61
|
let fsMap = /* @__PURE__ */ new Map();
|
|
62
|
+
const sourceMaps = /* @__PURE__ */ new Map();
|
|
58
63
|
let compilerOptions;
|
|
59
64
|
return {
|
|
60
65
|
name: "unplugin-civet",
|
|
61
66
|
enforce: "pre",
|
|
62
67
|
async buildStart() {
|
|
63
|
-
if (options.dts) {
|
|
68
|
+
if (options.dts || options.typecheck) {
|
|
64
69
|
const configPath = import_typescript.default.findConfigFile(process.cwd(), import_typescript.default.sys.fileExists);
|
|
65
70
|
if (!configPath) {
|
|
66
71
|
throw new Error("Could not find 'tsconfig.json'");
|
|
@@ -86,7 +91,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
86
91
|
}
|
|
87
92
|
},
|
|
88
93
|
buildEnd() {
|
|
89
|
-
if (options.dts) {
|
|
94
|
+
if (options.dts || options.typecheck) {
|
|
90
95
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), import_typescript.default);
|
|
91
96
|
const host = tsvfs.createVirtualCompilerHost(
|
|
92
97
|
system,
|
|
@@ -98,20 +103,55 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
98
103
|
options: compilerOptions,
|
|
99
104
|
host: host.compilerHost
|
|
100
105
|
});
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
const diagnostics = import_typescript.default.getPreEmitDiagnostics(program).map((diagnostic) => {
|
|
107
|
+
const file = diagnostic.file;
|
|
108
|
+
if (!file)
|
|
109
|
+
return diagnostic;
|
|
110
|
+
const sourceMap = sourceMaps.get(file.fileName);
|
|
111
|
+
if (!sourceMap)
|
|
112
|
+
return diagnostic;
|
|
113
|
+
const sourcemapLines = sourceMap.data.lines;
|
|
114
|
+
const range = (0, import_ts_diagnostic.remapRange)(
|
|
115
|
+
{
|
|
116
|
+
start: diagnostic.start || 0,
|
|
117
|
+
end: (diagnostic.start || 0) + (diagnostic.length || 1)
|
|
111
118
|
},
|
|
112
|
-
|
|
113
|
-
true
|
|
119
|
+
sourcemapLines
|
|
114
120
|
);
|
|
121
|
+
return {
|
|
122
|
+
...diagnostic,
|
|
123
|
+
messageText: (0, import_ts_diagnostic.flattenDiagnosticMessageText)(diagnostic.messageText),
|
|
124
|
+
length: diagnostic.length,
|
|
125
|
+
start: range.start
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
if (diagnostics.length > 0) {
|
|
129
|
+
console.error(
|
|
130
|
+
import_typescript.default.formatDiagnosticsWithColorAndContext(diagnostics, formatHost)
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (options.dts) {
|
|
134
|
+
for (const file of fsMap.keys()) {
|
|
135
|
+
const sourceFile = program.getSourceFile(file);
|
|
136
|
+
program.emit(
|
|
137
|
+
sourceFile,
|
|
138
|
+
async (filePath, content) => {
|
|
139
|
+
const dir = import_path.default.dirname(filePath);
|
|
140
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
141
|
+
const pathFromDistDir = import_path.default.relative(
|
|
142
|
+
compilerOptions.outDir ?? process.cwd(),
|
|
143
|
+
filePath
|
|
144
|
+
);
|
|
145
|
+
this.emitFile({
|
|
146
|
+
source: content,
|
|
147
|
+
fileName: pathFromDistDir,
|
|
148
|
+
type: "asset"
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
void 0,
|
|
152
|
+
true
|
|
153
|
+
);
|
|
154
|
+
}
|
|
115
155
|
}
|
|
116
156
|
}
|
|
117
157
|
},
|
|
@@ -135,13 +175,20 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
135
175
|
return null;
|
|
136
176
|
const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
|
|
137
177
|
const code = await fs.promises.readFile(filename, "utf-8");
|
|
178
|
+
const compiled = import_civet.default.compile(code, {
|
|
179
|
+
// inlineMap: true,
|
|
180
|
+
filename: id,
|
|
181
|
+
js: transpileToJS,
|
|
182
|
+
sourceMap: true
|
|
183
|
+
});
|
|
184
|
+
sourceMaps.set(import_path.default.resolve(process.cwd(), id), compiled.sourceMap);
|
|
185
|
+
const jsonSourceMap = compiled.sourceMap.json(
|
|
186
|
+
import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
|
|
187
|
+
import_path.default.basename(id)
|
|
188
|
+
);
|
|
138
189
|
let transformed = {
|
|
139
|
-
code:
|
|
140
|
-
|
|
141
|
-
filename: id,
|
|
142
|
-
js: transpileToJS
|
|
143
|
-
}),
|
|
144
|
-
map: null
|
|
190
|
+
code: compiled.code,
|
|
191
|
+
map: jsonSourceMap
|
|
145
192
|
};
|
|
146
193
|
if (options.transformOutput)
|
|
147
194
|
transformed = await options.transformOutput(transformed.code, id);
|
|
@@ -150,8 +197,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
150
197
|
transform(code, id) {
|
|
151
198
|
if (!/\.civet\.tsx?$/.test(id))
|
|
152
199
|
return null;
|
|
153
|
-
if (options.dts) {
|
|
154
|
-
|
|
200
|
+
if (options.dts || options.typecheck) {
|
|
201
|
+
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
202
|
+
fsMap.set(resolved, code);
|
|
203
|
+
const slash = resolved.replace(/\\/g, "/");
|
|
204
|
+
if (resolved !== slash)
|
|
205
|
+
fsMap.set(slash, code);
|
|
155
206
|
}
|
|
156
207
|
return null;
|
|
157
208
|
},
|
package/dist/webpack.js
CHANGED
|
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(webpack_exports);
|
|
|
37
37
|
// src/index.ts
|
|
38
38
|
var import_unplugin = require("unplugin");
|
|
39
39
|
var import_civet = __toESM(require("@danielx/civet"));
|
|
40
|
+
var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
|
|
40
41
|
var fs = __toESM(require("fs"));
|
|
41
42
|
var import_path = __toESM(require("path"));
|
|
42
43
|
var import_typescript = __toESM(require("typescript"));
|
|
@@ -52,15 +53,19 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
52
53
|
if (options.dts && options.js) {
|
|
53
54
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
if (options.typecheck && options.js) {
|
|
57
|
+
throw new Error("Can't have both `typecheck` and `js` be set to `true`.");
|
|
58
|
+
}
|
|
59
|
+
const transpileToJS = options.js ?? !(options.dts || options.typecheck);
|
|
56
60
|
const outExt = options.outputExtension ?? (transpileToJS ? ".jsx" : ".tsx");
|
|
57
61
|
let fsMap = /* @__PURE__ */ new Map();
|
|
62
|
+
const sourceMaps = /* @__PURE__ */ new Map();
|
|
58
63
|
let compilerOptions;
|
|
59
64
|
return {
|
|
60
65
|
name: "unplugin-civet",
|
|
61
66
|
enforce: "pre",
|
|
62
67
|
async buildStart() {
|
|
63
|
-
if (options.dts) {
|
|
68
|
+
if (options.dts || options.typecheck) {
|
|
64
69
|
const configPath = import_typescript.default.findConfigFile(process.cwd(), import_typescript.default.sys.fileExists);
|
|
65
70
|
if (!configPath) {
|
|
66
71
|
throw new Error("Could not find 'tsconfig.json'");
|
|
@@ -86,7 +91,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
86
91
|
}
|
|
87
92
|
},
|
|
88
93
|
buildEnd() {
|
|
89
|
-
if (options.dts) {
|
|
94
|
+
if (options.dts || options.typecheck) {
|
|
90
95
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), import_typescript.default);
|
|
91
96
|
const host = tsvfs.createVirtualCompilerHost(
|
|
92
97
|
system,
|
|
@@ -98,20 +103,55 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
98
103
|
options: compilerOptions,
|
|
99
104
|
host: host.compilerHost
|
|
100
105
|
});
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
const diagnostics = import_typescript.default.getPreEmitDiagnostics(program).map((diagnostic) => {
|
|
107
|
+
const file = diagnostic.file;
|
|
108
|
+
if (!file)
|
|
109
|
+
return diagnostic;
|
|
110
|
+
const sourceMap = sourceMaps.get(file.fileName);
|
|
111
|
+
if (!sourceMap)
|
|
112
|
+
return diagnostic;
|
|
113
|
+
const sourcemapLines = sourceMap.data.lines;
|
|
114
|
+
const range = (0, import_ts_diagnostic.remapRange)(
|
|
115
|
+
{
|
|
116
|
+
start: diagnostic.start || 0,
|
|
117
|
+
end: (diagnostic.start || 0) + (diagnostic.length || 1)
|
|
111
118
|
},
|
|
112
|
-
|
|
113
|
-
true
|
|
119
|
+
sourcemapLines
|
|
114
120
|
);
|
|
121
|
+
return {
|
|
122
|
+
...diagnostic,
|
|
123
|
+
messageText: (0, import_ts_diagnostic.flattenDiagnosticMessageText)(diagnostic.messageText),
|
|
124
|
+
length: diagnostic.length,
|
|
125
|
+
start: range.start
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
if (diagnostics.length > 0) {
|
|
129
|
+
console.error(
|
|
130
|
+
import_typescript.default.formatDiagnosticsWithColorAndContext(diagnostics, formatHost)
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (options.dts) {
|
|
134
|
+
for (const file of fsMap.keys()) {
|
|
135
|
+
const sourceFile = program.getSourceFile(file);
|
|
136
|
+
program.emit(
|
|
137
|
+
sourceFile,
|
|
138
|
+
async (filePath, content) => {
|
|
139
|
+
const dir = import_path.default.dirname(filePath);
|
|
140
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
141
|
+
const pathFromDistDir = import_path.default.relative(
|
|
142
|
+
compilerOptions.outDir ?? process.cwd(),
|
|
143
|
+
filePath
|
|
144
|
+
);
|
|
145
|
+
this.emitFile({
|
|
146
|
+
source: content,
|
|
147
|
+
fileName: pathFromDistDir,
|
|
148
|
+
type: "asset"
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
void 0,
|
|
152
|
+
true
|
|
153
|
+
);
|
|
154
|
+
}
|
|
115
155
|
}
|
|
116
156
|
}
|
|
117
157
|
},
|
|
@@ -135,13 +175,20 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
135
175
|
return null;
|
|
136
176
|
const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
|
|
137
177
|
const code = await fs.promises.readFile(filename, "utf-8");
|
|
178
|
+
const compiled = import_civet.default.compile(code, {
|
|
179
|
+
// inlineMap: true,
|
|
180
|
+
filename: id,
|
|
181
|
+
js: transpileToJS,
|
|
182
|
+
sourceMap: true
|
|
183
|
+
});
|
|
184
|
+
sourceMaps.set(import_path.default.resolve(process.cwd(), id), compiled.sourceMap);
|
|
185
|
+
const jsonSourceMap = compiled.sourceMap.json(
|
|
186
|
+
import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
|
|
187
|
+
import_path.default.basename(id)
|
|
188
|
+
);
|
|
138
189
|
let transformed = {
|
|
139
|
-
code:
|
|
140
|
-
|
|
141
|
-
filename: id,
|
|
142
|
-
js: transpileToJS
|
|
143
|
-
}),
|
|
144
|
-
map: null
|
|
190
|
+
code: compiled.code,
|
|
191
|
+
map: jsonSourceMap
|
|
145
192
|
};
|
|
146
193
|
if (options.transformOutput)
|
|
147
194
|
transformed = await options.transformOutput(transformed.code, id);
|
|
@@ -150,8 +197,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
150
197
|
transform(code, id) {
|
|
151
198
|
if (!/\.civet\.tsx?$/.test(id))
|
|
152
199
|
return null;
|
|
153
|
-
if (options.dts) {
|
|
154
|
-
|
|
200
|
+
if (options.dts || options.typecheck) {
|
|
201
|
+
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
202
|
+
fsMap.set(resolved, code);
|
|
203
|
+
const slash = resolved.replace(/\\/g, "/");
|
|
204
|
+
if (resolved !== slash)
|
|
205
|
+
fsMap.set(slash, code);
|
|
155
206
|
}
|
|
156
207
|
return null;
|
|
157
208
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielx/civet",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.38",
|
|
5
5
|
"description": "CoffeeScript style syntax for TypeScript",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/main.mjs",
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"require": "./dist/esbuild.js",
|
|
37
37
|
"import": "./dist/esbuild.mjs"
|
|
38
38
|
},
|
|
39
|
+
"./ts-diagnostic": {
|
|
40
|
+
"require": "./dist/ts-diagnostic.js",
|
|
41
|
+
"import": "./dist/ts-diagnostic.mjs"
|
|
42
|
+
},
|
|
39
43
|
"./*": "./*",
|
|
40
44
|
"./dist/*": "./dist/*"
|
|
41
45
|
},
|
|
@@ -84,6 +88,8 @@
|
|
|
84
88
|
"typescript": "^5.2.2",
|
|
85
89
|
"vite": "^4.4.9",
|
|
86
90
|
"vitepress": "^1.0.0-alpha.35",
|
|
91
|
+
"vscode-languageserver": "^8.1.0",
|
|
92
|
+
"vscode-languageserver-textdocument": "^1.0.8",
|
|
87
93
|
"vue": "^3.2.45"
|
|
88
94
|
},
|
|
89
95
|
"peerDependencies": {
|