-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛Cache issue with identical files with relative import #933
Comments
I've noticed that I get similar behavior only when serving This is currently the only reason I am not adopting Parcel for bigger projects. I LOVE what you guys are doing with Parcel 😄 so I hope this gets resolved soon! |
could be related to #551 |
@eXon I reproduced your issue (I did have to tweak the I ruled out the Parcel I de-minified require = function(r, e, n) {
var t = "function" == typeof require && require;
function o(n, u) {
if (!e[n]) {
if (!r[n]) {
var i = "function" == typeof require && require;
if (!u && i) return i(n, !0);
if (t) return t(n, !0);
var f = new Error("Cannot find module '" + n + "'");
throw f.code = "MODULE_NOT_FOUND", f
}
l.resolve = function(e) {
return r[n][1][e] || e
};
var c = e[n] = new o.Module(n);
r[n][0].call(c.exports, l, c, c.exports)
}
return e[n].exports;
function l(r) {
return o(l.resolve(r))
}
}
o.isParcelRequire = !0, o.Module = function(r) {
this.id = r, this.bundle = o, this.exports = {}
}, o.modules = r, o.cache = e, o.parent = t;
for (var u = 0; u < n.length; u++) o(n[u]);
return o
}({
9: [function(require, module, exports) {
module.exports = function() {
console.log("FOLDER1!!!")
};
}, {}],
3: [function(require, module, exports) {
var r = require("../");
r();
}, {
"../": 9
}],
11: [function(require, module, exports) {
module.exports = function() {
console.log("FOLDER2!!!")
};
}, {}],
13: [function(require, module, exports) {
module.exports = function() {
console.log("FOLDER3!!!")
};
}, {}],
7: [function(require, module, exports) {
var global = (1, eval)("this");
var e = (0, eval)("this"),
r = require("../");
r(), e.different = !0;
}, {
"../": 13
}],
1: [function(require, module, exports) {
require("./folder1/subfolder"), require("./folder2/subfolder"), require("./folder3/subfolder");
}, {
"./folder1/subfolder": 3,
"./folder2/subfolder": 3,
"./folder3/subfolder": 7
}]
}, {}, [1])
//# sourceMappingURL=/dist/index.map Looks like at the bottom both I'm going to do some more digging to see what part of Parcel could be causing the issue... |
The correct thing would be: 9: [function(require, module, exports) {
module.exports = function() {
console.log("FOLDER1!!!")
};
}, {}],
3: [function(require, module, exports) {
var r = require("../");
r();
}, {
"../": 9
}],
<some id>: [function(require, module, exports) {
var r = require("../");
r();
}, {
"../": 11
}],
11: [function(require, module, exports) {
module.exports = function() {
console.log("FOLDER2!!!")
};
}, {}],
13: [function(require, module, exports) {
module.exports = function() {
console.log("FOLDER3!!!")
};
}, {}],
7: [function(require, module, exports) {
var global = (1, eval)("this");
var e = (0, eval)("this"),
r = require("../");
r(), e.different = !0;
}, {
"../": 13
}],
1: [function(require, module, exports) {
require("./folder1/subfolder"), require("./folder2/subfolder"), require("./folder3/subfolder");
}, {
"./folder1/subfolder": 3,
"./folder2/subfolder": <some id>,
"./folder3/subfolder": 7
}] (note where I added elements referencing |
Looks like the culprit might be the following: In this case, both Then, when Proposed fix: deduplication check both the generated JS AND the absolute dependency paths. |
* Apply workaround for parcel-bundler/parcel#933
Related to #1152. |
This is also true for module imports not only for relative imports. import { httpPost, httpPut } from '@cerebral/http/operators'
import { redirectToSignal } from '@cerebral/router/operators' are getting the same index: "@cerebral/http/operators":67,"@cerebral/router/operators":67, |
… absolute dependency paths (#1011)
…differences in absolute dependency paths (parcel-bundler#1011)
… absolute dependency paths (#1011)
… absolute dependency paths (#1011)
It seems like there is a cache issue when you have two identical files in two different folder, but they have relative import path. As an example, I have
folder1/subFolder/index.js
andfolder2/subFolder/index.js
importing../index.js
. However,folder1/index.js
andfolder2/index.js
are two different files.It looks like Parcel is thinking they are both the same but they are not because of the relative path.
😯 Current Behavior
Here is a proof of concept: https://github.com/exon/parcel-cache-bug
If you build and run it, it will print:
🤔 Expected Behavior
However, the expected result were:
💁 Possible Solution
I don't know the Parcel cache system but I guess it should transform the import path into something more absolute starting from the project root.
The text was updated successfully, but these errors were encountered: