Skip to content

Commit

Permalink
refactor: remove serialize-javascript (withastro#3278)
Browse files Browse the repository at this point in the history
* Replaced serialize-javascript with devalue

* Changeset
  • Loading branch information
JuanM04 authored May 3, 2022
1 parent 1de48ce commit 13c1f5f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-goats-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Internal: replaces `serialize-javascript` with `devalue`
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"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 @@ -120,7 +121,6 @@
"resolve": "^1.22.0",
"rollup": "^2.70.2",
"semver": "^7.3.7",
"serialize-javascript": "^6.0.0",
"shiki": "^0.10.1",
"shorthash": "^0.0.2",
"sirv": "^2.0.2",
Expand Down
3 changes: 0 additions & 3 deletions packages/astro/src/@types/serialize-javascript.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ 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 @@ -91,13 +90,6 @@ 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 serializeJavaScript from 'serialize-javascript';
import devalue from 'devalue';

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

const HydrationDirectives = ['load', 'idle', 'media', 'visible', 'only'];
Expand Down
10 changes: 8 additions & 2 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 13c1f5f

Please sign in to comment.