@ecopages/content-processor 0.2.0-rc.5 → 0.2.0-rc.6

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
@@ -31,6 +31,8 @@ The processor gives you a typed manifest and MDX components at build time. Wire
31
31
 
32
32
  During development, edits to an entry's MDX body invalidate its compiled server collection bundle even when its frontmatter and generated manifest are unchanged. The next request rebuilds that bundle and renders the new body.
33
33
 
34
+ Co-located non-entry files inside a collection directory (for example `survey-form.config.ts`, helper modules, or JSON data) also invalidate the compiled server collection without rewriting the generated entries manifest.
35
+
34
36
  ## Installation
35
37
 
36
38
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/content-processor",
3
- "version": "0.2.0-rc.5",
3
+ "version": "0.2.0-rc.6",
4
4
  "description": "Scan MDX collections at build time and expose typed ecopages:content/* virtual modules for pages and scripts",
5
5
  "keywords": [
6
6
  "content",
@@ -20,10 +20,10 @@
20
20
  "directory": "packages/processors/content-processor"
21
21
  },
22
22
  "peerDependencies": {
23
- "@ecopages/core": "0.2.0-rc.5"
23
+ "@ecopages/core": "0.2.0-rc.6"
24
24
  },
25
25
  "dependencies": {
26
- "@ecopages/file-system": "0.2.0-rc.5",
26
+ "@ecopages/file-system": "0.2.0-rc.6",
27
27
  "@ecopages/logger": "^0.2.3",
28
28
  "remark-frontmatter": "^5.0.0",
29
29
  "unified": "^11.0.5",
package/src/plugin.d.ts CHANGED
@@ -31,6 +31,7 @@ export declare class ContentProcessorPlugin extends Processor<ContentProcessorCo
31
31
  constructor(config: Omit<ProcessorConfig<ContentProcessorConfig>, 'name' | 'description'>);
32
32
  get buildPlugins(): EcoBuildPlugin[];
33
33
  get plugins(): EcoBuildPlugin[];
34
+ invalidateServerArtifacts(): void;
34
35
  private getCollectionsConfig;
35
36
  private getCollectionContentRoot;
36
37
  private writeGeneratedFile;
@@ -48,6 +49,7 @@ export declare class ContentProcessorPlugin extends Processor<ContentProcessorCo
48
49
  private regenerateCollectionEntriesModule;
49
50
  private regenerateCollections;
50
51
  private regenerateAllCollections;
52
+ private isCollectionEntryPath;
51
53
  private handleContentFileEvent;
52
54
  private initializeWatchPaths;
53
55
  private generateTypes;
package/src/plugin.js CHANGED
@@ -49,7 +49,7 @@ export class ContentProcessorPlugin extends Processor {
49
49
  constructor(config) {
50
50
  const defaultWatchConfig = {
51
51
  paths: [],
52
- extensions: ['mdx'],
52
+ extensions: ['.mdx', '.md', '.ts', '.tsx', '.js', '.jsx', '.json'],
53
53
  onCreate: async (ctx) => this.handleContentFileEvent(ctx.path, 'create'),
54
54
  onChange: async (ctx) => this.handleContentFileEvent(ctx.path, 'change'),
55
55
  onDelete: async (ctx) => this.handleContentFileEvent(ctx.path, 'delete'),
@@ -72,6 +72,11 @@ export class ContentProcessorPlugin extends Processor {
72
72
  createContentPlugin(this.collectionModules, this.collectionServerModules, this.collectionServerCompiledModules, this.collectionBrowserModules, (collectionName) => this.ensureCollectionServerArtifact(collectionName)),
73
73
  ];
74
74
  }
75
+ invalidateServerArtifacts() {
76
+ for (const collectionName of Object.keys(this.getCollectionsConfig())) {
77
+ this.invalidateCollectionServerArtifact(collectionName);
78
+ }
79
+ }
75
80
  getCollectionsConfig() {
76
81
  if (!this.options?.collections) {
77
82
  throw new Error('Content processor requires `options.collections`');
@@ -177,6 +182,13 @@ export class ContentProcessorPlugin extends Processor {
177
182
  async regenerateAllCollections() {
178
183
  await this.regenerateCollections(Object.keys(this.getCollectionsConfig()));
179
184
  }
185
+ isCollectionEntryPath(normalizedPath, configuredExtensions) {
186
+ const extensions = configuredExtensions ?? ['.mdx'];
187
+ return extensions.some((ext) => {
188
+ const dotted = ext.startsWith('.') ? ext : `.${ext}`;
189
+ return normalizedPath.endsWith(dotted);
190
+ });
191
+ }
180
192
  async handleContentFileEvent(filePath, event) {
181
193
  if (!this.context) {
182
194
  return;
@@ -191,6 +203,12 @@ export class ContentProcessorPlugin extends Processor {
191
203
  }
192
204
  let shouldRegenerateTypes = false;
193
205
  for (const collectionName of affectedCollections) {
206
+ const definition = this.getCollectionsConfig()[collectionName];
207
+ const isEntry = this.isCollectionEntryPath(normalizedPath, definition.extensions);
208
+ if (!isEntry) {
209
+ this.invalidateCollectionServerArtifact(collectionName);
210
+ continue;
211
+ }
194
212
  if (event === 'create' || event === 'delete') {
195
213
  await this.regenerateCollectionModule(collectionName);
196
214
  shouldRegenerateTypes = true;