Skip to content

Add es module#7

Open
YerkoPalma wants to merge 4 commits into
masterfrom
module
Open

Add es module#7
YerkoPalma wants to merge 4 commits into
masterfrom
module

Conversation

@YerkoPalma

Copy link
Copy Markdown
Member

No description provided.

Comment thread package.json Outdated
Comment thread index.es.js Outdated
@@ -0,0 +1,35 @@
import assert from 'www.unpkg.com/nanoassert?module'

Copy link
Copy Markdown
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?

@YerkoPalma YerkoPalma Oct 17, 2018

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
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/md@0.6.0/dist/md.es.js?module which is the actual version plus whatever you defined in your module property in package.json

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

Copy link
Copy Markdown
Member

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/nanoassert@x.y.z/index.js?module' automatically. bundlers could also use this entry point then.

Copy link
Copy Markdown
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
Copy Markdown
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