lukeed / sirv

An optimized middleware & CLI application for serving static files~!
MIT License
1.07k stars 58 forks source link

Sirv cuts the file if its size increases #131

Closed istudyatuni closed 2 years ago

istudyatuni commented 2 years ago

Hello! Here is the minimal reproduction for this. Briefly: after adding some code to the file and reloading page, the file is cropped to the old size.

sirv, 2.0.2

For example, I have

// main.js
document.body.innerHTML = 'hi'

function longFunc() {
  let a = [[4, 5, 6], 6, 7, [0, 3]].flat().filter(e => e).map(e => e * 2).flat()
}

longFunc()

and include it

<!-- index.html -->
<script type="module" src="main.js"></script>

if after first page load I change indentations in main.js

document.body.innerHTML = 'hi'

function longFunc() {
  let a = [[4, 5, 6], 6, 7, [0, 3]]
    .flat()
    .filter(e => e)
    .map(e => e * 2)
    .flat()
}

longFunc()

and reload page, sirv will not return end of main.js:

document.body.innerHTML = 'hi'

function longFunc() {
  let a = [[4, 5, 6], 6, 7, [0, 3]]
    .flat()
    .filter(e => e)
    .map(e => e * 2)
    .

Sorry for my English

istudyatuni commented 2 years ago

Hmm, I think it's because I didn't add --dev

lukeed commented 2 years ago

English is great 👍 And yes, this needs —dev to keep interacting with the filesystem. Without it, it’s serving from memory

istudyatuni commented 2 years ago

English is great

I checked first half with DeepL :)