-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6005912
commit e884a4e
Showing
15 changed files
with
4,057 additions
and
1,419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ jobs: | |
|
||
- run: yarn install --immutable | ||
- run: yarn build | ||
- run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
nodeLinker: node-modules | ||
|
||
nmHoistingLimits: workspaces | ||
yarnPath: .yarn/releases/yarn-4.2.1.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
"watch": "parcel watch", | ||
"build": "parcel build", | ||
"example": "yarn workspace example build", | ||
"test": "rm -rf .parcel-cache && rm -rf dist && node test/index.cjs" | ||
"test": "yarn workspace test test" | ||
}, | ||
"keywords": [ | ||
"parcel", | ||
|
@@ -52,7 +52,8 @@ | |
"parcel": "^2.2.0" | ||
}, | ||
"workspaces": [ | ||
"example" | ||
"example/", | ||
"test/" | ||
], | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "@parcel/config-default", | ||
"transformers": { | ||
"*.md": ["parcel-transformer-markdown-front-matter"] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const fs = require('node:fs/promises'); | ||
const url = require('node:url'); | ||
const { Parcel } = require('@parcel/core'); | ||
const jsdom = require('jsdom'); | ||
const { JSDOM } = jsdom; | ||
|
||
const bundler = new Parcel({ | ||
entries: './markdown/index.html', | ||
defaultConfig: '@parcel/config-default', | ||
defaultTargetOptions: { | ||
distDir: './dist' | ||
}, | ||
shouldDisableCache: true, | ||
}); | ||
|
||
class FileResourceLoader extends jsdom.ResourceLoader { | ||
fetch(url, options) { | ||
const parsedUrl = new URL(url); | ||
return fs.readFile(`./dist${parsedUrl.pathname}`); | ||
} | ||
} | ||
|
||
test('render a markdown file', async () => { | ||
return expect(new Promise(async (resolve, reject) => { | ||
await bundler.run(); | ||
const virtualConsole = new jsdom.VirtualConsole(); | ||
const logs = []; | ||
virtualConsole.on('log', (message) => { | ||
logs.push(message); | ||
}); | ||
const dom = await JSDOM.fromFile('./dist/index.html', { | ||
runScripts: 'dangerously', | ||
resources: new FileResourceLoader(), | ||
virtualConsole, | ||
}); | ||
dom.window.onEnd = () => { | ||
resolve(logs); | ||
}; | ||
})).resolves.toEqual([ | ||
'parcel-transformer-markdown-front-matter', | ||
`<h1 id="markdown">Markdown</h1> | ||
<p>Markdown content</p>` | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Test</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> | ||
<script type="module" src="./index.js"></script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import md from './index.md'; | ||
console.log(md.title); | ||
console.log(md.__content.trim()); | ||
window.onEnd(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: parcel-transformer-markdown-front-matter | ||
--- | ||
|
||
# Markdown | ||
|
||
Markdown content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "test", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@parcel/config-default": "^2.12.0", | ||
"@parcel/core": "^2.12.0", | ||
"jest": "^29.7.0", | ||
"jsdom": "^24.0.0", | ||
"parcel-transformer-markdown-front-matter": "workspace:^" | ||
} | ||
} |
Oops, something went wrong.