Fix Markdoc cloudflare errors (#7351)
* fix: move `node:` libs out of utils * fix: node -> default * chore: remove kleur from markdoc ex (why was this there??) * chore: lock * chore: changeset
This commit is contained in:
parent
491c2db424
commit
a30f2f3de4
6 changed files with 30 additions and 49 deletions
5
.changeset/early-colts-punch.md
Normal file
5
.changeset/early-colts-punch.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/markdoc': patch
|
||||
---
|
||||
|
||||
Fix cloudflare build errors for a bad "./config" entrypoint and "node:crypto" getting included unexpectedly.
|
|
@ -12,7 +12,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@astrojs/markdoc": "^0.3.0",
|
||||
"astro": "^2.5.6",
|
||||
"kleur": "^4.1.5"
|
||||
"astro": "^2.6.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,15 +21,15 @@
|
|||
"exports": {
|
||||
"./prism": {
|
||||
"types": "./dist/extensions/prism.d.ts",
|
||||
"node": "./dist/extensions/prism.js"
|
||||
"default": "./dist/extensions/prism.js"
|
||||
},
|
||||
"./shiki": {
|
||||
"types": "./dist/extensions/shiki.d.ts",
|
||||
"node": "./dist/extensions/shiki.js"
|
||||
"default": "./dist/extensions/shiki.js"
|
||||
},
|
||||
"./config": {
|
||||
"types": "./dist/config.d.ts",
|
||||
"node": "./dist/config.js"
|
||||
"default": "./dist/config.js"
|
||||
},
|
||||
".": "./dist/index.js",
|
||||
"./components": "./components/index.ts",
|
||||
|
|
|
@ -4,8 +4,8 @@ import Markdoc from '@markdoc/markdoc';
|
|||
import type { AstroConfig, AstroIntegration, ContentEntryType, HookParameters } from 'astro';
|
||||
import fs from 'node:fs';
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
import crypto from 'node:crypto';
|
||||
import {
|
||||
createNameHash,
|
||||
hasContentFlag,
|
||||
isValidUrl,
|
||||
MarkdocError,
|
||||
|
@ -292,3 +292,18 @@ function shouldOptimizeImage(src: string) {
|
|||
// Optimize anything that is NOT external or an absolute path to `public/`
|
||||
return !isValidUrl(src) && !src.startsWith('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create build hash for manual Rollup chunks.
|
||||
* @see 'packages/astro/src/core/build/plugins/plugin-css.ts'
|
||||
*/
|
||||
function createNameHash(baseId: string, hashIds: string[]): string {
|
||||
const baseName = baseId ? path.parse(baseId).name : 'index';
|
||||
const hash = crypto.createHash('sha256');
|
||||
for (const id of hashIds) {
|
||||
hash.update(id, 'utf-8');
|
||||
}
|
||||
const h = hash.digest('hex').slice(0, 8);
|
||||
const proposedName = baseName + '.' + h;
|
||||
return proposedName;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import matter from 'gray-matter';
|
||||
import crypto from 'node:crypto';
|
||||
import path from 'node:path';
|
||||
import type { ErrorPayload as ViteErrorPayload } from 'vite';
|
||||
|
||||
/**
|
||||
|
@ -112,18 +110,3 @@ export function hasContentFlag(viteId: string, flag: string): boolean {
|
|||
const flags = new URLSearchParams(viteId.split('?')[1] ?? '');
|
||||
return flags.has(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create build hash for manual Rollup chunks.
|
||||
* @see 'packages/astro/src/core/build/plugins/plugin-css.ts'
|
||||
*/
|
||||
export function createNameHash(baseId: string, hashIds: string[]): string {
|
||||
const baseName = baseId ? path.parse(baseId).name : 'index';
|
||||
const hash = crypto.createHash('sha256');
|
||||
for (const id of hashIds) {
|
||||
hash.update(id, 'utf-8');
|
||||
}
|
||||
const h = hash.digest('hex').slice(0, 8);
|
||||
const proposedName = baseName + '.' + h;
|
||||
return proposedName;
|
||||
}
|
||||
|
|
|
@ -373,11 +373,8 @@ importers:
|
|||
specifier: ^0.3.0
|
||||
version: link:../../packages/integrations/markdoc
|
||||
astro:
|
||||
specifier: ^2.5.6
|
||||
specifier: ^2.6.2
|
||||
version: link:../../packages/astro
|
||||
kleur:
|
||||
specifier: ^4.1.5
|
||||
version: 4.1.5
|
||||
|
||||
examples/with-markdown-plugins:
|
||||
dependencies:
|
||||
|
@ -4235,15 +4232,6 @@ importers:
|
|||
specifier: 0.2.3
|
||||
version: 0.2.3
|
||||
|
||||
packages/integrations/mdx/test/fixtures/invalid-mdx-component:
|
||||
dependencies:
|
||||
'@astrojs/mdx':
|
||||
specifier: workspace:*
|
||||
version: link:../../..
|
||||
astro:
|
||||
specifier: workspace:*
|
||||
version: link:../../../../../astro
|
||||
|
||||
packages/integrations/mdx/test/fixtures/mdx-frontmatter-injection:
|
||||
dependencies:
|
||||
'@astrojs/mdx':
|
||||
|
@ -5456,13 +5444,12 @@ packages:
|
|||
|
||||
/@astrojs/compiler@1.4.2:
|
||||
resolution: {integrity: sha512-xoRp7JpiMZPK/beUcZEM5kM44Z/h20wwwQcl54duPqQMyySG9vZ5xMM6dYiQmn7b3XzpZs0cT6TRDoJJ5gwHAQ==}
|
||||
dev: true
|
||||
|
||||
/@astrojs/language-server@1.0.0:
|
||||
resolution: {integrity: sha512-oEw7AwJmzjgy6HC9f5IdrphZ1GVgfV/+7xQuyf52cpTiRWd/tJISK3MsKP0cDkVlfodmNABNFnAaAWuLZEiiiA==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@astrojs/compiler': 1.4.0
|
||||
'@astrojs/compiler': 1.4.2
|
||||
'@jridgewell/trace-mapping': 0.3.18
|
||||
'@vscode/emmet-helper': 2.8.8
|
||||
events: 3.3.0
|
||||
|
@ -5850,14 +5837,6 @@ packages:
|
|||
'@babel/types': 7.21.5
|
||||
dev: false
|
||||
|
||||
/@babel/parser@7.21.8:
|
||||
resolution: {integrity: sha512-6zavDGdzG3gUqAdWvlLFfk+36RilI+Pwyuuh7HItyeScCWP3k6i8vKclAQ0bM/0y/Kz/xiwvxhMv9MgTJP5gmA==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@babel/types': 7.21.5
|
||||
dev: false
|
||||
|
||||
/@babel/parser@7.21.9:
|
||||
resolution: {integrity: sha512-q5PNg/Bi1OpGgx5jYlvWZwAorZepEudDMCLtj967aeS7WMont7dUZI46M2XwcIQqvUlMxWfdLFu4S/qSxeUu5g==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
|
@ -8691,7 +8670,7 @@ packages:
|
|||
/@types/babel__core@7.1.19:
|
||||
resolution: {integrity: sha512-WEOTgRsbYkvA/KCsDwVEGkd7WAr1e3g31VHQ8zy5gul/V1qKullU/BU5I68X5v7V3GnB9eotmom4v5a5gjxorw==}
|
||||
dependencies:
|
||||
'@babel/parser': 7.21.8
|
||||
'@babel/parser': 7.21.9
|
||||
'@babel/types': 7.21.5
|
||||
'@types/babel__generator': 7.6.4
|
||||
'@types/babel__template': 7.4.1
|
||||
|
@ -8706,7 +8685,7 @@ packages:
|
|||
/@types/babel__template@7.4.1:
|
||||
resolution: {integrity: sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==}
|
||||
dependencies:
|
||||
'@babel/parser': 7.18.4
|
||||
'@babel/parser': 7.21.9
|
||||
'@babel/types': 7.21.5
|
||||
dev: false
|
||||
|
||||
|
@ -15514,7 +15493,7 @@ packages:
|
|||
resolution: {integrity: sha512-lJ/mG/Lz/ccSwNtwqpFS126mtMVzFVyYv0ddTF9wqwrEG4seECjKDAyw/oGv915rAcJi8jr89990nqfpmG+qdg==}
|
||||
engines: {node: ^14.15.0 || >=16.0.0, pnpm: '>=7.14.0'}
|
||||
dependencies:
|
||||
'@astrojs/compiler': 1.4.0
|
||||
'@astrojs/compiler': 1.4.2
|
||||
prettier: 2.8.8
|
||||
sass-formatter: 0.7.6
|
||||
synckit: 0.8.5
|
||||
|
|
Loading…
Reference in a new issue