fastdom
fastdom copied to clipboard
ESM/ES6 module format
Please provide esm format distribution for importing in browser directly without any module loader.
Not sure what this means but happy to accept a PR
On Wed, 14 Jul 2021, 16:48 cdalexndr, @.***> wrote:
Please provide esm format distribution for importing in browser directly without any module loader.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wilsonpage/fastdom/issues/124, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZFBZOIK2TPYX35GBNIJTTXWWS7ANCNFSM5ALXNBAA .
Is this still relevant/needed? Maybe can offer some help.
Not sure what this means but happy to accept a PR …
It lets you do this:
<script type="module">
import { FastDom } from '/path/to/fastdom';
…
EDIT: in JS you use the export
keyword to allow import to import it like this
// file1.js
export const a = "A!";
export const b = "B :D";
export const c = "C :)";
export const d = "D :3";
// file2.js
// this is just an example of ways import can be used
import {a, b}, * from 'file1.js';
…
I believe that defeates the purpose of the library. As a module it would be encapsulated and other code could not reach it, but this is meant to be a global singleton.
I believe that defeates the purpose of the library. As a module it would be encapsulated and other code could not reach it, but this is meant to be a global singleton.
Every ESM module works like a singleton, so no problem.
Every ESM module works like a singleton, so no problem.
@VitorLuizC Do not make assumptions about whether it is a problem or not. Your personal perspective and needs do not apply to everone. Web project vary and it is an issue if you don't have modules all the way through. Please try to be more open minded.
Right now it is one global instance accessible from every scope which some may require if they can't/won't rewrite their codebase.
<head>
<script src="./js/fastdom.min.js"></script>
<script type="module">
/* use within a (new) module */
console.log( window.fastdom );
</script>
</head>
<body>
<script>
/* use within "old" code */
console.log( window.fastdom );
</script>
</body>
Anyway you can (already) use this as module.
import "./fastdom.min.js"
console.log(fastdom);