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

build: ship commonjs version for node and testing #10

Closed
Hotell opened this issue Jul 25, 2018 · 7 comments
Closed

build: ship commonjs version for node and testing #10

Hotell opened this issue Jul 25, 2018 · 7 comments
Labels
enhancement New feature or request

Comments

@Hotell
Copy link

Hotell commented Jul 25, 2018

Currently if i wanna use same polyfills in testing environment ( jest ) like in dev/prod with typescript I have to do a lot of ceremony:

  • in jest config
{
transformIgnorePatterns: [
    '<rootDir>/node_modules/(?!@abraham/reflection/.*)',
  ],
}
  • in tsconfig
{
"allowJs": true
}

this is rather hack then good DX experience :)

shipping commonJS bundle is a no brainer and would help a lot ;) cheers

@abraham
Copy link
Owner

abraham commented Jul 25, 2018

Are you compiling to JS and then running the tests on the compiled version?

How would you imagine the two build targets would be handled? Something like this?

import '@abraham/reflection';
require('@abraham/reflection/dist/common.js');

@Hotell
Copy link
Author

Hotell commented Jul 25, 2018

the API should remain same, package.json should be source of truth here., I think. WDYT ? :)

{
  "main": "dist/reflection.umd.js", // commonjs bundle
  "module": "dist/index.js", // es2015 module
}

@abraham
Copy link
Owner

abraham commented Jul 25, 2018

Are there build tools that use the module entry? I think unpkg does but I don't know about any others.

@Hotell
Copy link
Author

Hotell commented Jul 25, 2018

Webpack, rollup ... I'm using it all the time https://github.com/Hotell/typescript-lib-starter

@abraham
Copy link
Owner

abraham commented Jul 25, 2018

Want to give abraham/reflection#rollup a try?

@abraham abraham mentioned this issue Jul 25, 2018
@Hotell
Copy link
Author

Hotell commented Jul 25, 2018

that works! although rollup consumes es2015 module files 😥so there is no dist/index.js anymore

image

@Hotell
Copy link
Author

Hotell commented Jul 25, 2018

oh nevermind, it builds correctly when explicitly running build within node modules :)
image

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

No branches or pull requests

2 participants