Skip to content

Commit

Permalink
fix: remove "stream" dependency in browser bundles, #396
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Oct 3, 2021
1 parent 68c4cfc commit 3b5eb66
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
31 changes: 16 additions & 15 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ const treeshake = {
propertyReadSideEffects: false
}
const input = './src/liquid.ts'
const replaceFS = {
include: './src/liquid-options.ts',
delimiters: ['', ''],
'./fs/node': './fs/browser'
}
const replaceStream = {
include: './src/render/render.ts',
delimiters: ['', ''],
'../emitters/streamed-emitter': '../emitters/streamed-emitter-browser'
}

const nodeCjs = {
output: [{
Expand Down Expand Up @@ -65,11 +75,8 @@ const browserEsm = {
}],
external: ['path', 'fs'],
plugins: [
replace({
include: './src/liquid-options.ts',
delimiters: ['', ''],
'./fs/node': './fs/browser'
}),
replace(replaceFS),
replace(replaceStream),
typescript({
tsconfigOverride: {
include: [ 'src' ],
Expand All @@ -94,11 +101,8 @@ const browserUmd = {
banner
}],
plugins: [
replace({
include: './src/liquid-options.ts',
delimiters: ['', ''],
'./fs/node': './fs/browser'
}),
replace(replaceFS),
replace(replaceStream),
typescript({
tsconfigOverride: {
include: [ 'src' ],
Expand All @@ -122,11 +126,8 @@ const browserMin = {
sourcemap
}],
plugins: [
replace({
include: './src/liquid-options.ts',
delimiters: ['', ''],
'./fs/node': './fs/browser'
}),
replace(replaceFS),
replace(replaceStream),
typescript({
tsconfigOverride: {
include: [ 'src' ],
Expand Down
12 changes: 12 additions & 0 deletions src/emitters/streamed-emitter-browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Emitter } from './emitter'

export class StreamedEmitter implements Emitter {
public buffer = '';
public stream: NodeJS.ReadableStream = null as any
constructor () {
throw new Error('streaming not supported in browser')
}
public write: (html: any) => void
public error: (err: Error) => void
public end: () => void
}

0 comments on commit 3b5eb66

Please sign in to comment.