Parcel: caching sometimes cause wrong file linked

Created on 20 Jun 2018  路  5Comments  路  Source: parcel-bundler/parcel

馃悰 bug report

馃帥 Configuration (.babelrc, package.json, cli command)

// build.js
const Bundler = require("parcel-bundler");

const entries = [
    "./public/src/main.js",
    "./public/src/control.js",
    "./public/src/console.js"
]

const bundler = new Bundler(entries, {
    outDir: "./public/dist",
    publicUrl: "/dist",
    cache: process.env.NODE_ENV !== "production",
    minify: process.env.NODE_ENV === "production",
    watch: process.env.NODE_ENV !== "production"
});

bundler.bundle()

馃 Expected Behavior

everything works fine

馃槸 Current Behavior

Sometimes when caching enabled wrong files are imported.

馃捇 Code Sample

// one.js
export default 1;

// two.js
export default 2;

// main.js
import one from "./one";
import two from "./two";

console.log(one); // 2
console.log(two); // 2

This is the minimal example that demonstrate my problem (this might not reproduce the problem). In my case, I'm making a game which you could press button 1 and shoot toxic bullets or press button 2 to shoot laser bullets. Sometimes when caching enabled you shoot toxic bullet no matter you press button 1 or 2 (in other conditions that the build went wrong mostly the app would just crash, logging something's not defined), but disabling caching and build again without changing any code the game works perfectly normal.

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.9.2 (happens with previous versions too)
| Node | 10.4.1
| npm/Yarn | 1.7.0
| Operating System | macOS High Sierra 10.13.4

Bug

Most helpful comment

caching introduce many problem I think. the output file hash has changed, but the references in index.html are still the old ones. I have to disable the cache or remove the cache directory manually.

All 5 comments

caching introduce many problem I think. the output file hash has changed, but the references in index.html are still the old ones. I have to disable the cache or remove the cache directory manually.

Yes, I definitely have the issue with incorrect css fingerprint being used in the index.html file. Passing --no-cache on build makes the issue disappear.

Should be fixed by 1bd5fcc9038e47fcc233543e32903b6e02aeb3a1. Released in v1.9.3.

Upgrading to 1.9.3 seems to have fixed this somewhat but I'm still seeing problems with the .map files

Strangely, this problem persists after deleting .cache and rebuilding. Perhaps it is a different cache related issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

urbanhop picture urbanhop  路  3Comments

algebraic-brain picture algebraic-brain  路  3Comments

donaldallen picture donaldallen  路  3Comments

dotdash picture dotdash  路  3Comments

davidnagli picture davidnagli  路  3Comments