Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

add package.json props for umd vs es2015 vs es6 versions #22

Closed
btopro opened this issue Sep 10, 2018 · 6 comments
Closed

add package.json props for umd vs es2015 vs es6 versions #22

btopro opened this issue Sep 10, 2018 · 6 comments

Comments

@btopro
Copy link

btopro commented Sep 10, 2018

If done correctly (we're way out of my element here admittedly) we could support all 3 forms of build routines via webpack / other bundles in the package.json. main currently points to index.js which doesn't exist. The talk / reference doc below discusses this idea --

https://youtu.be/Ucq9F-7Xp8I?t=28m51s

https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview#

basic idea would be to have something like

  "main": "<%= elementName %>.umd.js",
  "module": "<%= elementName %>.es5.js",
  "es2015": "<%= elementName %>.js",

in the package.json. Could also help in resolving issues of umd vs non umd builds

@kylebuch8
Copy link
Contributor

@btopro This is great (and Rob Dodson is my hero). This is also out of my wheelhouse but @mwcz might have a better chance of understanding how we'd do this.

@btopro
Copy link
Author

btopro commented Sep 11, 2018

if you or @mwcz can solve the current hell of knowing what to babel compile or not compile to get this error to go away then you'd be my hero - Uncaught TypeError: Class constructor PolymerElement cannot be invoked without 'new'

It's a precursor to the idea above. We'd need to pick a build routine that would allow for referenced repos so that it could be reviewed in storybook / the demo sites / etc; or, having a routine that rewrites the storybook / demo files to match the routine in question.

@kylebuch8
Copy link
Contributor

It's probably something to do with the custom-elements-es5-adapter.js. If you're using ES6 files and have that file loaded, you'll get that error.

Maybe take a look at https://stackoverflow.com/questions/43520535/class-constructor-polymerelement-cannot-be-invoked-without-new

@mwcz
Copy link
Contributor

mwcz commented Sep 11, 2018

Thanks @btopro, this is awesome stuff. I remember seeing part of that talk and thinking it would come in handy some day.

I'm totally onboard with this change. @btopro, any ideas on how we could add tests for this change? Perhaps some tiny webpack/etc projects that do nothing but npm install a RHElement, import it, and build?

@btopro
Copy link
Author

btopro commented Sep 11, 2018

that sounds like a good enough will it blend style test to ensure it's still working. My fork of the generator is adding a lot of other stuff (as per video on twitter the other day) but it's still work in progress. Though in that scenario (RHElement being just 1 class extension) the will it blend test would just be using the customElementClass template variable to rewrite the rest specific to the element type (https://github.com/btopro/generator-rhelement/blob/master/generators/index.js#L242)

@castastrophe
Copy link
Contributor

Added main and module in #32 but with different prefixes:

  "main": "./dist/<%= elementName %>.umd.js",
  "module": "./dist/<%= elementName %>.js",
  "unpkg": "./dist/<%= elementName %>.umd.min.js",

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

No branches or pull requests

4 participants