Repository: holoviz/panel

Issue:
Failed to load module script
I'm testing out panel==1.0.0rc1 (and current `main`) branch.

I again get the MIMETYPE problem as in https://github.com/holoviz/panel/issues/4080

```python
import numpy as np
import matplotlib.pyplot as plt
import panel as pn

# import mimetypes
# mimetypes.add_type("application/javascript", ".js")

pn.extension(template='fast')

freq = pn.widgets.FloatSlider(
    name='Frequency', start=0, end=10, value=5
).servable(target='sidebar')

ampl = pn.widgets.FloatSlider(
    name='Amplitude', start=0, end=1, value=0.5
).servable(target='sidebar')

def plot(freq, ampl):
    fig = plt.figure()
    ax = fig.add_subplot(111)
    xs = np.linspace(0, 1)
    ys = np.sin(xs*freq)*ampl
    ax.plot(xs, ys)
    return fig

mpl = pn.pane.Matplotlib(
    pn.bind(plot, freq, ampl)
)

pn.Column(
    '# Sine curve', mpl
).servable(target='main')
```

![image](https://user-images.githubusercontent.com/42288570/234964738-86f30472-9efc-4325-89de-fc4e64390064.png)

```bash
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
fast-components.js:1  Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
script?theme=dark:74  Uncaught TypeError: window.fastDesignProvider is not a constructor
    at HTMLDocument.<anonymous> (script?theme=dark:74:25)
```

If I add 

```python
import mimetypes
mimetypes.add_type("application/javascript", ".js")
```

It works.

I'm on Windows 10 on a new laptop I received two weeks ago.



Discussion:
Odd, since we do have this in there already:

```
if mimetypes.types_map.get('.js') == 'text/plain':
    logger.warn(
        "Mimetype declaration for .js files was set to 'text/plain'. "
        "This will interefere with serving JS modules. Ensure your system "
        "does not override the mimetype declaration and/or contact your "
        "system administrator. "
    )
    mimetypes.add_type("application/javascript", ".js")
```

What does `mimetypes.types_map.get('.js')` return for you by default?
`application/javascript`.

![image](https://user-images.githubusercontent.com/42288570/235281236-d2444305-b918-48ab-8567-657fea956e26.png)

But it is an issue for me. Now I would like to test out awesome-panel.org locally on my windows laptop on panel==1.0.0rc1, but it fails.

![image](https://user-images.githubusercontent.com/42288570/235281281-8af3a40e-a011-4aa0-88da-adef199d86bb.png)

I also checked that `text/plain` is in fact what is returned by the server

![image](https://user-images.githubusercontent.com/42288570/235282591-16ab7656-b762-42ba-8cee-0b252b7a317a.png)

The issue is that when you first ask for `mimetypes.types_map.get(".js")` they are not giving you the setting in the windows registry. They are giving you some default value in the mimetypes module.

When something triggers the `init` function in the `mimetypes` module, then the values from the windows registry are read. And they are `text/plain`.

If I run

```python
import mimetypes

print(1, mimetypes.types_map.get(".js"))
mimetypes.init()
print(2, mimetypes.types_map.get(".js"))
mimetypes.add_type("application/javascript", ".js")
print(3, mimetypes.types_map.get(".js"))
```

Then I see

```bash
$ python script.py
1 application/javascript
2 text/plain
3 application/javascript
```

Resolving patch:
diff --git a/panel/io/resources.py b/panel/io/resources.py
--- a/panel/io/resources.py
+++ b/panel/io/resources.py
@@ -122,14 +122,7 @@ def conffilter(value):
 
 extension_dirs['panel'] = str(DIST_DIR)
 
-if mimetypes.types_map.get('.js') == 'text/plain':
-    logger.warn(
-        "Mimetype declaration for .js files was set to 'text/plain'. "
-        "This will interefere with serving JS modules. Ensure your system "
-        "does not override the mimetype declaration and/or contact your "
-        "system administrator. "
-    )
-    mimetypes.add_type("application/javascript", ".js")
+mimetypes.add_type("application/javascript", ".js")
 
 @contextmanager
 def set_resource_mode(mode):


Test patch: