mirror of
https://github.com/modernweb-dev/rocket.git
synced 2026-03-22 08:51:18 +00:00
Compare commits
10 Commits
@mdjs/core
...
@rocket/cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c009801164 | ||
|
|
60310ab3dd | ||
|
|
db03f69210 | ||
|
|
e6c3d274cf | ||
|
|
f9014c15a6 | ||
|
|
7e277cd88f | ||
|
|
bc6106381c | ||
|
|
00bf3882f6 | ||
|
|
543e297c5b | ||
|
|
70b0ce8e1c |
@@ -112,16 +112,13 @@ addPlugin(MyClass, { otherProp: 'new name' }); // ts error
|
|||||||
|
|
||||||
Many plugin systems require you to either execute a plugin function like in `rollup`.
|
Many plugin systems require you to either execute a plugin function like in `rollup`.
|
||||||
|
|
||||||
<!-- prettier-ignore-start -->
|
|
||||||
```js
|
```js
|
||||||
import json from '@rollup/plugin-json';
|
import json from '@rollup/plugin-json';
|
||||||
|
|
||||||
/** @type {import('rocket/cli').RocketCliConfig} */
|
export default /** @type {import('rocket/cli').RocketCliConfig} */ ({
|
||||||
export default ({
|
|
||||||
plugins: [json({ preferConst: true })],
|
plugins: [json({ preferConst: true })],
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
<!-- prettier-ignore-end -->
|
|
||||||
|
|
||||||
or add it in a special way like in `eleventy`
|
or add it in a special way like in `eleventy`
|
||||||
|
|
||||||
@@ -254,6 +251,18 @@ addPlugin(myPlugin, { myFlag: true }); // ts ok
|
|||||||
addPlugin(myPlugin, { notExisting: true }); // ts error
|
addPlugin(myPlugin, { notExisting: true }); // ts error
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: There is a "hidden" feature in addPlugin that if you attach a `wrapPlugin` property to the returning function it will call `wrapPlugin` on the plugin before adding it.
|
||||||
|
|
||||||
|
```js
|
||||||
|
// example auto wrap rollup plugins for @web/dev-server
|
||||||
|
import { fromRollup } from '@web/dev-server-rollup';
|
||||||
|
|
||||||
|
const userSetupFunctions = [addPlugin(json)].map(mod => {
|
||||||
|
mod.wrapPlugin = fromRollup;
|
||||||
|
return mod;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Adjusting Plugin Options
|
## Adjusting Plugin Options
|
||||||
|
|
||||||
Adjusting options means to either
|
Adjusting options means to either
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
"update-package-configs": "node scripts/update-package-configs.mjs && yarn format"
|
"update-package-configs": "node scripts/update-package-configs.mjs && yarn format"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@changesets/cli": "^2.12.0",
|
"@changesets/cli": "^2.20.0",
|
||||||
"@custom-elements-manifest/analyzer": "^0.4.12",
|
"@custom-elements-manifest/analyzer": "^0.4.12",
|
||||||
"@open-wc/testing": "^3.0.0-next.1",
|
"@open-wc/testing": "^3.0.0-next.1",
|
||||||
"@rollup/plugin-commonjs": "^17.0.0",
|
"@rollup/plugin-commonjs": "^17.0.0",
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
"husky": "^4.3.7",
|
"husky": "^4.3.7",
|
||||||
"lint-staged": "^10.5.3",
|
"lint-staged": "^10.5.3",
|
||||||
"mocha": "^8.2.1",
|
"mocha": "^8.2.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.7",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"onchange": "^7.1.0",
|
"onchange": "^7.1.0",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.2.1",
|
||||||
@@ -84,8 +84,6 @@
|
|||||||
"puppeteer": "^9.0.0",
|
"puppeteer": "^9.0.0",
|
||||||
"remark-emoji": "^2.1.0",
|
"remark-emoji": "^2.1.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rocket-preset-code-tabs": "^0.2.6",
|
|
||||||
"rocket-preset-custom-elements-manifest": "^0.1.7",
|
|
||||||
"rollup": "^2.36.1",
|
"rollup": "^2.36.1",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
"sinon": "^9.2.3",
|
"sinon": "^9.2.3",
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# @rocket/cli
|
# @rocket/cli
|
||||||
|
|
||||||
|
## 0.10.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 60310ab: Improve performance by initializing sax-wasm only once even when it is running in parallel
|
||||||
|
- Updated dependencies [60310ab]
|
||||||
|
- @rocket/eleventy-rocket-nav@0.3.1
|
||||||
|
|
||||||
## 0.10.1
|
## 0.10.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/cli",
|
"name": "@rocket/cli",
|
||||||
"version": "0.10.1",
|
"version": "0.10.2",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
"@rocket/building-rollup": "^0.4.0",
|
"@rocket/building-rollup": "^0.4.0",
|
||||||
"@rocket/core": "^0.1.2",
|
"@rocket/core": "^0.1.2",
|
||||||
"@rocket/eleventy-plugin-mdjs-unified": "^0.6.0",
|
"@rocket/eleventy-plugin-mdjs-unified": "^0.6.0",
|
||||||
"@rocket/eleventy-rocket-nav": "^0.3.0",
|
"@rocket/eleventy-rocket-nav": "^0.3.1",
|
||||||
"@rollup/plugin-babel": "^5.2.2",
|
"@rollup/plugin-babel": "^5.2.2",
|
||||||
"@rollup/plugin-node-resolve": "^11.0.1",
|
"@rollup/plugin-node-resolve": "^11.0.1",
|
||||||
"@web/config-loader": "^0.1.3",
|
"@web/config-loader": "^0.1.3",
|
||||||
|
|||||||
@@ -243,9 +243,9 @@ async function insertResponsiveImages(html) {
|
|||||||
const config = getComputedConfig();
|
const config = getComputedConfig();
|
||||||
|
|
||||||
if (!isSetup) {
|
if (!isSetup) {
|
||||||
await parser.prepareWasm(saxWasmBuffer);
|
isSetup = parser.prepareWasm(saxWasmBuffer);
|
||||||
isSetup = true;
|
|
||||||
}
|
}
|
||||||
|
await isSetup;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
inputPath: this.inputPath,
|
inputPath: this.inputPath,
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @rocket/eleventy-rocket-nav
|
# @rocket/eleventy-rocket-nav
|
||||||
|
|
||||||
|
## 0.3.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 60310ab: Improve performance by initializing sax-wasm only once even when it is running in parallel
|
||||||
|
|
||||||
## 0.3.0
|
## 0.3.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/eleventy-rocket-nav",
|
"name": "@rocket/eleventy-rocket-nav",
|
||||||
"version": "0.3.0",
|
"version": "0.3.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ function getHeadingsOfHtml(html) {
|
|||||||
return { headings, insertPoint };
|
return { headings, insertPoint };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @type {boolean | Promise<unknown>} */
|
||||||
let isSetup = false;
|
let isSetup = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,9 +105,9 @@ let isSetup = false;
|
|||||||
*/
|
*/
|
||||||
async function addPageAnchors(content) {
|
async function addPageAnchors(content) {
|
||||||
if (!isSetup) {
|
if (!isSetup) {
|
||||||
await parser.prepareWasm(saxWasmBuffer);
|
isSetup = parser.prepareWasm(saxWasmBuffer);
|
||||||
isSetup = true;
|
|
||||||
}
|
}
|
||||||
|
await isSetup;
|
||||||
|
|
||||||
const { headings, insertPoint } = getHeadingsOfHtml(content);
|
const { headings, insertPoint } = getHeadingsOfHtml(content);
|
||||||
const pageAnchorsHtml = [];
|
const pageAnchorsHtml = [];
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## 0.9.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- e6c3d27: Support `js client` as an alias to `js script`
|
||||||
|
|
||||||
## 0.9.3
|
## 0.9.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mdjs/core",
|
"name": "@mdjs/core",
|
||||||
"version": "0.9.3",
|
"version": "0.9.4",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ function mdjsParse() {
|
|||||||
if (node.lang === 'js' && node.meta === 'script') {
|
if (node.lang === 'js' && node.meta === 'script') {
|
||||||
jsCode += node.value;
|
jsCode += node.value;
|
||||||
}
|
}
|
||||||
|
if (node.lang === 'js' && node.meta === 'client') {
|
||||||
|
jsCode += node.value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// we can only return/modify the tree but jsCode should not be part of the tree
|
// we can only return/modify the tree but jsCode should not be part of the tree
|
||||||
// so we attach it globally to the file.data
|
// so we attach it globally to the file.data
|
||||||
@@ -26,7 +29,9 @@ function mdjsParse() {
|
|||||||
* @param {Node} node
|
* @param {Node} node
|
||||||
*/
|
*/
|
||||||
const removeFunction = node =>
|
const removeFunction = node =>
|
||||||
node.type === 'code' && node.lang === 'js' && node.meta === 'script';
|
node.type === 'code' &&
|
||||||
|
node.lang === 'js' &&
|
||||||
|
(node.meta === 'script' || node.meta === 'client');
|
||||||
remove(tree, removeFunction);
|
remove(tree, removeFunction);
|
||||||
|
|
||||||
return tree;
|
return tree;
|
||||||
|
|||||||
@@ -28,6 +28,24 @@ describe('mdjsParse', () => {
|
|||||||
expect(/** @type {MDJSVFileData} */ (result.data).jsCode).to.equal('const bar = 22;');
|
expect(/** @type {MDJSVFileData} */ (result.data).jsCode).to.equal('const bar = 22;');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('extracts "js client" code blocks', async () => {
|
||||||
|
const input = [
|
||||||
|
'## Intro',
|
||||||
|
'```js',
|
||||||
|
'const foo = 1;',
|
||||||
|
'```',
|
||||||
|
'```js client',
|
||||||
|
'const bar = 22;',
|
||||||
|
'```',
|
||||||
|
].join('\n');
|
||||||
|
const parser = unified().use(markdown).use(mdjsParse).use(html, { sanitize: false });
|
||||||
|
const result = await parser.process(input);
|
||||||
|
expect(result.contents).to.equal(
|
||||||
|
'<h2>Intro</h2>\n<pre><code class="language-js">const foo = 1;\n</code></pre>\n',
|
||||||
|
);
|
||||||
|
expect(/** @type {MDJSVFileData} */ (result.data).jsCode).to.equal('const bar = 22;');
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: fix this bug - maybe something in unified itself 🤔
|
// TODO: fix this bug - maybe something in unified itself 🤔
|
||||||
it.skip('handling only "js script" code blocks', async () => {
|
it.skip('handling only "js script" code blocks', async () => {
|
||||||
const input = [
|
const input = [
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# plugins-manager
|
# plugins-manager
|
||||||
|
|
||||||
|
## 0.3.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 7e277cd: Add a "hidden" feature in addPlugin that if you attach a `wrapPlugin` property to the returning function it will call `wrapPlugin` on the plugin before adding it.
|
||||||
|
|
||||||
## 0.3.0
|
## 0.3.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "plugins-manager",
|
"name": "plugins-manager",
|
||||||
"version": "0.3.0",
|
"version": "0.3.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||||
/**
|
/**
|
||||||
* @template {import('../types/main').Plugin} T
|
* @template {import('../types/main').Plugin} T
|
||||||
* @param {T} plugin
|
* @param {T} plugin
|
||||||
@@ -12,6 +13,10 @@ export function addPlugin(plugin, options = {}, { how = 'after', location = 'bot
|
|||||||
if (plugins === undefined) {
|
if (plugins === undefined) {
|
||||||
plugins = [];
|
plugins = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
const usePlugin = addPluginFn.wrapPlugin ? addPluginFn.wrapPlugin(plugin) : plugin;
|
||||||
|
|
||||||
// only add if name is not already in the meta plugin list
|
// only add if name is not already in the meta plugin list
|
||||||
if (plugins.findIndex(pluginObj => pluginObj.plugin === plugin) === -1) {
|
if (plugins.findIndex(pluginObj => pluginObj.plugin === plugin) === -1) {
|
||||||
let index = -1;
|
let index = -1;
|
||||||
@@ -40,7 +45,7 @@ export function addPlugin(plugin, options = {}, { how = 'after', location = 'bot
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins.splice(index, 0, {
|
plugins.splice(index, 0, {
|
||||||
plugin,
|
plugin: usePlugin,
|
||||||
options,
|
options,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,4 +109,18 @@ describe('addPlugin', () => {
|
|||||||
});
|
});
|
||||||
expect(config.plugins).to.deep.equal(['-- newFirst last Plugin --']);
|
expect(config.plugins).to.deep.equal(['-- newFirst last Plugin --']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('[advanced] can add a `wrapPlugin` property to the function itself which will call it on the plugin on init', async () => {
|
||||||
|
function myWrapper(plugin) {
|
||||||
|
return () => 'wrapped' + plugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = applyPlugins({
|
||||||
|
setupPlugins: [addPlugin(insertPlugin)].map(mod => {
|
||||||
|
mod.wrapPlugin = myWrapper;
|
||||||
|
return mod;
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
expect(config.plugins).to.deep.equal(['wrapped-- first last Plugin --']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user