Skip to content

Commit 44fc16c

Browse files
committed
cache build id fix
1 parent 3a2c8f9 commit 44fc16c

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

packages/ink/src/cache.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type {
88
} from './types';
99
import type { Event } from './EventEmitter';
1010
import type Builder from './document/Builder';
11-
import { serialize } from './helpers';
1211
//local
1312
import type { CacheOptions } from './types';
1413

@@ -29,10 +28,8 @@ export default function cache(options: CacheOptions) {
2928
//extract props and builder from params
3029
const props = (event.params.props || {}) as Hash;
3130
const builder = event.params.builder as Builder;
32-
//get id ie. abc123c
33-
const id = serialize(builder.document.source);
3431
//get cache file path ie. /path/to/docs/build/server/abc123c.js
35-
const cache = path.join(server, `${id}.js`);
32+
const cache = path.join(server, `${builder.document.id}.js`);
3633
//if cache file exists
3734
if (fs.existsSync(cache)) {
3835
//get the build object
@@ -50,10 +47,8 @@ export default function cache(options: CacheOptions) {
5047
emitter.on('build-server', (event: Event<string>) => {
5148
//extract builder from params
5249
const builder = event.params.builder as Builder;
53-
//get fs and id ie. abc123c
54-
const id = serialize(builder.document.source);
5550
//get cache file path ie. /path/to/docs/build/server/abc123c.js
56-
const cache = path.join(server, `${id}.js`);
51+
const cache = path.join(server, `${builder.document.id}.js`);
5752
//if cache file exists, send it
5853
if (fs.existsSync(cache)) {
5954
event.set(fs.readFileSync(cache, 'utf8'));
@@ -67,10 +62,8 @@ export default function cache(options: CacheOptions) {
6762
emitter.on('build-client', (event: Event<string>) => {
6863
//extract builder from params
6964
const builder = event.params.builder as Builder;
70-
//get fs and id ie. abc123c
71-
const id = serialize(builder.document.source);
7265
//get cache file path ie. /path/to/docs/build/client/abc123c.js
73-
const cache = path.join(client, `${id}.js`);
66+
const cache = path.join(client, `${builder.document.id}.js`);
7467
//if cache file exists, send it
7568
if (fs.existsSync(cache)) {
7669
event.set(fs.readFileSync(cache, 'utf8'));
@@ -81,10 +74,8 @@ export default function cache(options: CacheOptions) {
8174
emitter.on('build-styles', (event: Event<string>) => {
8275
//extract builder from params
8376
const builder = event.params.builder as Builder;
84-
//get fs and id ie. abc123c
85-
const id = serialize(builder.document.source);
8677
//get cache file path ie. /path/to/docs/build/client/abc123c.css
87-
const cache = path.join(client, `${id}.css`);
78+
const cache = path.join(client, `${builder.document.id}.css`);
8879
//if cache file exists, send it
8980
if (fs.existsSync(cache)) {
9081
event.set(fs.readFileSync(cache, 'utf8'));

0 commit comments

Comments
 (0)