Skip to content

Instantly share code, notes, and snippets.

@xgqfrms
Last active May 23, 2023 09:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xgqfrms/7abacf4807cd00f046bc53fb6d9a4118 to your computer and use it in GitHub Desktop.
Save xgqfrms/7abacf4807cd00f046bc53fb6d9a4118 to your computer and use it in GitHub Desktop.
ESM export modules demos
// import { autoReport, manualReport, } from "./index.js";
import Metrics, { autoReport, manualReport, } from "./index.js";
if(autoReport && manualReport) {
console.log(`app ✅`);
autoReport();
manualReport();
console.log(`Metrics ✅`);
Metrics.autoReport();
Metrics.manualReport();
} else {
console.log(`app ❌`);
}
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="author" content="xgqfrms">
<meta name="generator" content="VS code">
<title>ESM export modules demos</title>
</head>
<body>
<header>
<h1>ESM export modules demos</h1>
</header>
<main>
<section>
<a href="https://feiqa.xgqfrms.xyz/index.html"></a>
</section>
<article></article>
</main>
<footer>
<p>copyright&copy; xgqfrms 2022</p>
</footer>
<script src="./app.js" type="module"></script>
</body>
</html>
const autoReport = () => console.log(`autoReport`);
const manualReport = () => console.log(`manualReport`);
const Metrics = {
autoReport,
manualReport,
};
export {
autoReport,
manualReport,
};
// export default Metrics;
export default {
...Metrics
};
@xgqfrms
Copy link
Author

xgqfrms commented Apr 22, 2023

test ok ✅

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment