Repository navigation
Version Packages - #191
Version Packages#191
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/esrap/c/1abc1e24a82c60399356b2df2864dc2db6084ee5Open in |
Rich-Harris
left a comment
There was a problem hiding this comment.
huh — turns out #124 doesn't work any more. Something important drifted between when it was opened and when it was merged
|
Alright, investigated. Not entirely sure what changed to cause the repro to fail, but I do at least know how to fix it. It was failing because this code in the repro... export async function load () {
const loaded = await files['../../package.json']()
state = loaded.default
}...was being transformed thusly... export async function load() {
const loaded = (await $.track_reactivity_loss(files['../../package.json']()))();
$.set(state, loaded.default, true);
}...and the outer call expression was unmapped. Fixing it requires two changes — one in Svelte... diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/AwaitExpression.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/AwaitExpression.js
index 9fcc33287c..a0aec96bf1 100644
--- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/AwaitExpression.js
+++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/AwaitExpression.js
@@ -18,7 +18,7 @@ export function AwaitExpression(node, context) {
// in dev, note which values are read inside a reactive expression,
// but don't track them
else if (dev && !is_ignored(node, 'await_reactivity_loss')) {
- return b.call(b.await(b.call('$.track_reactivity_loss', argument)));
+ return b.call({ ...node, argument: b.call('$.track_reactivity_loss', argument) });
}
return argument === node.argument ? node : { ...node, argument };...and one here: diff --git a/src/languages/ts/index.js b/src/languages/ts/index.js
index 509e3b2..bdaa845 100644
--- a/src/languages/ts/index.js
+++ b/src/languages/ts/index.js
@@ -676,6 +676,13 @@ export default (options = {}) => {
* @param {Context} context
*/
'CallExpression|NewExpression': (node, context) => {
+ const loc = node.loc ?? node.callee.loc;
+
+ if (loc) {
+ const { line, column } = loc.start;
+ context.location(line, column);
+ }
+
if (node.type === 'NewExpression') {
write_keyword(context, node, 'new', ' ');
}Notably, whether or not we add a mapping for the end of a keyword has no bearing on the matter, so I now think we should revert #124 so as to preserve as much information as possible. |
d1d9e25 to
93051ab
Compare
93051ab to
1abc1e2
Compare
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
[email protected]
Patch Changes