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.

ES6 Module Support?

See original GitHub issue

I am trying to use this library in a polymer 3 typescript project. Would it be possible to add support for es6 modules?

Code

import dayjs from 'dayjs';

Result

my-app.ts:73 One or more components failed to load SyntaxError: The requested module '../node_modules/dayjs/dayjs.min.js' does not provide an export named 'default'

Workaround

<script src="node_modules/dayjs/dayjs.min.js" async></script>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:22 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
hiredgunhousecommented, Nov 16, 2020

I try that:

import * as dayjs from 'dayjs'
var someDate = dayjs(new Date()).add(28, 'day')

and I get dayjs is not a function How come there is no sample of ES6 import in the docs?

5reactions
ghostcommented, Aug 25, 2018

try this import * as dayjs from 'dayjs';

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript modules via script tag | Can I use... Support tables ...
Loading JavaScript module scripts (aka ES6 modules) using <script type="module"> Includes support for the nomodule attribute. Usage % of. all users, all tracked ......
Read more >
JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >
16. Modules - Exploring JS
Their support for cyclic dependencies is better than CommonJS's. The ES6 module standard has two parts: Declarative syntax (for importing and exporting) ...
Read more >
Using ES Modules in the Browser Today - SitePoint
The Current ES Modules Landscape ... Safari, Chrome, Firefox and Edge all support the ES6 Modules import syntax. Here's what they look like....
Read more >
ES6 modules in the browser: are they ready yet?
First things first, the browser support: as I write this at the start of 2020, it's a pretty respectable 90%. https://caniuse.com/#feat=es6-module.
Read more >

github_iconTop Related Medium Post

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