Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With module you can define the path to ES module #612

Closed
wants to merge 1 commit into from

Conversation

kevinsimper
Copy link

The module attribute is too define ES module so that loaders can find the unpackaged code.

https://github.com/rollup/rollup/wiki/pkg.module

https://pikapkg.com is looking for ES modules in that field

https://unpkg.com serves that file if you define that it should load with ?module

@iamkun
Copy link
Owner

iamkun commented Jun 11, 2019

#492

@kevinsimper
Copy link
Author

@iamkun I read it now but it makes bundler that looks for ES Modules code find the wrong code that doesn't use the correct syntax. That bundlers can figure out is not a great solution.

The day.min.js doesn't expose any of the ES Module export syntax, I don't see how this is a solution in #492 😅

@iamkun
Copy link
Owner

iamkun commented Jun 11, 2019

I am afraid there's no way to fix this issue until webpack fix that related issue first. Let me know if I'm wrong.

@kevinsimper
Copy link
Author

The solution can also be to publish two packages, as @Tvrqvoise says, I don't think you can solve both, but that is why you have two entrypoints, one for node.js and one for ES modules :)

@kevinsimper
Copy link
Author

kevinsimper commented Jun 11, 2019

I published a new npm package that people can use easily in the browser
https://unpkg.com/dayjs-es?module

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Static Template</title>
  </head>
  <body>
    Dayjs
    <script type="module">
      import dayjs from "https://unpkg.com/dayjs-es?module";
      let day = document.createElement("div");
      day.innerHTML = dayjs().format();
      document.body.appendChild(day);
    </script>
  </body>
</html>

Static example can be seen here https://codesandbox.io/s/static-dcus0

@kevinsimper
Copy link
Author

Here is also a discussion about how to tackle it :) https://twitter.com/_developit/status/1138115151318704128

@iamkun
Copy link
Owner

iamkun commented Jul 4, 2019

I'll close this since it's been a while since it's been opened. Feel free to reopen if you have updates on this

@iamkun iamkun closed this Jul 4, 2019
@kevinsimper
Copy link
Author

@iamkun Isn't the three previous comments enough? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants