Skip to content

Commit

Permalink
Revert "refactor: remove serialize-javascript (withastro#3278)" (with…
Browse files Browse the repository at this point in the history
…astro#3304)

* Revert "refactor: remove serialize-javascript (withastro#3278)"

This reverts commit 13c1f5f.

* Adds a changeset
  • Loading branch information
matthewp committed May 5, 2022
1 parent b5b95e4 commit 3d901ca
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-pianos-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes regression that prevented passing classes to islands
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"ci-info": "^3.3.0",
"common-ancestor-path": "^1.0.1",
"debug": "^4.3.4",
"devalue": "^2.0.1",
"diff": "^5.0.0",
"eol": "^0.9.1",
"es-module-lexer": "^0.10.5",
Expand Down Expand Up @@ -121,6 +120,7 @@
"resolve": "^1.22.0",
"rollup": "^2.70.2",
"semver": "^7.3.7",
"serialize-javascript": "^6.0.0",
"shiki": "^0.10.1",
"sirv": "^2.0.2",
"slash": "^4.0.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/astro/src/@types/serialize-javascript.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module 'serialize-javascript' {
export default function serialize(value: any): string;
}
8 changes: 8 additions & 0 deletions packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const ALWAYS_EXTERNAL = new Set([
...builtinModules.map((name) => `node:${name}`),
'@sveltejs/vite-plugin-svelte',
'micromark-util-events-to-acorn',
'serialize-javascript',
'node-fetch',
'prismjs',
'shiki',
Expand Down Expand Up @@ -92,6 +93,13 @@ export async function createVite(
css: {
postcss: astroConfig.style.postcss || {},
},
resolve: {
alias: {
// This is needed for Deno compatibility, as the non-browser version
// of this module depends on Node `crypto`
randombytes: 'randombytes/browser',
},
},
// Note: SSR API is in beta (https://vitejs.dev/guide/ssr.html)
ssr: {
external: [...ALWAYS_EXTERNAL],
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/runtime/server/hydration.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { AstroComponentMetadata, SSRLoadedRenderer } from '../../@types/astro';
import type { SSRElement, SSRResult } from '../../@types/astro';
import { hydrationSpecifier, serializeListValue } from './util.js';
import devalue from 'devalue';
import serializeJavaScript from 'serialize-javascript';

// Serializes props passed into a component so that they can be reused during hydration.
// The value is any
export function serializeProps(value: any) {
return devalue(value);
return serializeJavaScript(value);
}

const HydrationDirectives = ['load', 'idle', 'media', 'visible', 'only'];
Expand Down
10 changes: 2 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3d901ca

Please sign in to comment.