<p dir="auto">Per <a href="https://discord.com/channels/684898665143206084/684898665151594506/961668940680011796" rel="nofollow">this convo</a>, given the following <code class="notranslate">deno.json</code>:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;compilerOptions&quot;: {
    &quot;jsx&quot;: &quot;react-jsx&quot;,
    &quot;jsxImportSource&quot;: &quot;https://esm.sh/preact&quot;
  },
  &quot;tasks&quot;: {
    &quot;test&quot;: &quot;deno run test.jsx&quot;,
    &quot;bundle&quot;: &quot;deno bundle test.jsx test.js&quot;
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"compilerOptions"</span>: {
    <span class="pl-ent">"jsx"</span>: <span class="pl-s"><span class="pl-pds">"</span>react-jsx<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"jsxImportSource"</span>: <span class="pl-s"><span class="pl-pds">"</span>https://esm.sh/preact<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"tasks"</span>: {
    <span class="pl-ent">"test"</span>: <span class="pl-s"><span class="pl-pds">"</span>deno run test.jsx<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"bundle"</span>: <span class="pl-s"><span class="pl-pds">"</span>deno bundle test.jsx test.js<span class="pl-pds">"</span></span>
  }
}</pre></div>
<p dir="auto">and the following <code class="notranslate">test.jsx</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="console.log(&lt;div&gt;&lt;/div&gt;)

export {}"><pre class="notranslate"><code class="notranslate">console.log(&lt;div&gt;&lt;/div&gt;)

export {}
</code></pre></div>
<p dir="auto">running <code class="notranslate">deno task test</code> returns as expected:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Task test deno run test.jsx
{
  type: &quot;div&quot;,
  props: {},
  key: undefined,
  ref: undefined,
  __k: null,
  __: null,
  __b: 0,
  __e: null,
  __d: undefined,
  __c: null,
  __h: null,
  constructor: undefined,
  __v: -1,
  __source: undefined,
  __self: undefined
}"><pre class="notranslate"><code class="notranslate">Task test deno run test.jsx
{
  type: "div",
  props: {},
  key: undefined,
  ref: undefined,
  __k: null,
  __: null,
  __b: 0,
  __e: null,
  __d: undefined,
  __c: null,
  __h: null,
  constructor: undefined,
  __v: -1,
  __source: undefined,
  __self: undefined
}
</code></pre></div>
<p dir="auto">but running <code class="notranslate">deno task bundle</code> throws an error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Task bundle deno bundle test.jsx test.js
Check file:///........................../test.jsx
Bundle file:///........................./test.jsx
error: Unable to output during bundling.

Caused by:
    0: load_transformed failed
    1: failed to analyze module
    2: failed to resolve https://esm.sh/preact/jsx-runtime from file:///........................./test.jsx
    3: Cannot resolve &quot;https://esm.sh/preact/jsx-runtime&quot; from &quot;file:///........................./test.jsx&quot;."><pre class="notranslate"><code class="notranslate">Task bundle deno bundle test.jsx test.js
Check file:///........................../test.jsx
Bundle file:///........................./test.jsx
error: Unable to output during bundling.

Caused by:
    0: load_transformed failed
    1: failed to analyze module
    2: failed to resolve https://esm.sh/preact/jsx-runtime from file:///........................./test.jsx
    3: Cannot resolve "https://esm.sh/preact/jsx-runtime" from "file:///........................./test.jsx".
</code></pre></div>
<p dir="auto">It's pointless if we have a security system and end up adding too many permissions because a single file (or library) wants a "read permission".</p>
<ol dir="auto">
<li>deno.json / import_map.json</li>
</ol>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;imports&quot;: {
    &quot;dotenv&quot;: &quot;https://deno.land/x/dotenv@v3.2.0/mod.ts&quot;
  },
  &quot;permissions&quot;: {
    &quot;dotenv&quot;: [&quot;allow-read&quot;]
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"imports"</span>: {
    <span class="pl-ent">"dotenv"</span>: <span class="pl-s"><span class="pl-pds">"</span>https://deno.land/x/dotenv@v3.2.0/mod.ts<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"permissions"</span>: {
    <span class="pl-ent">"dotenv"</span>: [<span class="pl-s"><span class="pl-pds">"</span>allow-read<span class="pl-pds">"</span></span>]
  }
}</pre></div>
<ol start="2" dir="auto">
<li>Using the URL to give permissions</li>
</ol>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { serve } from 'https://deno.land/std@0.140.0/http/server.ts?allow-net'"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">serve</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'https://deno.land/std@0.140.0/http/server.ts?allow-net'</span></pre></div>
<ol start="3" dir="auto">
<li>Using comments</li>
</ol>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { config } from 'https://deno.land/x/dotenv/mod.ts'

// @deno-perm-allow-read loading .env file
config({ export: true })

// or

// @deno-perm-allow-net=10.0.0.13 only access this network
serve((_req) =&gt; {
  return new Response('Hello World!', {
    headers: { 'content-type': 'text/plain' }
  })
})"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">config</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'https://deno.land/x/dotenv/mod.ts'</span>

<span class="pl-c">// <span class="pl-k">@deno</span>-perm-allow-read loading .env file</span>
<span class="pl-en">config</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">export</span>: <span class="pl-c1">true</span> <span class="pl-kos">}</span><span class="pl-kos">)</span>

<span class="pl-c">// or</span>

<span class="pl-c">// <span class="pl-k">@deno</span>-perm-allow-net=10.0.0.13 only access this network</span>
<span class="pl-en">serve</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">_req</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-smi">Response</span><span class="pl-kos">(</span><span class="pl-s">'Hello World!'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
    <span class="pl-c1">headers</span>: <span class="pl-kos">{</span> <span class="pl-s">'content-type'</span>: <span class="pl-s">'text/plain'</span> <span class="pl-kos">}</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span></pre></div>