Skip to content

Commit

Permalink
Fix main source file generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
francois2metz committed May 6, 2024
1 parent a5797d8 commit 641cb44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
"description": "Parcel plugin to load markdown file with yaml-front-matter.",
"author": "François de Metz <[email protected]>",
"license": "MIT",
"type": "module",
"source": "./src/index.ts",
"main": "./dist/main.js",
"module": "dist/module.js",
"types": "dist/index.d.ts",
"module": "./dist/module.js",
"types": "./dist/index.d.ts",
"scripts": {
"watch": "parcel watch",
"build": "parcel build",
Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import path from 'node:path';
import { Transformer } from '@parcel/plugin';
import { marked, type MarkedOptions } from 'marked';

Check failure on line 3 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("marked")' call instead.
import yamlFrontmatter from 'yaml-front-matter';
const { loadFront } = yamlFrontmatter;
import { loadFront } from 'yaml-front-matter';

export default new Transformer({
async loadConfig({ config }) {
Expand Down Expand Up @@ -43,7 +42,7 @@ export default new Transformer({
const option: { marked?: MarkedOptions } = config || {};
const result = { ...frontMatter };
if (option.marked) {
result.__content = marked.parse(frontMatter.__content, { ...option.marked });
result.__content = await marked.parse(frontMatter.__content, { ...option.marked });
}
asset.type = 'js';
asset.setCode(`export default ${JSON.stringify(result)}`);
Expand Down

0 comments on commit 641cb44

Please sign in to comment.