denoland / tic-tac-toe

A global, real-time multiplayer TicTacToe game for Deno 🦕
https://tic-tac-toe-game.deno.dev
MIT License
75 stars 8 forks source link

What is the purpose of import_map.json? #4

Open crowlsyong opened 1 year ago

crowlsyong commented 1 year ago

I'm just playing around with the project (thanks for putting it out) and I came across import_map.json. It seems a little redundant if there's already the deno.json, which in this case is importing the import map. Just wondering if there's something in the code which requires this configuration, if it's some kind of best practices, or something else?

Why not take import_map.json:

{
  "imports": {
    "🛠️/": "./utils/",
    "🏝️/": "./islands/",
    "🧱/": "./components/",

    "$fresh/": "https://deno.land/x/fresh@1.1.3/",
    "preact": "https://esm.sh/preact@10.11.0",
    "preact/": "https://esm.sh/preact@10.11.0/",
    "preact-render-to-string": "https://esm.sh/*preact-render-to-string@5.2.4",
    "@preact/signals": "https://esm.sh/*@preact/signals@1.0.3",
    "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.0.1",
    "twind": "https://esm.sh/twind@0.16.17",
    "twind/": "https://esm.sh/twind@0.16.17/",
    "$std/": "https://deno.land/std@0.175.0/"
  }
}

and pop it into to deno.json such that it deno.json looks like:

{
  "tasks": {
    "start": "deno run -A --unstable --watch=static/,routes/ dev.ts"
  },
  "imports": {
    "🛠️/": "./utils/",
    "🏝️/": "./islands/",
    "🧱/": "./components/",

    "$fresh/": "https://deno.land/x/fresh@1.1.3/",
    "preact": "https://esm.sh/preact@10.11.0",
    "preact/": "https://esm.sh/preact@10.11.0/",
    "preact-render-to-string": "https://esm.sh/*preact-render-to-string@5.2.4",
    "@preact/signals": "https://esm.sh/*@preact/signals@1.0.3",
    "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.0.1",
    "twind": "https://esm.sh/twind@0.16.17",
    "twind/": "https://esm.sh/twind@0.16.17/",
    "$std/": "https://deno.land/std@0.175.0/"
  }
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "preact"
  }
}