-
Notifications
You must be signed in to change notification settings - Fork 141
Add support for both CJS/ESM plugins #2876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
13cfeaa
Update documentation on custom CJS/ESM plugins
Harjun751 2068652
Add support of .cjs/.mjs custom plugins
Harjun751 6601a75
Update minimum node version to v22.12
Harjun751 2d2c5f3
Add new test site for plugins
Harjun751 a698212
Clarify comment phrasing
Harjun751 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
packages/cli/test/functional/test_site_custom_plugins/_markbind/layouts/default.md
This file contains hidden or 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,14 @@ | ||
| <header> | ||
|
|
||
| </header> | ||
|
|
||
| <div id="flex-body"> | ||
| <div id="content-wrapper"> | ||
| {{ content }} | ||
| </div> | ||
| <scroll-top-button></scroll-top-button> | ||
| </div> | ||
|
|
||
| <footer> | ||
|
|
||
| </footer> |
12 changes: 12 additions & 0 deletions
12
...l/test_site_custom_plugins/_markbind/plugins/cjs_module_scope/cjs_plugin_with_cjs_ext.cjs
This file contains hidden or 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,12 @@ | ||
| const cheerio = module.parent.require('cheerio'); | ||
|
|
||
| module.exports = { | ||
| postRender: (pluginContext, frontmatter, content) => { | ||
| const $ = cheerio.load(content, { xmlMode: false }); | ||
| // Modify the page... | ||
| $('#cjs_module_scope_cjs_plugin_with_cjs_ext').append( | ||
| 'Should work! (CJS module with .cjs extension in CJS module scope)', | ||
| ); | ||
| return $.html(); | ||
| }, | ||
| }; |
12 changes: 12 additions & 0 deletions
12
...test_site_custom_plugins/_markbind/plugins/cjs_module_scope/cjs_plugin_without_cjs_ext.js
This file contains hidden or 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,12 @@ | ||
| const cheerio = module.parent.require('cheerio'); | ||
|
|
||
| module.exports = { | ||
| postRender: (pluginContext, frontmatter, content) => { | ||
| const $ = cheerio.load(content, { xmlMode: false }); | ||
| // Modify the page... | ||
| $('#cjs_module_scope_cjs_plugin_without_cjs_ext').append( | ||
| 'Should work! (CJS module without .cjs extension in CJS module scope)', | ||
| ); | ||
| return $.html(); | ||
| }, | ||
| }; |
12 changes: 12 additions & 0 deletions
12
...l/test_site_custom_plugins/_markbind/plugins/cjs_module_scope/esm_plugin_with_mjs_ext.mjs
This file contains hidden or 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,12 @@ | ||
| import cheerio from 'cheerio'; | ||
|
|
||
| function postRender(pluginContext, frontmatter, content) { | ||
| const $ = cheerio.load(content); | ||
| // Modify the page... | ||
| $('#cjs_module_scope_esm_plugin_with_mjs_ext').append( | ||
| 'Should work! (ESM module with .mjs extension in CJS module scope)', | ||
| ); | ||
| return $.html(); | ||
| } | ||
|
|
||
| export { postRender }; |
12 changes: 12 additions & 0 deletions
12
...test_site_custom_plugins/_markbind/plugins/cjs_module_scope/esm_plugin_without_mjs_ext.js
This file contains hidden or 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,12 @@ | ||
| import cheerio from 'cheerio'; | ||
|
|
||
| function postRender(pluginContext, frontmatter, content) { | ||
| const $ = cheerio.load(content); | ||
| // Modify the page... | ||
| $('#cjs_module_scope_esm_plugin_without_mjs_ext').append( | ||
| '**SHOULD SKIP** (ESM module without .mjs extension in CJS module scope)', | ||
| ); | ||
| return $.html(); | ||
| } | ||
|
|
||
| export { postRender }; |
3 changes: 3 additions & 0 deletions
3
.../test/functional/test_site_custom_plugins/_markbind/plugins/cjs_module_scope/package.json
This file contains hidden or 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,3 @@ | ||
| { | ||
| "type": "commonjs" | ||
| } |
12 changes: 12 additions & 0 deletions
12
...l/test_site_custom_plugins/_markbind/plugins/esm_module_scope/cjs_plugin_with_cjs_ext.cjs
This file contains hidden or 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,12 @@ | ||
| const cheerio = module.parent.require('cheerio'); | ||
|
|
||
| module.exports = { | ||
| postRender: (pluginContext, frontmatter, content) => { | ||
| const $ = cheerio.load(content, { xmlMode: false }); | ||
| // Modify the page... | ||
| $('#esm_module_scope_cjs_plugin_with_cjs_ext').append( | ||
| 'Should work! (CJS module with .cjs extension in ESM module scope)', | ||
| ); | ||
| return $.html(); | ||
| }, | ||
| }; |
12 changes: 12 additions & 0 deletions
12
...test_site_custom_plugins/_markbind/plugins/esm_module_scope/cjs_plugin_without_cjs_ext.js
This file contains hidden or 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,12 @@ | ||
| const cheerio = module.parent.require('cheerio'); | ||
|
|
||
| module.exports = { | ||
| postRender: (pluginContext, frontmatter, content) => { | ||
| const $ = cheerio.load(content, { xmlMode: false }); | ||
| // Modify the page... | ||
| $('#esm_module_scope_cjs_plugin_without_cjs_ext').append( | ||
| '**SHOULD SKIP** (CJS module without .cjs extension in ESM module scope)', | ||
| ); | ||
| return $.html(); | ||
| }, | ||
| }; |
12 changes: 12 additions & 0 deletions
12
...l/test_site_custom_plugins/_markbind/plugins/esm_module_scope/esm_plugin_with_mjs_ext.mjs
This file contains hidden or 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,12 @@ | ||
| import cheerio from 'cheerio'; | ||
|
|
||
| function postRender(pluginContext, frontmatter, content) { | ||
| const $ = cheerio.load(content); | ||
| // Modify the page... | ||
| $('#esm_module_scope_esm_plugin_with_mjs_ext').append( | ||
| 'Should work! (ESM module with .mjs extension in ESM module scope)', | ||
| ); | ||
| return $.html(); | ||
| } | ||
|
|
||
| export { postRender }; |
12 changes: 12 additions & 0 deletions
12
...test_site_custom_plugins/_markbind/plugins/esm_module_scope/esm_plugin_without_mjs_ext.js
This file contains hidden or 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,12 @@ | ||
| import cheerio from 'cheerio'; | ||
|
|
||
| function postRender(pluginContext, frontmatter, content) { | ||
| const $ = cheerio.load(content); | ||
| // Modify the page... | ||
| $('#esm_module_scope_esm_plugin_without_mjs_ext').append( | ||
| 'Should work! (ESM module without .mjs extension in ESM module scope)', | ||
| ); | ||
| return $.html(); | ||
| } | ||
|
|
||
| export { postRender }; |
3 changes: 3 additions & 0 deletions
3
.../test/functional/test_site_custom_plugins/_markbind/plugins/esm_module_scope/package.json
This file contains hidden or 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,3 @@ | ||
| { | ||
| "type": "module" | ||
| } |
12 changes: 12 additions & 0 deletions
12
...al/test_site_custom_plugins/_markbind/plugins/no_module_scope/cjs_plugin_with_cjs_ext.cjs
This file contains hidden or 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,12 @@ | ||
| const cheerio = module.parent.require('cheerio'); | ||
|
|
||
| module.exports = { | ||
| postRender: (pluginContext, frontmatter, content) => { | ||
| const $ = cheerio.load(content, { xmlMode: false }); | ||
| // Modify the page... | ||
| $('#no_module_scope_cjs_plugin_with_cjs_ext').append( | ||
| 'Should work! (CJS module with .cjs extension not in any module scope)', | ||
| ); | ||
| return $.html(); | ||
| }, | ||
| }; |
12 changes: 12 additions & 0 deletions
12
.../test_site_custom_plugins/_markbind/plugins/no_module_scope/cjs_plugin_without_cjs_ext.js
This file contains hidden or 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,12 @@ | ||
| const cheerio = module.parent.require('cheerio'); | ||
|
|
||
| module.exports = { | ||
| postRender: (pluginContext, frontmatter, content) => { | ||
| const $ = cheerio.load(content, { xmlMode: false }); | ||
| // Modify the page... | ||
| $('#no_module_scope_cjs_plugin_without_cjs_ext').append( | ||
| 'Should work! (CJS module without .cjs extension not in any module scope)', | ||
| ); | ||
| return $.html(); | ||
| }, | ||
| }; |
12 changes: 12 additions & 0 deletions
12
...al/test_site_custom_plugins/_markbind/plugins/no_module_scope/esm_plugin_with_mjs_ext.mjs
This file contains hidden or 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,12 @@ | ||
| import cheerio from 'cheerio'; | ||
|
|
||
| function postRender(pluginContext, frontmatter, content) { | ||
| const $ = cheerio.load(content); | ||
| // Modify the page... | ||
| $('#no_module_scope_esm_plugin_with_mjs_ext').append( | ||
| 'Should work! (ESM module with .mjs extension not in any module scope)', | ||
| ); | ||
| return $.html(); | ||
| } | ||
|
|
||
| export { postRender }; |
12 changes: 12 additions & 0 deletions
12
.../test_site_custom_plugins/_markbind/plugins/no_module_scope/esm_plugin_without_mjs_ext.js
This file contains hidden or 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,12 @@ | ||
| import cheerio from 'cheerio'; | ||
|
|
||
| function postRender(pluginContext, frontmatter, content) { | ||
| const $ = cheerio.load(content); | ||
| // Modify the page... | ||
| $('#no_module_scope_esm_plugin_without_mjs_ext').append( | ||
| 'Should work! (ESM module without .mjs extension not in any module scope)', | ||
| ); | ||
| return $.html(); | ||
| } | ||
|
|
||
| export { postRender }; |
3 changes: 3 additions & 0 deletions
3
...i/test/functional/test_site_custom_plugins/_markbind/plugins/no_module_scope/package.json
This file contains hidden or 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,3 @@ | ||
| { | ||
|
|
||
| } |
Empty file.
12 changes: 12 additions & 0 deletions
12
...te_custom_plugins/expected/_markbind/plugins/cjs_module_scope/cjs_plugin_with_cjs_ext.cjs
This file contains hidden or 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,12 @@ | ||
| const cheerio = module.parent.require('cheerio'); | ||
|
|
||
| module.exports = { | ||
| postRender: (pluginContext, frontmatter, content) => { | ||
| const $ = cheerio.load(content, { xmlMode: false }); | ||
| // Modify the page... | ||
| $('#cjs_module_scope_cjs_plugin_with_cjs_ext').append( | ||
| 'Should work! (CJS module with .cjs extension in CJS module scope)', | ||
| ); | ||
| return $.html(); | ||
| }, | ||
| }; |
12 changes: 12 additions & 0 deletions
12
..._custom_plugins/expected/_markbind/plugins/cjs_module_scope/cjs_plugin_without_cjs_ext.js
This file contains hidden or 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,12 @@ | ||
| const cheerio = module.parent.require('cheerio'); | ||
|
|
||
| module.exports = { | ||
| postRender: (pluginContext, frontmatter, content) => { | ||
| const $ = cheerio.load(content, { xmlMode: false }); | ||
| // Modify the page... | ||
| $('#cjs_module_scope_cjs_plugin_without_cjs_ext').append( | ||
| 'Should work! (CJS module without .cjs extension in CJS module scope)', | ||
| ); | ||
| return $.html(); | ||
| }, | ||
| }; |
12 changes: 12 additions & 0 deletions
12
...te_custom_plugins/expected/_markbind/plugins/cjs_module_scope/esm_plugin_with_mjs_ext.mjs
This file contains hidden or 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,12 @@ | ||
| import cheerio from 'cheerio'; | ||
|
|
||
| function postRender(pluginContext, frontmatter, content) { | ||
| const $ = cheerio.load(content); | ||
| // Modify the page... | ||
| $('#cjs_module_scope_esm_plugin_with_mjs_ext').append( | ||
| 'Should work! (ESM module with .mjs extension in CJS module scope)', | ||
| ); | ||
| return $.html(); | ||
| } | ||
|
|
||
| export { postRender }; |
12 changes: 12 additions & 0 deletions
12
..._custom_plugins/expected/_markbind/plugins/cjs_module_scope/esm_plugin_without_mjs_ext.js
This file contains hidden or 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,12 @@ | ||
| import cheerio from 'cheerio'; | ||
|
|
||
| function postRender(pluginContext, frontmatter, content) { | ||
| const $ = cheerio.load(content); | ||
| // Modify the page... | ||
| $('#cjs_module_scope_esm_plugin_without_mjs_ext').append( | ||
| '**SHOULD SKIP** (ESM module without .mjs extension in CJS module scope)', | ||
| ); | ||
| return $.html(); | ||
| } | ||
|
|
||
| export { postRender }; |
3 changes: 3 additions & 0 deletions
3
...ctional/test_site_custom_plugins/expected/_markbind/plugins/cjs_module_scope/package.json
This file contains hidden or 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,3 @@ | ||
| { | ||
| "type": "commonjs" | ||
| } |
12 changes: 12 additions & 0 deletions
12
...te_custom_plugins/expected/_markbind/plugins/esm_module_scope/cjs_plugin_with_cjs_ext.cjs
This file contains hidden or 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,12 @@ | ||
| const cheerio = module.parent.require('cheerio'); | ||
|
|
||
| module.exports = { | ||
| postRender: (pluginContext, frontmatter, content) => { | ||
| const $ = cheerio.load(content, { xmlMode: false }); | ||
| // Modify the page... | ||
| $('#esm_module_scope_cjs_plugin_with_cjs_ext').append( | ||
| 'Should work! (CJS module with .cjs extension in ESM module scope)', | ||
| ); | ||
| return $.html(); | ||
| }, | ||
| }; |
12 changes: 12 additions & 0 deletions
12
..._custom_plugins/expected/_markbind/plugins/esm_module_scope/cjs_plugin_without_cjs_ext.js
This file contains hidden or 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,12 @@ | ||
| const cheerio = module.parent.require('cheerio'); | ||
|
|
||
| module.exports = { | ||
| postRender: (pluginContext, frontmatter, content) => { | ||
| const $ = cheerio.load(content, { xmlMode: false }); | ||
| // Modify the page... | ||
| $('#esm_module_scope_cjs_plugin_without_cjs_ext').append( | ||
| '**SHOULD SKIP** (CJS module without .cjs extension in ESM module scope)', | ||
| ); | ||
| return $.html(); | ||
| }, | ||
| }; |
12 changes: 12 additions & 0 deletions
12
...te_custom_plugins/expected/_markbind/plugins/esm_module_scope/esm_plugin_with_mjs_ext.mjs
This file contains hidden or 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,12 @@ | ||
| import cheerio from 'cheerio'; | ||
|
|
||
| function postRender(pluginContext, frontmatter, content) { | ||
| const $ = cheerio.load(content); | ||
| // Modify the page... | ||
| $('#esm_module_scope_esm_plugin_with_mjs_ext').append( | ||
| 'Should work! (ESM module with .mjs extension in ESM module scope)', | ||
| ); | ||
| return $.html(); | ||
| } | ||
|
|
||
| export { postRender }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.