silgi 0.7.19 → 0.7.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const version = "0.7.19";
1
+ const version = "0.7.21";
2
2
  const packageJson = {
3
3
  version: version};
4
4
 
@@ -1457,7 +1457,10 @@ const logger = useLogger("silgi");
1457
1457
  async function generateApp(app, options = {}) {
1458
1458
  app.templates = Object.values(defaultTemplates).concat(app.options.build.templates);
1459
1459
  await app.callHook("app:templates", app);
1460
- app.templates = app.templates.map((tmpl) => normalizeTemplate(tmpl, app.options.silgi.vfsDir));
1460
+ app.templates = app.templates.map((tmpl) => {
1461
+ const dir = tmpl.where === ".silgi" ? app.options.build.dir : tmpl.where === "server" ? app.options.silgi.serverDir : tmpl.where === "client" ? app.options.silgi.clientDir : app.options.silgi.vfsDir;
1462
+ return normalizeTemplate(tmpl, dir);
1463
+ });
1461
1464
  const filteredTemplates = {
1462
1465
  pre: [],
1463
1466
  post: []
@@ -1471,11 +1474,11 @@ async function generateApp(app, options = {}) {
1471
1474
  }
1472
1475
  const templateContext = { app };
1473
1476
  const writes = [];
1474
- const indexImports = [];
1475
1477
  const dirs = /* @__PURE__ */ new Set();
1476
1478
  const changedTemplates = [];
1477
1479
  async function processTemplate(template) {
1478
- const fullPath = template.dst || resolve(app.options.silgi.vfsDir, template.filename);
1480
+ const dir = template.where === ".silgi" ? app.options.build.dir : template.where === "server" ? app.options.silgi.serverDir : template.where === "client" ? app.options.silgi.clientDir : app.options.silgi.vfsDir;
1481
+ const fullPath = template.dst || resolve(dir, template.filename);
1479
1482
  const start = performance.now();
1480
1483
  const contents = await compileTemplate(template, templateContext).catch((e) => {
1481
1484
  logger.error(`Could not compile template \`${template.filename}\`.`);
@@ -1493,9 +1496,6 @@ async function generateApp(app, options = {}) {
1493
1496
  }
1494
1497
  if (template.modified && template.write) {
1495
1498
  dirs.add(dirname(fullPath));
1496
- if (!fullPath.endsWith(".d.ts")) {
1497
- indexImports.push(relativeWithDot(app.options.silgi.serverDir, fullPath));
1498
- }
1499
1499
  writes.push(() => writeFileSync(fullPath, contents, "utf8"));
1500
1500
  }
1501
1501
  }
@@ -291,7 +291,9 @@ function normalizeTemplate(template, buildDir) {
291
291
  template.write = true;
292
292
  }
293
293
  if (!template.dst) {
294
- template.dst = resolve(buildDir ?? useSilgiCLI().options.silgi.serverDir, template.filename);
294
+ const silgi = useSilgiCLI();
295
+ const dir = template.where === ".silgi" ? silgi.options.build.dir : template.where === "server" ? silgi.options.silgi.serverDir : template.where === "client" ? silgi.options.silgi.clientDir : silgi.options.silgi.serverDir;
296
+ template.dst = resolve(buildDir ?? dir, template.filename);
295
297
  }
296
298
  return template;
297
299
  }
@@ -1,3 +1,3 @@
1
- const version = "0.7.19";
1
+ const version = "0.7.21";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "0.7.19";
1
+ const version = "0.7.21";
2
2
 
3
3
  export { version };
@@ -199,6 +199,7 @@ interface SilgiTemplate<Options = TemplateDefaultOptions> {
199
199
  /** The resolved path to the source file to be template */
200
200
  src?: string;
201
201
  /** Provided compile option instead of src */
202
+ where?: 'server' | 'client' | '.silgi';
202
203
  getContents?: (data: {
203
204
  app: SilgiCLI;
204
205
  options: Options;
@@ -199,6 +199,7 @@ interface SilgiTemplate<Options = TemplateDefaultOptions> {
199
199
  /** The resolved path to the source file to be template */
200
200
  src?: string;
201
201
  /** Provided compile option instead of src */
202
+ where?: 'server' | 'client' | '.silgi';
202
203
  getContents?: (data: {
203
204
  app: SilgiCLI;
204
205
  options: Options;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.7.19",
4
+ "version": "0.7.21",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {