Deno: Compiler APIs should allow a `reload` option to cache bust

Created on 13 May 2020  路  6Comments  路  Source: denoland/deno

Currently there is no way to internally cache bust with the compiler APIs, only if Deno is invoked with --reload will the compiler APIs cache bust.

cli feat

Most helpful comment

Ref #4782
Ref #4743

This is on my radar

All 6 comments

Ref #4752

Ref #4782
Ref #4743

This is on my radar

I tried this with Deno 1.5.3. I can confirm that the original complaint was fixed.

However, there are a couple of new problems.

  1. The source maps are broken. When I ask for source map files, the map files are still created. However, the .js files no longer point to the map files, so I can't use the source maps.

  2. The file names changed. (I wish I could be 100% certain of the old behavior.) When I compile /home/phil/cpp_alert_server/deno/admin/ts/cvs_nq_update.ts I get file:///home/phil/cpp_alert_server/deno/admin/ts/cvs_nq_update.ts.js and file:///home/phil/cpp_alert_server/deno/admin/ts/cvs_nq_update.ts.js.map as output files. I.e. it added ".js" and ".js.map" rather than replacing ".ts" with the new extension. That's not terrible, but I would like to know the intent and if we think this is the final form.

Thanks!

EDIT: The map file is broken. Now it starts with

{"version":3,"file":"","sourceRoot":"","sources":["file:///home/phil/cpp_alert_server/deno/admin/ts/cvs_nq_update.ts"],"names":[],"mappings":"AAIA,SAAS,

I don't know what used to be in there. (I wish I'd saved a copy of the old result or the old Deno executable.) But source maps used to work in Deno 1.5.1. So they must have been relative paths. I'm running the browser on a totally different machine than the Deno server, no file sharing.

Regarding source maps, they never point at the emitted files, they point back at the source files. Yes previously they could be non-deterministic. Now they point at the absolute URI of the source. It is worth discussing more, but we would likely not address it until #4752.

Regarding the name changes, it is intentional, again, because there are all sorts of scenarios where it could be broken if we simply don't append the extension. There is no such thing as a "final form" with an unstable API. 馃槃

There is no such thing as a "final form" with an unstable API. 馃槃

Understood. I'm trying to decide how much to fix on my side and how much to wait for.

Here's my very quick and dirty work around to get source maps working again. I need to do something better, but this works for now and it explains what changed in Deno.

                    if (compiledFilePieces.isJs) {
                      body += "\n//# sourceMappingURL=" + withoutPath + ".js.map";
                    } else if (compiledFilePieces.isJsMap) {
                      body = body.replace(/(?<=\[")file:\/.*(?=\/[^\/]+.ts"\])/, ".");
                    }

In a *.ts.js file append something like //# sourceMappingURL=cvs_nq_update.js.map. In a *.ts.js.map file replace something like ["file:///home/phil/cpp_alert_server/deno/admin/ts/cvs_nq_update.ts"] with a relative URL like ["./cvs_nq_update.ts"].

Was this page helpful?
0 / 5 - 0 ratings

Related issues

somombo picture somombo  路  3Comments

justjavac picture justjavac  路  3Comments

doutchnugget picture doutchnugget  路  3Comments

kyeotic picture kyeotic  路  3Comments

ry picture ry  路  3Comments