coralite 0.27.0 → 0.28.1

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 CHANGED
@@ -32,20 +32,12 @@ Before using the Coralite CLI, ensure that it's installed on your system. You ca
32
32
 
33
33
  ```bash
34
34
  npm install -g coralite
35
- # or
36
- yarn global add coralite
37
- # or
38
- pnpm add -g coralite
39
35
  ```
40
36
 
41
37
  You can also install coralite as a development dependency:
42
38
 
43
39
  ```bash
44
40
  npm install --save-dev coralite
45
- # or
46
- yarn add -D coralite
47
- # or
48
- pnpm add -D coralite
49
41
  ```
50
42
 
51
43
  ## Basic Syntax
@@ -64,14 +56,14 @@ Replace `[options]` with the desired flags and arguments.
64
56
 
65
57
  To generate a website using Coralite, you must provide three essential options:
66
58
 
67
- - **-t or --templates**: The path to your templates directory containing reusable UI elements (e.g., `-t src/templates`).
59
+ - **-t or --components**: The path to your components directory containing reusable UI elements (e.g., `-t src/components`).
68
60
  - **-p or --pages**: The path to your pages directory where static HTML files reside (e.g., `-p src/pages`).
69
61
  - **--output or -o**: The output directory for the generated site (e.g., `--output dist`).
70
62
 
71
63
  Here's an example of how these options might look:
72
64
 
73
65
  ```bash
74
- coralite --templates path/to/templates --pages path/to/pages --output dist
66
+ coralite --components path/to/components --pages path/to/pages --output dist
75
67
  ```
76
68
 
77
69
  ## Optional Options
@@ -81,5 +73,5 @@ coralite --templates path/to/templates --pages path/to/pages --output dist
81
73
  Run the CLI in dry-run mode to preview the actions that would be performed without actually generating the website. This is useful for debugging or when you want to check potential issues before committing changes:
82
74
 
83
75
  ```bash
84
- coralite --templates path/to/templates --pages path/to/pages --output dist --dry-run
76
+ coralite --components path/to/components --pages path/to/pages --output dist --dry-run
85
77
  ```
@@ -1 +1 @@
1
- {"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AAEH;;;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B;+BAxBxB,iBAAiB;oCAkBtB,mBAAmB;0CAAnB,mBAAmB;qCAAnB,mBAAmB;sCAAnB,mBAAmB;oCAAnB,mBAAmB"}
package/dist/lib/index.js CHANGED
@@ -6615,6 +6615,18 @@ function findAndExtractScript(code) {
6615
6615
  if (node.callee && node.callee.type === "Identifier" && node.callee.name === "defineComponent") {
6616
6616
  const firstArg = node.arguments[0];
6617
6617
  if (firstArg && firstArg.type === "ObjectExpression") {
6618
+ const tokensProp = firstArg.properties.find(
6619
+ (prop) => prop.type === "Property" && prop.key.type === "Identifier" && prop.key.name === "tokens"
6620
+ );
6621
+ let tokens = [];
6622
+ if (tokensProp && tokensProp.type === "Property" && tokensProp.value.type === "ObjectExpression") {
6623
+ tokens = tokensProp.value.properties.map((p) => {
6624
+ if (p.type === "Property") {
6625
+ return p.key.type === "Identifier" ? p.key.name : p.key.type === "Literal" ? p.key.value : void 0;
6626
+ }
6627
+ return void 0;
6628
+ }).filter(Boolean);
6629
+ }
6618
6630
  const clientProp = firstArg.properties.find(
6619
6631
  (prop) => prop.type === "Property" && prop.key.type === "Identifier" && prop.key.name === "client"
6620
6632
  );
@@ -6733,6 +6745,15 @@ function findAndExtractScript(code) {
6733
6745
  result.setupContent = setupContent;
6734
6746
  }
6735
6747
  }
6748
+ if (result && tokens.length > 0) {
6749
+ result.tokens = tokens;
6750
+ }
6751
+ } else if (tokens.length > 0) {
6752
+ result = {
6753
+ content: "export default function(){}",
6754
+ lineOffset: 0,
6755
+ tokens
6756
+ };
6736
6757
  }
6737
6758
  }
6738
6759
  }
@@ -6770,7 +6791,7 @@ CoraliteCollection.prototype.setItem = async function(value) {
6770
6791
  throw new Error("Valid HTMLData object must be provided");
6771
6792
  }
6772
6793
  const pathname = value.path.pathname;
6773
- const dirname4 = value.path.dirname;
6794
+ const dirname5 = value.path.dirname;
6774
6795
  const originalValue = this.collection[pathname];
6775
6796
  const documentValue = value;
6776
6797
  if (!originalValue) {
@@ -6788,11 +6809,11 @@ CoraliteCollection.prototype.setItem = async function(value) {
6788
6809
  }
6789
6810
  }
6790
6811
  this.collection[pathname] = documentValue;
6791
- if (!this.listByPath[dirname4]) {
6792
- this.listByPath[dirname4] = [];
6812
+ if (!this.listByPath[dirname5]) {
6813
+ this.listByPath[dirname5] = [];
6793
6814
  }
6794
- if (!this.listByPath[dirname4].includes(documentValue)) {
6795
- this.listByPath[dirname4].push(documentValue);
6815
+ if (!this.listByPath[dirname5].includes(documentValue)) {
6816
+ this.listByPath[dirname5].push(documentValue);
6796
6817
  }
6797
6818
  if (!this.list.includes(documentValue)) {
6798
6819
  this.list.push(documentValue);
@@ -6807,18 +6828,18 @@ CoraliteCollection.prototype.deleteItem = async function(value) {
6807
6828
  throw new Error("Valid pathname must be provided");
6808
6829
  }
6809
6830
  let pathname;
6810
- let dirname4;
6831
+ let dirname5;
6811
6832
  let valuesByPath;
6812
6833
  let originalValue;
6813
6834
  if (typeof value !== "string" && value.path) {
6814
6835
  pathname = value.path.pathname;
6815
- dirname4 = value.path.dirname;
6816
- valuesByPath = this.listByPath[dirname4];
6836
+ dirname5 = value.path.dirname;
6837
+ valuesByPath = this.listByPath[dirname5];
6817
6838
  originalValue = value;
6818
6839
  } else if (typeof value === "string") {
6819
6840
  pathname = value;
6820
- dirname4 = path.dirname(pathname);
6821
- valuesByPath = this.listByPath[dirname4];
6841
+ dirname5 = path.dirname(pathname);
6842
+ valuesByPath = this.listByPath[dirname5];
6822
6843
  originalValue = this.collection[pathname];
6823
6844
  } else {
6824
6845
  throw new Error("Valid pathname must be provided");
@@ -6851,7 +6872,7 @@ CoraliteCollection.prototype.deleteItem = async function(value) {
6851
6872
  valuesByPath.splice(pathIndex, 1);
6852
6873
  }
6853
6874
  if (valuesByPath.length === 0) {
6854
- delete this.listByPath[dirname4];
6875
+ delete this.listByPath[dirname5];
6855
6876
  }
6856
6877
  };
6857
6878
  CoraliteCollection.prototype.updateItem = async function(value) {
@@ -6904,8 +6925,8 @@ CoraliteCollection.prototype.getItem = function(id) {
6904
6925
  }
6905
6926
  return this.collection[id];
6906
6927
  };
6907
- CoraliteCollection.prototype.getListByPath = function(dirname4) {
6908
- const list = this.listByPath[dirname4];
6928
+ CoraliteCollection.prototype.getListByPath = function(dirname5) {
6929
+ const list = this.listByPath[dirname5];
6909
6930
  if (list) {
6910
6931
  return list.slice();
6911
6932
  }
@@ -9354,7 +9375,7 @@ async function transformCss(css, rootClasses, descendantClasses) {
9354
9375
  import { build } from "esbuild";
9355
9376
  import serialize from "serialize-javascript";
9356
9377
  import { pathToFileURL } from "node:url";
9357
- import { resolve } from "node:path";
9378
+ import { resolve, relative, dirname as dirname2, parse as parse4, format } from "node:path";
9358
9379
  function ScriptManager() {
9359
9380
  this.sharedFunctions = /* @__PURE__ */ Object.create(null);
9360
9381
  this.helpers = /* @__PURE__ */ Object.create(null);
@@ -9438,11 +9459,14 @@ ScriptManager.prototype.compileStandaloneComponent = async function(componentId,
9438
9459
  if (parts.length > 0) {
9439
9460
  const importStr = parts.join(", ");
9440
9461
  entryCodeParts.push(`import ${importStr} from ${specifier}${attributesString};
9462
+ `);
9463
+ } else if (!importDefinition.namespaceExport) {
9464
+ entryCodeParts.push(`import ${specifier}${attributesString};
9441
9465
  `);
9442
9466
  }
9443
9467
  }
9444
9468
  }
9445
- const importsObjContent = Object.keys(importMap).length > 0 ? `const componentImports = { ${Object.entries(importMap).map(([key, value]) => `${key}: ${value}`).join(", ")} };` : "const componentImports = {};";
9469
+ const importsObjContent = Object.keys(importMap).length > 0 ? `const componentImports = { ${Object.entries(importMap).map(([key, value]) => `"${key}": ${value}`).join(", ")} };` : "const componentImports = {};";
9446
9470
  entryCodeParts.push(importsObjContent + "\n");
9447
9471
  entryCodeParts.push(`
9448
9472
  function kebabToCamel(str) {
@@ -9534,13 +9558,68 @@ function cleanKeys(object) {
9534
9558
  `);
9535
9559
  entryCodeParts.push(`
9536
9560
  class ${componentId.replace(/[-.:]/g, "_")} extends HTMLElement {
9561
+ static get observedAttributes() {
9562
+ return ${JSON.stringify(scriptContent?.tokens || [])};
9563
+ }
9564
+
9537
9565
  constructor() {
9538
9566
  super();
9539
9567
  this.attachShadow({ mode: 'open' });
9568
+ this._initialized = false;
9569
+ }
9570
+
9571
+ attributeChangedCallback(name, oldValue, newValue) {
9572
+ if (oldValue !== newValue) {
9573
+ if (this._context && this._context.values) {
9574
+ this._context.values[name] = newValue;
9575
+ }
9576
+ this.updateDOM(name, newValue);
9577
+ }
9578
+ }
9579
+
9580
+ updateDOM(name, newValue) {
9581
+ if (!this.shadowRoot) return;
9582
+
9583
+ // Find text nodes that contain the token mapping
9584
+ const walker = document.createTreeWalker(this.shadowRoot, NodeFilter.SHOW_TEXT, null, false);
9585
+ let node;
9586
+ const tokenStr = \`{{ \${name} }}\`;
9587
+
9588
+ while ((node = walker.nextNode())) {
9589
+ // Check if original data or textContent contains the token map
9590
+ if (node._coraliteTokens && node._coraliteTokens.includes(name)) {
9591
+ // We know this text node holds the value, let's re-render its text based on current context
9592
+ let newText = node._coraliteOriginalText;
9593
+ for (const token of node._coraliteTokens) {
9594
+ newText = newText.split(\`{{ \${token} }}\`).join(this._context.values[token] !== undefined ? this._context.values[token] : '');
9595
+ }
9596
+ node.nodeValue = newText;
9597
+ node.nodeValue = newText;
9598
+ }
9599
+ }
9600
+
9601
+ // Also update attributes that might have bindings
9602
+ const elements = this.shadowRoot.querySelectorAll('*');
9603
+ for (const el of elements) {
9604
+ if (el._coraliteAttrs) {
9605
+ for (const [attrName, originalValue] of Object.entries(el._coraliteAttrs)) {
9606
+ if (originalValue.includes(tokenStr)) {
9607
+ let newAttrValue = originalValue;
9608
+ // replace all tokens in this attribute
9609
+ const tokenMatches = originalValue.match(/\\{\\{([^}]+)\\}\\}/g) || [];
9610
+ for (const match of tokenMatches) {
9611
+ const tokenKey = match.replace(/\\{|\\}/g, '').trim();
9612
+ newAttrValue = newAttrValue.split(match).join(this._context.values[tokenKey] !== undefined ? this._context.values[tokenKey] : '');
9613
+ }
9614
+ el.setAttribute(attrName, newAttrValue);
9615
+ }
9616
+ }
9617
+ }
9618
+ }
9540
9619
  }
9541
9620
 
9542
9621
  async connectedCallback() {
9543
- // 1. Map DOM Attributes to values
9622
+ // Map DOM Attributes to values
9544
9623
  const domAttributes = {};
9545
9624
  for (let i = 0; i < this.attributes.length; i++) {
9546
9625
  const attribute = this.attributes[i];
@@ -9548,17 +9627,18 @@ class ${componentId.replace(/[-.:]/g, "_")} extends HTMLElement {
9548
9627
  }
9549
9628
  const initialValues = cleanKeys(domAttributes);
9550
9629
 
9551
- // 2. Hydrate Refs
9630
+ // Hydrate Refs
9552
9631
  const refs = {};
9553
9632
 
9554
- // 3. Setup context
9555
- const context = {
9633
+ // Setup context
9634
+ this._context = {
9556
9635
  instanceId: this.id || Math.random().toString(36).substr(2, 9),
9557
9636
  componentId: "${componentId}",
9558
9637
  values: initialValues,
9559
9638
  root: this.shadowRoot,
9560
9639
  imports: componentImports // Standalone imports are bundled within the component
9561
9640
  };
9641
+ const context = this._context;
9562
9642
 
9563
9643
  const setupValues = await getSetups(context);
9564
9644
  context.values = { ...context.values, ...setupValues };
@@ -9567,18 +9647,51 @@ class ${componentId.replace(/[-.:]/g, "_")} extends HTMLElement {
9567
9647
  let htmlPayload = \`${htmlPayload.replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`;
9568
9648
  const cssPayload = \`${cssPayload.replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`;
9569
9649
 
9570
- // Replace text tokens in the payload (rudimentary support for standalone components without the full AST engine)
9571
- for (const [key, value] of Object.entries(context.values)) {
9572
- const token = \`{{ \${key} }}\`;
9573
- htmlPayload = htmlPayload.split(token).join(value);
9574
- }
9575
-
9576
9650
  let styles = '';
9577
9651
  if (cssPayload) {
9578
9652
  styles = \`<style>\${cssPayload}</style>\`;
9579
9653
  }
9654
+
9655
+ // Set raw HTML first before token replacement to preserve slots structure
9580
9656
  this.shadowRoot.innerHTML = styles + htmlPayload;
9581
9657
 
9658
+ // Extract tokens mapped to DOM nodes for reactivity
9659
+ const walker = document.createTreeWalker(this.shadowRoot, NodeFilter.SHOW_TEXT, null, false);
9660
+ let node;
9661
+ while ((node = walker.nextNode())) {
9662
+ const text = node.textContent || '';
9663
+ const tokens = (text.match(/\\{\\{([^}]+)\\}\\}/g) || []).map(t => t.replace(/\\{|\\}/g, '').trim());
9664
+
9665
+ if (tokens.length > 0) {
9666
+ node._coraliteTokens = tokens;
9667
+ node._coraliteOriginalText = text;
9668
+
9669
+ let newText = text;
9670
+ for (const token of tokens) {
9671
+ newText = newText.split(\`{{ \${token} }}\`).join(context.values[token] !== undefined ? context.values[token] : '');
9672
+ }
9673
+ node.nodeValue = newText;
9674
+ }
9675
+ }
9676
+
9677
+ // Attribute reactivity
9678
+ const allElements = this.shadowRoot.querySelectorAll('*');
9679
+ for (const el of allElements) {
9680
+ for (const attr of el.attributes) {
9681
+ if (attr.value.includes('{{')) {
9682
+ if (!el._coraliteAttrs) el._coraliteAttrs = {};
9683
+ el._coraliteAttrs[attr.name] = attr.value;
9684
+
9685
+ let newAttrValue = attr.value;
9686
+ const tokens = (attr.value.match(/\\{\\{([^}]+)\\}\\}/g) || []).map(t => t.replace(/\\{|\\}/g, '').trim());
9687
+ for (const token of tokens) {
9688
+ newAttrValue = newAttrValue.split(\`{{ \${token} }}\`).join(context.values[token] !== undefined ? context.values[token] : '');
9689
+ }
9690
+ el.setAttribute(attr.name, newAttrValue);
9691
+ }
9692
+ }
9693
+ }
9694
+
9582
9695
  // Post-render ref extraction
9583
9696
  const refElements = this.shadowRoot.querySelectorAll('[ref]');
9584
9697
  refElements.forEach(el => {
@@ -9594,6 +9707,10 @@ class ${componentId.replace(/[-.:]/g, "_")} extends HTMLElement {
9594
9707
 
9595
9708
  // 4. Execute User Script
9596
9709
  if (typeof userComponentFn === 'function') {
9710
+ if (this._initialized) {
9711
+ return;
9712
+ }
9713
+ this._initialized = true;
9597
9714
  await userComponentFn.call(this, context);
9598
9715
  }
9599
9716
  }
@@ -9626,6 +9743,27 @@ customElements.define("${componentId}", ${componentId.replace(/[-.:]/g, "_")});
9626
9743
  pluginData: { index }
9627
9744
  };
9628
9745
  });
9746
+ pluginBuild.onResolve({ filter: /^coralite-component\// }, (args) => {
9747
+ const importedComponentId = args.path.replace("coralite-component/", "");
9748
+ let targetPath = `./${importedComponentId}.js`;
9749
+ const sourceSharedFn = this.sharedFunctions[componentId];
9750
+ const targetSharedFn = this.sharedFunctions[importedComponentId];
9751
+ if (sourceSharedFn && sourceSharedFn.filePath && targetSharedFn && targetSharedFn.filePath) {
9752
+ const relativePath = relative(dirname2(sourceSharedFn.filePath), targetSharedFn.filePath);
9753
+ const parsed = parse4(relativePath);
9754
+ parsed.ext = ".js";
9755
+ parsed.base = parsed.name + parsed.ext;
9756
+ let finalPath = format(parsed);
9757
+ if (!finalPath.startsWith(".") && !finalPath.startsWith("/")) {
9758
+ finalPath = `./${finalPath}`;
9759
+ }
9760
+ targetPath = finalPath.replace(/\\/g, "/");
9761
+ }
9762
+ return {
9763
+ path: targetPath,
9764
+ external: true
9765
+ };
9766
+ });
9629
9767
  pluginBuild.onLoad({
9630
9768
  filter: /.*/,
9631
9769
  namespace: "coralite-script-module"
@@ -9669,7 +9807,7 @@ customElements.define("${componentId}", ${componentId.replace(/[-.:]/g, "_")});
9669
9807
  }
9670
9808
  }
9671
9809
  }
9672
- const importsObjContent2 = Object.keys(importMap2).length > 0 ? `const pluginImports = { ${Object.entries(importMap2).map(([key, value]) => `${key}: ${value}`).join(", ")} };` : "const pluginImports = {};";
9810
+ const importsObjContent2 = Object.keys(importMap2).length > 0 ? `const pluginImports = { ${Object.entries(importMap2).map(([key, value]) => `"${key}": ${value}`).join(", ")} };` : "const pluginImports = {};";
9673
9811
  contents += importsObjContent2 + "\n";
9674
9812
  const configContent = module.config ? `const pluginConfig = ${JSON.stringify(module.config)};` : "const pluginConfig = {};";
9675
9813
  contents += configContent + "\n";
@@ -9901,7 +10039,7 @@ ScriptManager.prototype.compileAllInstances = async function(instances, mode) {
9901
10039
  }
9902
10040
  }
9903
10041
  }
9904
- const importsObjContent = Object.keys(importMap).length > 0 ? `const componentImports = { ${Object.entries(importMap).map(([key, value]) => `${key}: ${value}`).join(", ")} };` : "const componentImports = {};";
10042
+ const importsObjContent = Object.keys(importMap).length > 0 ? `const componentImports = { ${Object.entries(importMap).map(([key, value]) => `"${key}": ${value}`).join(", ")} };` : "const componentImports = {};";
9905
10043
  contents += importsObjContent + "\n";
9906
10044
  contents += "export default componentImports;";
9907
10045
  return {
@@ -9953,7 +10091,7 @@ ScriptManager.prototype.compileAllInstances = async function(instances, mode) {
9953
10091
  }
9954
10092
  }
9955
10093
  }
9956
- const importsObjContent = Object.keys(importMap).length > 0 ? `const pluginImports = { ${Object.entries(importMap).map(([key, value]) => `${key}: ${value}`).join(", ")} };` : "const pluginImports = {};";
10094
+ const importsObjContent = Object.keys(importMap).length > 0 ? `const pluginImports = { ${Object.entries(importMap).map(([key, value]) => `"${key}": ${value}`).join(", ")} };` : "const pluginImports = {};";
9957
10095
  contents += importsObjContent + "\n";
9958
10096
  const configContent = module.config ? `const pluginConfig = ${JSON.stringify(module.config)};` : "const pluginConfig = {};";
9959
10097
  contents += configContent + "\n";
@@ -10264,7 +10402,7 @@ var metadataPlugin = createPlugin({
10264
10402
 
10265
10403
  // lib/coralite.js
10266
10404
  import { mkdir, writeFile } from "node:fs/promises";
10267
- import { dirname as dirname2, join as join2, normalize, relative, resolve as resolve2 } from "node:path";
10405
+ import { dirname as dirname3, join as join2, normalize, relative as relative2, resolve as resolve2 } from "node:path";
10268
10406
  import { createRequire } from "node:module";
10269
10407
  import { transform } from "esbuild";
10270
10408
 
@@ -10532,10 +10670,10 @@ Coralite.prototype.initialise = async function() {
10532
10670
  if (data2.type === "component") {
10533
10671
  rootPath = this.options.path.components;
10534
10672
  }
10535
- const urlPathname = pathToFileURL2(join2("/", relative(rootPath, data2.path.pathname))).pathname;
10673
+ const urlPathname = pathToFileURL2(join2("/", relative2(rootPath, data2.path.pathname))).pathname;
10536
10674
  const values = {
10537
10675
  $urlPathname: urlPathname,
10538
- $urlDirname: pathToFileURL2(dirname2(urlPathname)).pathname,
10676
+ $urlDirname: pathToFileURL2(dirname3(urlPathname)).pathname,
10539
10677
  $filePathname: data2.path.pathname,
10540
10678
  $fileDirname: data2.path.dirname,
10541
10679
  $filename: data2.path.filename,
@@ -10677,7 +10815,10 @@ Coralite.prototype._generateStandaloneComponents = async function* () {
10677
10815
  );
10678
10816
  yield {
10679
10817
  type: "component",
10680
- path: component.path,
10818
+ path: {
10819
+ ...component.path,
10820
+ filename: component.path.filename.replace(/\.html$/, ".js")
10821
+ },
10681
10822
  content: compiledCode,
10682
10823
  duration: performance.now() - startTime
10683
10824
  };
@@ -10941,17 +11082,15 @@ Coralite.prototype.build = async function(...args) {
10941
11082
  });
10942
11083
  }
10943
11084
  await Promise.all(executing);
10944
- if (this.options.standaloneOutput) {
10945
- for await (const result of this._generateStandaloneComponents()) {
10946
- if (signal?.aborted) throw signal.reason;
10947
- if (typeof callback === "function") {
10948
- const transformed = await callback(result);
10949
- if (transformed) {
10950
- results.push(transformed);
10951
- }
10952
- } else {
10953
- results.push(result);
11085
+ for await (const result of this._generateStandaloneComponents()) {
11086
+ if (signal?.aborted) throw signal.reason;
11087
+ if (typeof callback === "function") {
11088
+ const transformed = await callback(result);
11089
+ if (transformed) {
11090
+ results.push(transformed);
10954
11091
  }
11092
+ } else {
11093
+ results.push(result);
10955
11094
  }
10956
11095
  }
10957
11096
  return results;
@@ -10982,15 +11121,19 @@ Coralite.prototype.save = async function(output, path2, options = {}) {
10982
11121
  const signal = options?.signal;
10983
11122
  const createdDir = {};
10984
11123
  const results = await this.build(path2, options, async (result) => {
10985
- let relDir, outDir, outFile, contentToWrite;
11124
+ let relativeDir, outDir, outFile, contentToWrite;
10986
11125
  if (result.type === "component") {
10987
- relDir = relative(this.options.path.components, result.path.dirname);
10988
- outDir = join2(this.options.standaloneOutput, relDir);
10989
- outFile = join2(outDir, result.path.filename.replace(".html", ".js"));
11126
+ relativeDir = relative2(this.options.path.components, result.path.dirname);
11127
+ if (this.options.standaloneOutput) {
11128
+ outDir = join2(output, this.options.standaloneOutput, relativeDir);
11129
+ } else {
11130
+ outDir = join2(output, "components", relativeDir);
11131
+ }
11132
+ outFile = join2(outDir, result.path.filename);
10990
11133
  contentToWrite = result.content;
10991
11134
  } else {
10992
- relDir = relative(this.options.path.pages, result.path.dirname);
10993
- outDir = join2(output, relDir);
11135
+ relativeDir = relative2(this.options.path.pages, result.path.dirname);
11136
+ outDir = join2(output, relativeDir);
10994
11137
  outFile = join2(outDir, result.path.filename);
10995
11138
  contentToWrite = result.content;
10996
11139
  }
@@ -11536,7 +11679,7 @@ Coralite.prototype._addPluginHook = function(name, callback) {
11536
11679
  var coralite_default = Coralite;
11537
11680
 
11538
11681
  // lib/plugin.js
11539
- import { basename, dirname as dirname3 } from "path";
11682
+ import { basename, dirname as dirname4 } from "path";
11540
11683
  function validateNonEmptyString(value, paramName) {
11541
11684
  if (typeof value !== "string" || value.trim().length === 0) {
11542
11685
  throw new Error(
@@ -11612,7 +11755,7 @@ function processComponents(path2) {
11612
11755
  content,
11613
11756
  path: {
11614
11757
  pathname: path2,
11615
- dirname: dirname3(path2),
11758
+ dirname: dirname4(path2),
11616
11759
  filename: basename(path2)
11617
11760
  }
11618
11761
  };