@danielx/civet 0.7.13 → 0.7.15

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/rollup.js CHANGED
@@ -100,6 +100,8 @@ var rawPlugin = (options = {}, meta) => {
100
100
  let compilerOptions, compilerOptionsWithSourceMap;
101
101
  let rootDir = process.cwd();
102
102
  let esbuildOptions;
103
+ let configErrors;
104
+ let configFileNames;
103
105
  const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
104
106
  const getFormatHost = (sys) => {
105
107
  return {
@@ -114,6 +116,16 @@ var rawPlugin = (options = {}, meta) => {
114
116
  enforce: "pre",
115
117
  async buildStart() {
116
118
  if (transformTS || options.ts === "tsc") {
119
+ let mogrify2 = function(key) {
120
+ if (key in config && Array.isArray(config[key])) {
121
+ config[key] = config[key].map((item) => {
122
+ if (typeof item !== "string")
123
+ return item;
124
+ return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
125
+ });
126
+ }
127
+ };
128
+ var mogrify = mogrify2;
117
129
  const ts = await tsPromise;
118
130
  const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
119
131
  if (civetConfigPath) {
@@ -135,17 +147,26 @@ var rawPlugin = (options = {}, meta) => {
135
147
  console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
136
148
  throw error;
137
149
  }
150
+ mogrify2("files");
151
+ const system = { ...ts.sys };
152
+ const { readDirectory: systemReadDirectory } = system;
153
+ system.readDirectory = (path2, extensions, excludes, includes, depth) => {
154
+ extensions = [...extensions ?? [], ".civet"];
155
+ return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
156
+ };
138
157
  const configContents = ts.parseJsonConfigFileContent(
139
158
  config,
140
- ts.sys,
159
+ system,
141
160
  process.cwd()
142
161
  );
162
+ configErrors = configContents.errors;
163
+ configFileNames = configContents.fileNames;
143
164
  compilerOptions = {
144
165
  ...configContents.options,
145
166
  target: ts.ScriptTarget.ESNext,
146
167
  composite: false
147
168
  };
148
- compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
169
+ compilerOptions.jsx ?? (compilerOptions.jsx = ts.JsxEmit.Preserve);
149
170
  compilerOptionsWithSourceMap = {
150
171
  ...compilerOptions,
151
172
  sourceMap: true
@@ -153,11 +174,15 @@ var rawPlugin = (options = {}, meta) => {
153
174
  fsMap = /* @__PURE__ */ new Map();
154
175
  }
155
176
  },
156
- async buildEnd() {
177
+ async buildEnd(useConfigFileNames = false) {
157
178
  if (transformTS) {
158
179
  const ts = await tsPromise;
159
180
  const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
160
- const { fileExists: systemFileExists, readFile: systemReadFile } = system;
181
+ const {
182
+ fileExists: systemFileExists,
183
+ readFile: systemReadFile,
184
+ readDirectory: systemReadDirectory
185
+ } = system;
161
186
  system.fileExists = (filename) => {
162
187
  if (!filename.endsWith(".civet.tsx"))
163
188
  return systemFileExists(filename);
@@ -165,9 +190,35 @@ var rawPlugin = (options = {}, meta) => {
165
190
  return true;
166
191
  return systemFileExists(filename.slice(0, -4));
167
192
  };
193
+ system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
168
194
  system.readFile = (filename, encoding = "utf-8") => {
195
+ if (import_path.default.basename(filename) === "package.json") {
196
+ let recurse2 = function(node) {
197
+ if (node && typeof node === "object") {
198
+ for (const key in node) {
199
+ const value = node[key];
200
+ if (typeof value === "string") {
201
+ if (value.endsWith(".civet")) {
202
+ node[key] = value + ".tsx";
203
+ modified = true;
204
+ }
205
+ } else if (value) {
206
+ recurse2(value);
207
+ }
208
+ }
209
+ }
210
+ };
211
+ var recurse = recurse2;
212
+ const json = systemReadFile(filename, encoding);
213
+ if (!json)
214
+ return json;
215
+ const parsed = JSON.parse(json);
216
+ let modified = false;
217
+ recurse2(parsed.imports);
218
+ return modified ? JSON.stringify(parsed) : json;
219
+ }
169
220
  if (!filename.endsWith(".civet.tsx"))
170
- return systemReadFile(filename);
221
+ return systemReadFile(filename, encoding);
171
222
  if (fsMap.has(filename))
172
223
  return fsMap.get(filename);
173
224
  const civetFilename = filename.slice(0, -4);
@@ -189,8 +240,9 @@ var rawPlugin = (options = {}, meta) => {
189
240
  compilerOptions,
190
241
  ts
191
242
  );
243
+ host.compilerHost.getDirectories = system.getDirectories;
192
244
  const program = ts.createProgram({
193
- rootNames: [...fsMap.keys()],
245
+ rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
194
246
  options: compilerOptions,
195
247
  host: host.compilerHost
196
248
  });
@@ -216,6 +268,9 @@ var rawPlugin = (options = {}, meta) => {
216
268
  start: range.start
217
269
  };
218
270
  });
271
+ if (configErrors?.length) {
272
+ diagnostics.unshift(...configErrors);
273
+ }
219
274
  if (diagnostics.length > 0) {
220
275
  console.error(
221
276
  ts.formatDiagnosticsWithColorAndContext(
@@ -67,6 +67,8 @@ var rawPlugin = (options = {}, meta) => {
67
67
  let compilerOptions, compilerOptionsWithSourceMap;
68
68
  let rootDir = process.cwd();
69
69
  let esbuildOptions;
70
+ let configErrors;
71
+ let configFileNames;
70
72
  const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
71
73
  const getFormatHost = (sys) => {
72
74
  return {
@@ -81,6 +83,16 @@ var rawPlugin = (options = {}, meta) => {
81
83
  enforce: "pre",
82
84
  async buildStart() {
83
85
  if (transformTS || options.ts === "tsc") {
86
+ let mogrify2 = function(key) {
87
+ if (key in config && Array.isArray(config[key])) {
88
+ config[key] = config[key].map((item) => {
89
+ if (typeof item !== "string")
90
+ return item;
91
+ return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
92
+ });
93
+ }
94
+ };
95
+ var mogrify = mogrify2;
84
96
  const ts = await tsPromise;
85
97
  const civetConfigPath = "config" in options ? options.config : await findInDir(process.cwd());
86
98
  if (civetConfigPath) {
@@ -102,17 +114,26 @@ var rawPlugin = (options = {}, meta) => {
102
114
  console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
103
115
  throw error;
104
116
  }
117
+ mogrify2("files");
118
+ const system = { ...ts.sys };
119
+ const { readDirectory: systemReadDirectory } = system;
120
+ system.readDirectory = (path2, extensions, excludes, includes, depth) => {
121
+ extensions = [...extensions ?? [], ".civet"];
122
+ return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
123
+ };
105
124
  const configContents = ts.parseJsonConfigFileContent(
106
125
  config,
107
- ts.sys,
126
+ system,
108
127
  process.cwd()
109
128
  );
129
+ configErrors = configContents.errors;
130
+ configFileNames = configContents.fileNames;
110
131
  compilerOptions = {
111
132
  ...configContents.options,
112
133
  target: ts.ScriptTarget.ESNext,
113
134
  composite: false
114
135
  };
115
- compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
136
+ compilerOptions.jsx ?? (compilerOptions.jsx = ts.JsxEmit.Preserve);
116
137
  compilerOptionsWithSourceMap = {
117
138
  ...compilerOptions,
118
139
  sourceMap: true
@@ -120,11 +141,15 @@ var rawPlugin = (options = {}, meta) => {
120
141
  fsMap = /* @__PURE__ */ new Map();
121
142
  }
122
143
  },
123
- async buildEnd() {
144
+ async buildEnd(useConfigFileNames = false) {
124
145
  if (transformTS) {
125
146
  const ts = await tsPromise;
126
147
  const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
127
- const { fileExists: systemFileExists, readFile: systemReadFile } = system;
148
+ const {
149
+ fileExists: systemFileExists,
150
+ readFile: systemReadFile,
151
+ readDirectory: systemReadDirectory
152
+ } = system;
128
153
  system.fileExists = (filename) => {
129
154
  if (!filename.endsWith(".civet.tsx"))
130
155
  return systemFileExists(filename);
@@ -132,9 +157,35 @@ var rawPlugin = (options = {}, meta) => {
132
157
  return true;
133
158
  return systemFileExists(filename.slice(0, -4));
134
159
  };
160
+ system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
135
161
  system.readFile = (filename, encoding = "utf-8") => {
162
+ if (path.basename(filename) === "package.json") {
163
+ let recurse2 = function(node) {
164
+ if (node && typeof node === "object") {
165
+ for (const key in node) {
166
+ const value = node[key];
167
+ if (typeof value === "string") {
168
+ if (value.endsWith(".civet")) {
169
+ node[key] = value + ".tsx";
170
+ modified = true;
171
+ }
172
+ } else if (value) {
173
+ recurse2(value);
174
+ }
175
+ }
176
+ }
177
+ };
178
+ var recurse = recurse2;
179
+ const json = systemReadFile(filename, encoding);
180
+ if (!json)
181
+ return json;
182
+ const parsed = JSON.parse(json);
183
+ let modified = false;
184
+ recurse2(parsed.imports);
185
+ return modified ? JSON.stringify(parsed) : json;
186
+ }
136
187
  if (!filename.endsWith(".civet.tsx"))
137
- return systemReadFile(filename);
188
+ return systemReadFile(filename, encoding);
138
189
  if (fsMap.has(filename))
139
190
  return fsMap.get(filename);
140
191
  const civetFilename = filename.slice(0, -4);
@@ -156,8 +207,9 @@ var rawPlugin = (options = {}, meta) => {
156
207
  compilerOptions,
157
208
  ts
158
209
  );
210
+ host.compilerHost.getDirectories = system.getDirectories;
159
211
  const program = ts.createProgram({
160
- rootNames: [...fsMap.keys()],
212
+ rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
161
213
  options: compilerOptions,
162
214
  host: host.compilerHost
163
215
  });
@@ -183,6 +235,9 @@ var rawPlugin = (options = {}, meta) => {
183
235
  start: range.start
184
236
  };
185
237
  });
238
+ if (configErrors?.length) {
239
+ diagnostics.unshift(...configErrors);
240
+ }
186
241
  if (diagnostics.length > 0) {
187
242
  console.error(
188
243
  ts.formatDiagnosticsWithColorAndContext(
package/dist/unplugin.js CHANGED
@@ -100,6 +100,8 @@ var rawPlugin = (options = {}, meta) => {
100
100
  let compilerOptions, compilerOptionsWithSourceMap;
101
101
  let rootDir = process.cwd();
102
102
  let esbuildOptions;
103
+ let configErrors;
104
+ let configFileNames;
103
105
  const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
104
106
  const getFormatHost = (sys) => {
105
107
  return {
@@ -114,6 +116,16 @@ var rawPlugin = (options = {}, meta) => {
114
116
  enforce: "pre",
115
117
  async buildStart() {
116
118
  if (transformTS || options.ts === "tsc") {
119
+ let mogrify2 = function(key) {
120
+ if (key in config && Array.isArray(config[key])) {
121
+ config[key] = config[key].map((item) => {
122
+ if (typeof item !== "string")
123
+ return item;
124
+ return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
125
+ });
126
+ }
127
+ };
128
+ var mogrify = mogrify2;
117
129
  const ts = await tsPromise;
118
130
  const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
119
131
  if (civetConfigPath) {
@@ -135,17 +147,26 @@ var rawPlugin = (options = {}, meta) => {
135
147
  console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
136
148
  throw error;
137
149
  }
150
+ mogrify2("files");
151
+ const system = { ...ts.sys };
152
+ const { readDirectory: systemReadDirectory } = system;
153
+ system.readDirectory = (path2, extensions, excludes, includes, depth) => {
154
+ extensions = [...extensions ?? [], ".civet"];
155
+ return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
156
+ };
138
157
  const configContents = ts.parseJsonConfigFileContent(
139
158
  config,
140
- ts.sys,
159
+ system,
141
160
  process.cwd()
142
161
  );
162
+ configErrors = configContents.errors;
163
+ configFileNames = configContents.fileNames;
143
164
  compilerOptions = {
144
165
  ...configContents.options,
145
166
  target: ts.ScriptTarget.ESNext,
146
167
  composite: false
147
168
  };
148
- compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
169
+ compilerOptions.jsx ?? (compilerOptions.jsx = ts.JsxEmit.Preserve);
149
170
  compilerOptionsWithSourceMap = {
150
171
  ...compilerOptions,
151
172
  sourceMap: true
@@ -153,11 +174,15 @@ var rawPlugin = (options = {}, meta) => {
153
174
  fsMap = /* @__PURE__ */ new Map();
154
175
  }
155
176
  },
156
- async buildEnd() {
177
+ async buildEnd(useConfigFileNames = false) {
157
178
  if (transformTS) {
158
179
  const ts = await tsPromise;
159
180
  const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
160
- const { fileExists: systemFileExists, readFile: systemReadFile } = system;
181
+ const {
182
+ fileExists: systemFileExists,
183
+ readFile: systemReadFile,
184
+ readDirectory: systemReadDirectory
185
+ } = system;
161
186
  system.fileExists = (filename) => {
162
187
  if (!filename.endsWith(".civet.tsx"))
163
188
  return systemFileExists(filename);
@@ -165,9 +190,35 @@ var rawPlugin = (options = {}, meta) => {
165
190
  return true;
166
191
  return systemFileExists(filename.slice(0, -4));
167
192
  };
193
+ system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
168
194
  system.readFile = (filename, encoding = "utf-8") => {
195
+ if (import_path.default.basename(filename) === "package.json") {
196
+ let recurse2 = function(node) {
197
+ if (node && typeof node === "object") {
198
+ for (const key in node) {
199
+ const value = node[key];
200
+ if (typeof value === "string") {
201
+ if (value.endsWith(".civet")) {
202
+ node[key] = value + ".tsx";
203
+ modified = true;
204
+ }
205
+ } else if (value) {
206
+ recurse2(value);
207
+ }
208
+ }
209
+ }
210
+ };
211
+ var recurse = recurse2;
212
+ const json = systemReadFile(filename, encoding);
213
+ if (!json)
214
+ return json;
215
+ const parsed = JSON.parse(json);
216
+ let modified = false;
217
+ recurse2(parsed.imports);
218
+ return modified ? JSON.stringify(parsed) : json;
219
+ }
169
220
  if (!filename.endsWith(".civet.tsx"))
170
- return systemReadFile(filename);
221
+ return systemReadFile(filename, encoding);
171
222
  if (fsMap.has(filename))
172
223
  return fsMap.get(filename);
173
224
  const civetFilename = filename.slice(0, -4);
@@ -189,8 +240,9 @@ var rawPlugin = (options = {}, meta) => {
189
240
  compilerOptions,
190
241
  ts
191
242
  );
243
+ host.compilerHost.getDirectories = system.getDirectories;
192
244
  const program = ts.createProgram({
193
- rootNames: [...fsMap.keys()],
245
+ rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
194
246
  options: compilerOptions,
195
247
  host: host.compilerHost
196
248
  });
@@ -216,6 +268,9 @@ var rawPlugin = (options = {}, meta) => {
216
268
  start: range.start
217
269
  };
218
270
  });
271
+ if (configErrors?.length) {
272
+ diagnostics.unshift(...configErrors);
273
+ }
219
274
  if (diagnostics.length > 0) {
220
275
  console.error(
221
276
  ts.formatDiagnosticsWithColorAndContext(
package/dist/vite.js CHANGED
@@ -100,6 +100,8 @@ var rawPlugin = (options = {}, meta) => {
100
100
  let compilerOptions, compilerOptionsWithSourceMap;
101
101
  let rootDir = process.cwd();
102
102
  let esbuildOptions;
103
+ let configErrors;
104
+ let configFileNames;
103
105
  const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
104
106
  const getFormatHost = (sys) => {
105
107
  return {
@@ -114,6 +116,16 @@ var rawPlugin = (options = {}, meta) => {
114
116
  enforce: "pre",
115
117
  async buildStart() {
116
118
  if (transformTS || options.ts === "tsc") {
119
+ let mogrify2 = function(key) {
120
+ if (key in config && Array.isArray(config[key])) {
121
+ config[key] = config[key].map((item) => {
122
+ if (typeof item !== "string")
123
+ return item;
124
+ return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
125
+ });
126
+ }
127
+ };
128
+ var mogrify = mogrify2;
117
129
  const ts = await tsPromise;
118
130
  const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
119
131
  if (civetConfigPath) {
@@ -135,17 +147,26 @@ var rawPlugin = (options = {}, meta) => {
135
147
  console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
136
148
  throw error;
137
149
  }
150
+ mogrify2("files");
151
+ const system = { ...ts.sys };
152
+ const { readDirectory: systemReadDirectory } = system;
153
+ system.readDirectory = (path2, extensions, excludes, includes, depth) => {
154
+ extensions = [...extensions ?? [], ".civet"];
155
+ return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
156
+ };
138
157
  const configContents = ts.parseJsonConfigFileContent(
139
158
  config,
140
- ts.sys,
159
+ system,
141
160
  process.cwd()
142
161
  );
162
+ configErrors = configContents.errors;
163
+ configFileNames = configContents.fileNames;
143
164
  compilerOptions = {
144
165
  ...configContents.options,
145
166
  target: ts.ScriptTarget.ESNext,
146
167
  composite: false
147
168
  };
148
- compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
169
+ compilerOptions.jsx ?? (compilerOptions.jsx = ts.JsxEmit.Preserve);
149
170
  compilerOptionsWithSourceMap = {
150
171
  ...compilerOptions,
151
172
  sourceMap: true
@@ -153,11 +174,15 @@ var rawPlugin = (options = {}, meta) => {
153
174
  fsMap = /* @__PURE__ */ new Map();
154
175
  }
155
176
  },
156
- async buildEnd() {
177
+ async buildEnd(useConfigFileNames = false) {
157
178
  if (transformTS) {
158
179
  const ts = await tsPromise;
159
180
  const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
160
- const { fileExists: systemFileExists, readFile: systemReadFile } = system;
181
+ const {
182
+ fileExists: systemFileExists,
183
+ readFile: systemReadFile,
184
+ readDirectory: systemReadDirectory
185
+ } = system;
161
186
  system.fileExists = (filename) => {
162
187
  if (!filename.endsWith(".civet.tsx"))
163
188
  return systemFileExists(filename);
@@ -165,9 +190,35 @@ var rawPlugin = (options = {}, meta) => {
165
190
  return true;
166
191
  return systemFileExists(filename.slice(0, -4));
167
192
  };
193
+ system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
168
194
  system.readFile = (filename, encoding = "utf-8") => {
195
+ if (import_path.default.basename(filename) === "package.json") {
196
+ let recurse2 = function(node) {
197
+ if (node && typeof node === "object") {
198
+ for (const key in node) {
199
+ const value = node[key];
200
+ if (typeof value === "string") {
201
+ if (value.endsWith(".civet")) {
202
+ node[key] = value + ".tsx";
203
+ modified = true;
204
+ }
205
+ } else if (value) {
206
+ recurse2(value);
207
+ }
208
+ }
209
+ }
210
+ };
211
+ var recurse = recurse2;
212
+ const json = systemReadFile(filename, encoding);
213
+ if (!json)
214
+ return json;
215
+ const parsed = JSON.parse(json);
216
+ let modified = false;
217
+ recurse2(parsed.imports);
218
+ return modified ? JSON.stringify(parsed) : json;
219
+ }
169
220
  if (!filename.endsWith(".civet.tsx"))
170
- return systemReadFile(filename);
221
+ return systemReadFile(filename, encoding);
171
222
  if (fsMap.has(filename))
172
223
  return fsMap.get(filename);
173
224
  const civetFilename = filename.slice(0, -4);
@@ -189,8 +240,9 @@ var rawPlugin = (options = {}, meta) => {
189
240
  compilerOptions,
190
241
  ts
191
242
  );
243
+ host.compilerHost.getDirectories = system.getDirectories;
192
244
  const program = ts.createProgram({
193
- rootNames: [...fsMap.keys()],
245
+ rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
194
246
  options: compilerOptions,
195
247
  host: host.compilerHost
196
248
  });
@@ -216,6 +268,9 @@ var rawPlugin = (options = {}, meta) => {
216
268
  start: range.start
217
269
  };
218
270
  });
271
+ if (configErrors?.length) {
272
+ diagnostics.unshift(...configErrors);
273
+ }
219
274
  if (diagnostics.length > 0) {
220
275
  console.error(
221
276
  ts.formatDiagnosticsWithColorAndContext(
package/dist/webpack.js CHANGED
@@ -100,6 +100,8 @@ var rawPlugin = (options = {}, meta) => {
100
100
  let compilerOptions, compilerOptionsWithSourceMap;
101
101
  let rootDir = process.cwd();
102
102
  let esbuildOptions;
103
+ let configErrors;
104
+ let configFileNames;
103
105
  const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
104
106
  const getFormatHost = (sys) => {
105
107
  return {
@@ -114,6 +116,16 @@ var rawPlugin = (options = {}, meta) => {
114
116
  enforce: "pre",
115
117
  async buildStart() {
116
118
  if (transformTS || options.ts === "tsc") {
119
+ let mogrify2 = function(key) {
120
+ if (key in config && Array.isArray(config[key])) {
121
+ config[key] = config[key].map((item) => {
122
+ if (typeof item !== "string")
123
+ return item;
124
+ return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
125
+ });
126
+ }
127
+ };
128
+ var mogrify = mogrify2;
117
129
  const ts = await tsPromise;
118
130
  const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
119
131
  if (civetConfigPath) {
@@ -135,17 +147,26 @@ var rawPlugin = (options = {}, meta) => {
135
147
  console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
136
148
  throw error;
137
149
  }
150
+ mogrify2("files");
151
+ const system = { ...ts.sys };
152
+ const { readDirectory: systemReadDirectory } = system;
153
+ system.readDirectory = (path2, extensions, excludes, includes, depth) => {
154
+ extensions = [...extensions ?? [], ".civet"];
155
+ return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
156
+ };
138
157
  const configContents = ts.parseJsonConfigFileContent(
139
158
  config,
140
- ts.sys,
159
+ system,
141
160
  process.cwd()
142
161
  );
162
+ configErrors = configContents.errors;
163
+ configFileNames = configContents.fileNames;
143
164
  compilerOptions = {
144
165
  ...configContents.options,
145
166
  target: ts.ScriptTarget.ESNext,
146
167
  composite: false
147
168
  };
148
- compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
169
+ compilerOptions.jsx ?? (compilerOptions.jsx = ts.JsxEmit.Preserve);
149
170
  compilerOptionsWithSourceMap = {
150
171
  ...compilerOptions,
151
172
  sourceMap: true
@@ -153,11 +174,15 @@ var rawPlugin = (options = {}, meta) => {
153
174
  fsMap = /* @__PURE__ */ new Map();
154
175
  }
155
176
  },
156
- async buildEnd() {
177
+ async buildEnd(useConfigFileNames = false) {
157
178
  if (transformTS) {
158
179
  const ts = await tsPromise;
159
180
  const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
160
- const { fileExists: systemFileExists, readFile: systemReadFile } = system;
181
+ const {
182
+ fileExists: systemFileExists,
183
+ readFile: systemReadFile,
184
+ readDirectory: systemReadDirectory
185
+ } = system;
161
186
  system.fileExists = (filename) => {
162
187
  if (!filename.endsWith(".civet.tsx"))
163
188
  return systemFileExists(filename);
@@ -165,9 +190,35 @@ var rawPlugin = (options = {}, meta) => {
165
190
  return true;
166
191
  return systemFileExists(filename.slice(0, -4));
167
192
  };
193
+ system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
168
194
  system.readFile = (filename, encoding = "utf-8") => {
195
+ if (import_path.default.basename(filename) === "package.json") {
196
+ let recurse2 = function(node) {
197
+ if (node && typeof node === "object") {
198
+ for (const key in node) {
199
+ const value = node[key];
200
+ if (typeof value === "string") {
201
+ if (value.endsWith(".civet")) {
202
+ node[key] = value + ".tsx";
203
+ modified = true;
204
+ }
205
+ } else if (value) {
206
+ recurse2(value);
207
+ }
208
+ }
209
+ }
210
+ };
211
+ var recurse = recurse2;
212
+ const json = systemReadFile(filename, encoding);
213
+ if (!json)
214
+ return json;
215
+ const parsed = JSON.parse(json);
216
+ let modified = false;
217
+ recurse2(parsed.imports);
218
+ return modified ? JSON.stringify(parsed) : json;
219
+ }
169
220
  if (!filename.endsWith(".civet.tsx"))
170
- return systemReadFile(filename);
221
+ return systemReadFile(filename, encoding);
171
222
  if (fsMap.has(filename))
172
223
  return fsMap.get(filename);
173
224
  const civetFilename = filename.slice(0, -4);
@@ -189,8 +240,9 @@ var rawPlugin = (options = {}, meta) => {
189
240
  compilerOptions,
190
241
  ts
191
242
  );
243
+ host.compilerHost.getDirectories = system.getDirectories;
192
244
  const program = ts.createProgram({
193
- rootNames: [...fsMap.keys()],
245
+ rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
194
246
  options: compilerOptions,
195
247
  host: host.compilerHost
196
248
  });
@@ -216,6 +268,9 @@ var rawPlugin = (options = {}, meta) => {
216
268
  start: range.start
217
269
  };
218
270
  });
271
+ if (configErrors?.length) {
272
+ diagnostics.unshift(...configErrors);
273
+ }
219
274
  if (diagnostics.length > 0) {
220
275
  console.error(
221
276
  ts.formatDiagnosticsWithColorAndContext(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.7.13",
4
+ "version": "0.7.15",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",
@@ -98,7 +98,13 @@
98
98
  "vue": "^3.2.45"
99
99
  },
100
100
  "peerDependencies": {
101
- "typescript": "^4.5 || ^5.0"
101
+ "typescript": "^4.5 || ^5.0",
102
+ "yaml": "^2.4.5"
103
+ },
104
+ "peerDependenciesMeta": {
105
+ "yaml": {
106
+ "optional": true
107
+ }
102
108
  },
103
109
  "c8": {
104
110
  "all": true,
@@ -122,5 +128,6 @@
122
128
  "source/parser/types.civet",
123
129
  "source/bun-civet.civet"
124
130
  ]
125
- }
131
+ },
132
+ "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
126
133
  }