Skip to content
This repository was archived by the owner on Mar 30, 2020. It is now read-only.

Conversation

@bennypowers
Copy link
Contributor

No description provided.

@bennypowers bennypowers force-pushed the transform branch 2 times, most recently from da16b38 to 264427a Compare March 8, 2020 07:13
@bennypowers
Copy link
Contributor Author

@joeldenning do you have any insights as to why esm/_virtual/index.js is not found on the travis server?

$ rollup -c

/home/travis/build/bennypowers/crocks-esm/node_modules/crocks/index.js → esm...

created esm in 5.3s

/home/travis/build/bennypowers/crocks-esm/node_modules/crocks/index.js → system...

created system in 5.6s

$ sh postbuild.sh
[test:browser] $ karma start karma.conf.cjs --single-run
[test:unit] $ mocha -r chai/register-expect 'node-test/**/*.*'
[test:unit] (node:6654) ExperimentalWarning: The ESM module loader is experimental.
[test:unit] 
[test:unit] 
[test:unit]   @esm-bundle/crocks
[test:unit]     1) can load the esm bundle without dying
[test:unit]     2) can load transformed deep packages without dying
[test:unit] 
[test:unit] 
[test:unit]   0 passing (294ms)
[test:unit]   2 failing
[test:unit] 
[test:unit]   1) @esm-bundle/crocks
[test:unit]        can load the esm bundle without dying:
[test:unit]      Error: Cannot find module /home/travis/build/bennypowers/crocks-esm/esm/_virtual/index.js imported from /home/travis/build/bennypowers/crocks-esm/esm/index.js
[test:unit]       at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:61:13)
[test:unit]       at Loader.resolve (internal/modules/esm/loader.js:85:40)
[test:unit]       at Loader.getModuleJob (internal/modules/esm/loader.js:191:28)
[test:unit]       at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:42:40)
[test:unit]       at link (internal/modules/esm/module_job.js:41:36)
[test:unit] 
[test:unit]   2) @esm-bundle/crocks
[test:unit]        can load transformed deep packages without dying:
[test:unit]      Error: Cannot find module /home/travis/build/bennypowers/crocks-esm/esm/_virtual/isFunction.js imported from /home/travis/build/bennypowers/crocks-esm/esm/helpers/compose.js
[test:unit]       at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:61:13)
[test:unit]       at Loader.resolve (internal/modules/esm/loader.js:85:40)
[test:unit]       at Loader.getModuleJob (internal/modules/esm/loader.js:191:28)
[test:unit]       at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:42:40)
[test:unit]       at link (internal/modules/esm/module_job.js:41:36)
[test:unit] 
[test:unit] 
[test:unit] 
[test:unit] error Command failed with exit code 2.

@internettrans
Copy link

A few questions:

  1. Are you planning on publishing this under the @esm-bundle npm scope? If so, the repository needs to be transferred to https://github.com/esm-bundle and renamed to crocks instead of crocks-esm.
  2. This project is not creating an esm bundle - it's creating a lot of ESM files. Is that intentional?
  3. Using bash as part of your build means that Windows users likely won't be able to work on this project. It's probably better to use a node script instead

@joeldenning do you have any insights as to why esm/_virtual/index.js is not found on the travis server?

If you're not planning on publishing this under the @esm-bundle repository as a bundle, I don't I have the time to look into this for you.

@bennypowers
Copy link
Contributor Author

A few questions:

1. Are you planning on publishing this under the `@esm-bundle` npm scope? If so, the repository needs to be transferred to https://github.com/esm-bundle and renamed to `crocks` instead of `crocks-esm`.

Yes!

2. This project is not creating an esm bundle - it's creating a lot of ESM files. Is that intentional?

Yes. Imports like crocks/helpers/compose.js are commonly used with this library.

3. Using bash as part of your build means that Windows users likely won't be able to work on this project. It's probably better to use a node script instead

@joeldenning do you have any insights as to why esm/_virtual/index.js is not found on the travis server?

If you're not planning on publishing this under the @esm-bundle repository as a bundle, I don't I have the time to look into this for you.

@internettrans
Copy link

I think I gave you rights to create repositories in esm-bundle, so you should be able to transfer this repo over?

Regarding not providing a single bundle for the crocks library - that is different than the other esm-bundles, but I'm okay with it since people use the deeper imports. Does every single file have to be preserved? In that case it might make sense to just run it through babel instead of rollup, since rollup is specifically for concatenation / bundling.

Alternatively, there is a CDN that automatically converts any npm package to ESM and System.register format. It just doesn't convert them into bundles. Check it out at https://cdn.jspm.io/npm:crocks@0.12.4/index.dew.js. It's run by Guy Bedford - the downsides are that you can't host it yourself (it's closed source), deploys to it are managed by Guy, and the CDN never does any concatenation / bundling. However, it's a really useful tool and I'd recommend checking it out.

If that alternative hasn't already won you over - I'd suggest switching over to babel and using something like https://github.com/prateekbh/babel-esm-plugin to creating the files. The npm script would be this: babel src --out-dir dist --source-maps

@bennypowers
Copy link
Contributor Author

bennypowers commented Mar 10, 2020

rights to create repositories

I transferred the repo, but don't have perms to rename it

CDN

CDN is less compelling for me, since I want to depend on this package in other libraries

https://github.com/prateekbh/babel-esm-plugin

This is a webpack plugin, right? if the goal is to transform cjs to esm, rollup can do this with @rollup/plugin-commonjs, and in fact it does do that. Just for some reason, the _virtual dir that is produces is not showing up when run in travis' environment.

  1. Using bash as part of your build means that Windows users likely won't be able to work on this project. It's probably better to use a node script instead

I don't mind that in principle, but here are some scripts that do work. I think windows users could use WSL in the mean time?

SOLVED

Turns out it was PEBCAK and my scripts were broken

Copy link

@internettrans internettrans left a comment

Choose a reason for hiding this comment

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

Looks good to me - let's see if the first publish works after this is merged.

@kodiakhq kodiakhq bot merged commit 119d8c9 into master Mar 10, 2020
@kodiakhq kodiakhq bot deleted the transform branch March 10, 2020 16:58
@internettrans
Copy link

Publish to npm worked - the files are available at https://unpkg.com/@esm-bundle/crocks@0.12.4/esm/index.js

@internettrans
Copy link

Looks like it's working -
image

@bennypowers
Copy link
Contributor Author

in order to match with the original package, i think this should only output, not system

crocks/helpers/compose fails to load, it has to be crocks/esm/helpers/compose, which breaks compatibility

@bennypowers bennypowers mentioned this pull request Mar 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants