question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

a pure es module import would be fantastic

See original GitHub issue

I frequently like to use dat.gui in small experiments on my local machine. I’d love to not need to have a package manager to install/build/configure dat.gui for these fast experiments.

Here is how I’d like to use dat.gui:

<script type="module">
    import dat from 'https://cdn.jsdelivr.net/gh/dataarts/dat.gui@0.7.7/src/dat/index.js'

    const obj = { x: 40, y: 100 }

    const gui = new dat.GUI()
    gui.add(obj, 'x')
    gui.add(obj, 'y') 
</script>

Right now this snippet won’t work because the source code doesn’t include the file extension when it imports modules (.js)

This would be really amazing for prototyping, just being able to wire up this usage of dat.gui without all the ceremony of needing node, npm, bundling tools, bundling config, etc.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mreinsteincommented, May 28, 2020

I’d prefer not to drop that backward-compatibility without a compelling reason.

Yeah I’m not asking anyone to drop backwards compatibility. 😃 I’m just asking if we could provide a “pure” es modules based thing alongside all of our existing stuff, which would enable me to drop node/npm/package.json/build tools/legacy module formats, etc.

with the advent of good browser support + deno, now seems like a prime time to start re-evaluating the way we’ve been doing things for the last decade of javascript.

1reaction
mreinsteincommented, May 29, 2020

regarding the original question of the issue, we do provide a “pure ES module import” as explained above

sounds reasonable, thanks for your time!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Import ES module in Next.js ERR_REQUIRE_ESM
I think the problem is that Webpack (or Babel) is transforming all import s to require() s but ky is a pure ES...
Read more >
Publishing NPM Packages as Native ES Modules - Medium
Basically, for tree shaking to work with webpack, you must be using es imports and exports, and your code must consist of pure...
Read more >
Node Modules at War: Why CommonJS and ES ... - Code Red
ESM scripts can import CJS scripts, but only by using the “default import” syntax import _ from 'lodash' , not the “named import”...
Read more >
How to Dynamically Import ECMAScript Modules
ECMAScript (aka ES2015, or ES) modules are a way to organize cohesive ... Because the import(path) returns a promise, it fits great with...
Read more >
Alternatives to __dirname in Node.js with ES modules
ES modules with Node.js add a new, standardized global that allows your code to run anywhere, locally or remotely.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found