File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " mdsvex " : patch
3+ ---
4+
5+ Ensure that mdsvex files and layouts can contain Svelte 5 syntax.
Original file line number Diff line number Diff line change 1+ ---
2+ " mdsvex " : patch
3+ ---
4+
5+ Replace process polyfill with something that isn't ridiculous
Original file line number Diff line number Diff line change 4949 "tslib" : " ^2.3.1"
5050 },
5151 "engines" : {
52- "pnpm" : " ^9.1.0 "
52+ "pnpm" : " ^9.1.4 "
5353 },
5454 "pnpm" : {
5555 "onlyBuiltDependencies" : [
5656 " esbuild"
5757 ]
5858 },
59- "packageManager" : " pnpm@9.1.0 "
59+ "packageManager" : " pnpm@9.1.4 "
6060}
Original file line number Diff line number Diff line change 5959 "remark-slug" : " ^6.0.0" ,
6060 "retext" : " ^7.0.1" ,
6161 "retext-smartypants" : " ^4.0.0" ,
62- "rollup-plugin-polyfill-node" : " ^0.13.0" ,
6362 "rollup-plugin-svelte" : " ^5.1.1" ,
6463 "shiki" : " ^0.9.3" ,
65- "svelte" : " ^4 .0.0" ,
64+ "svelte" : " ^5 .0.0" ,
6665 "toml" : " ^3.0.0" ,
6766 "unified" : " ^9.1.0" ,
6867 "vfile" : " ^4.2.0"
Original file line number Diff line number Diff line change @@ -5,16 +5,10 @@ import sucrase from '@rollup/plugin-sucrase';
55import dts from 'rollup-plugin-dts' ;
66import { readFileSync } from 'fs' ;
77import { resolve } from 'path' ;
8- import polyfillNode from 'rollup-plugin-polyfill-node' ;
9-
10- const pkg = JSON . parse ( readFileSync ( resolve ( 'package.json' ) , 'utf-8' ) ) ;
118
129export default [
1310 {
1411 plugins : [
15- polyfillNode ( {
16- include : [ 'process' ] ,
17- } ) ,
1812 node ( { preferBuiltins : true } ) ,
1913 commonjs ( ) ,
2014 json ( ) ,
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ import type {
1414} from './types' ;
1515export * from './types' ;
1616
17- // import { join } from 'path ';
18- // import fs from 'fs';
17+ import { make_process } from './utils ' ;
18+
1919import { parse } from 'svelte/compiler' ;
2020import unified from 'unified' ;
2121import markdown from 'remark-parse' ;
@@ -371,8 +371,8 @@ const _compile = async (
371371 opts ?: MdsvexCompileOptions
372372) : Promise < PreprocessorReturn > => {
373373 if ( is_browser ) {
374- const process = await import ( 'process' ) ;
375- globalThis . process = process ;
374+ // @ts -ignore
375+ globalThis . process = make_process ( ) ;
376376 }
377377
378378 const preprocessor = mdsvex ( opts ) ;
Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ function extract_parts(nodes: Array<Element | Text>): Parts {
188188 module ?: any ;
189189 } ;
190190 try {
191+ // @ts -ignore
191192 result = parse ( nodes [ i ] . value as string ) ;
192193 } catch ( e ) {
193194 parts . html . push ( nodes [ i ] ) ;
Original file line number Diff line number Diff line change @@ -8,3 +8,57 @@ export function to_posix(_path: string): string {
88
99 return _path . replace ( / \\ / g, '/' ) ;
1010}
11+
12+ export function make_process ( ) {
13+ const process = {
14+ title : 'browser' ,
15+ argv : [ ] ,
16+ version : '' , // empty string to avoid regexp issues
17+ versions : {
18+ http_parser : '' ,
19+ node : '' ,
20+ v8 : '' ,
21+ ares : '' ,
22+ uv : '' ,
23+ zlib : '' ,
24+ brotli : '' ,
25+ modules : '' ,
26+ nghttp2 : '' ,
27+ napi : '' ,
28+ llhttp : '' ,
29+ openssl : '' ,
30+ icu : '' ,
31+ tz : '' ,
32+ unicode : '' ,
33+ } ,
34+ env : {
35+ NODE_ENV : 'production' ,
36+ } ,
37+ stdout : {
38+ isTTY : false ,
39+ } ,
40+ binding ( ) {
41+ return ;
42+ } ,
43+ cwd ( ) {
44+ return '/' ;
45+ } ,
46+ chdir ( ) {
47+ return ;
48+ } ,
49+ umask ( ) {
50+ return 0 ;
51+ } ,
52+ on : noop ,
53+ addListener : noop ,
54+ once : noop ,
55+ off : noop ,
56+ removeListener : noop ,
57+ removeAllListeners : noop ,
58+ emit : noop ,
59+ } ;
60+
61+ function noop ( ) { }
62+
63+ return process ;
64+ }
Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ const { children, ... rest } = $props ();
3+ </script >
4+
5+ <p >am layout</p >
6+ <p >metadata title: {rest .title }</p >
7+ {@render children ()}
Original file line number Diff line number Diff line change 11import adapter from '@sveltejs/adapter-auto' ;
22import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' ;
33import { mdsvex } from 'mdsvex' ;
4+
5+ import { join , dirname } from 'path' ;
6+ import { fileURLToPath } from 'url' ;
7+
8+ const __filename = fileURLToPath ( import . meta. url ) ;
9+ const __dirname = dirname ( __filename ) ;
10+
11+ const path_to_layout = join ( __dirname , './src/lib/Layout.svelte' ) ;
12+
413/** @type {import('@sveltejs/kit').Config } */
514const config = {
615 // Consult https://svelte.dev/docs/kit/integrations
@@ -14,7 +23,9 @@ const config = {
1423 adapter : adapter ( ) ,
1524 } ,
1625 extensions : [ '.svx' , '.svelte' ] ,
17- preprocess : mdsvex ( ) ,
26+ preprocess : mdsvex ( {
27+ layout : path_to_layout ,
28+ } ) ,
1829} ;
1930
2031export default config ;
You can’t perform that action at this time.
0 commit comments