- Start the server via
node server.js
. - Open http://localhost:3000.
- If the compilation cache leads to bad meta data in dynamic import, the message should only be logged once.
-
-
Save jkrems/6875ca31c00686c78f8119f59b852e05 to your computer and use it in GitHub Desktop.
Observe compilation cache collision
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.getElementById('target').innerText += `running ${import.meta.url}\n`; | |
if (import.meta.url.length < 100) { | |
import('./x/a.mjs'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
</head> | |
<pre id="target"></pre> | |
<script type="module" src="./a.mjs"></script> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createServer } = require('http'); | |
const { readFileSync } = require('fs'); | |
createServer((req, res) => { | |
const url = new URL(`http://${req.headers.host}/${req.url}`); | |
let filename = url.pathname.split('/').pop(); | |
let contentType = 'application/javascript'; | |
if (!filename.endsWith('.mjs')) { | |
filename = 'index.html'; | |
contentType = 'text/html'; | |
} | |
res.setHeader('Content-Type', contentType); | |
res.end(readFileSync(filename)); | |
}).listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment