deno_dir reorg

Created on 26 Jan 2019  ยท  11Comments  ยท  Source: denoland/deno

Currently my DENO_DIR looks like this

/Users/rld/.deno/
โ”œโ”€โ”€ bin
โ”‚ย ย  โ””โ”€โ”€ deno
โ”œโ”€โ”€ deno_history.txt
โ”œโ”€โ”€ deps
โ”‚ย ย  โ”œโ”€โ”€ http
โ”‚ย ย  โ””โ”€โ”€ https
โ”‚ย ย      โ””โ”€โ”€ deno.land
โ”‚ย ย          โ””โ”€โ”€ x
โ”‚ย ย              โ”œโ”€โ”€ fs
โ”‚ย ย              โ”‚ย ย  โ”œโ”€โ”€ path
โ”‚ย ย              โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ constants.ts
โ”‚ย ย              โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ interface.ts
โ”‚ย ย              โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ mod.ts
โ”‚ย ย              โ”‚ย ย  โ””โ”€โ”€ path.ts
โ”‚ย ย              โ”œโ”€โ”€ http
โ”‚ย ย              โ”‚ย ย  โ”œโ”€โ”€ file_server.ts
โ”‚ย ย              โ”‚ย ย  โ”œโ”€โ”€ http.ts
โ”‚ย ย              โ”‚ย ย  โ”œโ”€โ”€ http_status.ts
โ”‚ย ย              โ”‚ย ย  โ””โ”€โ”€ mod.ts
โ”‚ย ย              โ”œโ”€โ”€ io
โ”‚ย ย              โ”‚ย ย  โ”œโ”€โ”€ bufio.ts
โ”‚ย ย              โ”‚ย ย  โ””โ”€โ”€ util.ts
โ”‚ย ย              โ”œโ”€โ”€ media_types
โ”‚ย ย              โ”‚ย ย  โ”œโ”€โ”€ db_1.37.0.json
โ”‚ย ย              โ”‚ย ย  โ”œโ”€โ”€ deps.ts
โ”‚ย ย              โ”‚ย ย  โ””โ”€โ”€ mod.ts
โ”‚ย ย              โ”œโ”€โ”€ testing
โ”‚ย ย              โ”‚ย ย  โ””โ”€โ”€ mod.ts
โ”‚ย ย              โ””โ”€โ”€ textproto
โ”‚ย ย                  โ””โ”€โ”€ mod.ts
โ””โ”€โ”€ gen
    โ”œโ”€โ”€ 0021b0a2c686fac4019811b5c93189d5a9777de9.js
    โ”œโ”€โ”€ 0021b0a2c686fac4019811b5c93189d5a9777de9.js.map
    โ”œโ”€โ”€ 00962035aaaf777be1877911f2aa53c5c8af45bf.js
    โ”œโ”€โ”€ 00962035aaaf777be1877911f2aa53c5c8af45bf.js.map
    โ”œโ”€โ”€ 0d6e3626582696335cb96a79fdb9ec3f3bfa1331.js
    โ”œโ”€โ”€ 0d6e3626582696335cb96a79fdb9ec3f3bfa1331.js.map
    โ”œโ”€โ”€ 11bd9864a0cb45a60ba337fc688aba386f587a1f.js
    โ”œโ”€โ”€ 11bd9864a0cb45a60ba337fc688aba386f587a1f.js.map

Remote code is cached in ~/.deno/deps/https or ~/.deno/deps/http and generated javascript is stored under its content hash in ~/.deno/gen.

I think we should combine the generated and remote-cached directories so that the generated content lives belong the remote-cached typescript:

~/.deno/https/deno.land/x/fs/path.ts # cached from https://deno.land/x/fs/path.ts
~/.deno/https/deno.land/x/fs/path.js # generated
~/.deno/https/deno.land/x/fs/path.js.map # generated

This coincides better with how typescript normally operates

All 11 comments

@ry this is potentially problematic if a user happens to have two files with the same name of different extensions. Adopting this design seems to go against the original argument of requiring extensions.

On the other hand, under our current design, if we are dropping hash from the filenames, are we adopting alternative approaches tell the versioning of source TypeScript code (i.e. some changes take place)?

@zzz6519003 Deno is built on top of V8 which includes support to native Promises years ago. Deno async API depends on Promises.

@kevinkassimo People should not be using the same name with different extensions. I think it's fine to just exit and print a helpful warning.

Adopting this design seems to go against the original argument of requiring extensions.

I don't think so. The imports are still explicit.

The benefit of this design is so humans can inspect the DENO_DIR without the aid of software...

@ry I'm slightly worried that this basically poses extra restrictions on filenames from Deno that goes beyond the requirement of JavaScript itself. Personally I feel this counts as a prohibiting "magic" that is opposite of index.js but also troubling. Also, it is possible that people would do something like prettier.js as the implementation and uses prettier.ts to add type annotation wrappers on exported APIs...

As to inspections of the compiled code, we can probably instead add a flag on Deno that given a TypeScript file, (optionally compiles and) emits filenames that point to the code in $DENO_DIR/gen.

@kevinkassimo Yeah... good point... I will think on it more.

@ry Random thoughts, I think another way we could redesign the layout of gen/ instead so that it mirrors the structure of deps/, which makes it also very easy to find the compiled output (but we still need to find some places to store the hashes)

@kevinkassimo I think your idea of some tooling could work too... Something like this?

> deno info myfile.ts
compiled javascript: ~/.deno/gen/123513123123.js
source map: ~/.deno/gen/123513123123.js.map
>

@ry This design looks okay to me -- except that info might need to be a flag like --info or -I...

Sorry, I wasn't paying attention to this.

While we don't have it enabled again, if we do ever run JavaScript through the compiler to type check it, we would want to use what is emitted. For example you can put CommonJS or AMD modules in and get ESM out via the compiler.

One additional other thought, just so that we don't have to remap anything and could keep the output fine is:

~/.deno/https/deno.land/x/fs/path.ts # cached from https://deno.land/x/fs/path.ts
~/.deno/https/deno.land/x/fs/.gen/path.js # generated
~/.deno/https/deno.land/x/fs/.gen/path.js.map # generated

Then we wouldn't need to worry about any conflicts and it is still quite clear how the source and output files are related.

Can we close this issue in favor of #2057?

Yes - thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

somombo picture somombo  ยท  3Comments

kitsonk picture kitsonk  ยท  3Comments

davidbarratt picture davidbarratt  ยท  3Comments

ry picture ry  ยท  3Comments

justjavac picture justjavac  ยท  3Comments