Automatic processing JavaScript redirects don’t work
Quick, short summary:
If you using default exports and redirects in JavaScripts CodeKit doesn’t start processing on file changes (in CodeKit Version 3.8.2 Build 29156)
Exact steps to reproduce:
Create a script with a default export, e.g. _export.js:
export default answer = 42;
Redirect the default in another script, e.g. _redirect.js:
export {default} from "_export.js";
Import the redirected default in a third script, import.js:
import something from "_redirect.js";
console.log(something);
Set ES6 bundling format of import.js to CommonJS.
If you then modify the script with the default export (e.g. change answer to 43), CodeKit doesn’t process the output.
Yea, I see why. CodeKit walks files looking for import statements to determine dependency links. There is no import between _export.js and _redirect.js, so CodeKit is not aware that those two files are linked.
How common is this approach?
I don’t know, how common that feature is, but the MDN docs list this approach:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export#Module_Redirects
There is a workaround for CodeKit by first importing and then exporting, but I think it would be nice to support the “official” pattern.
Workaround:
import something from "_export.js";
export default something;
Sure, I just wasn’t aware of the pattern. It seems that “export ____ from” can be considered an import statement for linking purposes. If “export” appears without “from”, then it’s not.
Sent from my iPhone
On Mar 25, 2019, at 09:49, Karsten Müller [email protected] wrote:
I don’t know, how common that feature is, but the MDN docs list this approach:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export#Module_Redirects
There is a workaround for CodeKit by first importing and then exporting, but I think it would be nice to support the “official” pattern.
Workaround:
import something from "_export.js"; export default something; — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.