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

Add es module #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add es module #7

wants to merge 4 commits into from

Conversation

YerkoPalma
Copy link
Member

No description provided.

package.json Outdated Show resolved Hide resolved
index.es.js Outdated
@@ -0,0 +1,35 @@
import assert from 'www.unpkg.com/nanoassert?module'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs a protocol?

Copy link
Member Author

@YerkoPalma YerkoPalma Oct 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?

import assert from 'https://www.unpkg.com/nanoassert?module'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea. actually, doesn't unpkg automatically rewrite import paths when you use ?module? just doing import assert from 'nanoassert' might just work already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't .Something like https://unpkg.com/md?module get resolved to https://unpkg.com/[email protected]/dist/md.es.js?module which is the actual version plus whatever you defined in your module property in package.json

Copy link
Member

@goto-bus-stop goto-bus-stop Oct 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean how the import statements in the package source code get rewritten, like this:
image

so if we do import assert from 'nanoassert' here, unpkg would turn it into import assert from 'https://unpkg.com/[email protected]/index.js?module' automatically. bundlers could also use this entry point then.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you mean when already published? Actually never tried that, it would be much cleaner.

@YerkoPalma
Copy link
Member Author

@yoshuawuyts @goto-bus-stop Thanks for your comments.
I've updated this PR with your suggestions and also used microbundle for bundling es and cjs bundles.
(Travis is failling with node 5 and 4, not sure what to do about it)

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.

3 participants