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

Anomaly in package.json #67

Closed
rowanwins opened this issue Jan 24, 2019 · 3 comments
Closed

Anomaly in package.json #67

rowanwins opened this issue Jan 24, 2019 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@rowanwins
Copy link
Contributor

Hey @mfogel

Was doing some digging into my problem I was getting upstream in turf and started to wonder if it was due to how the package is distributed... I could get my scenario to run fine when using polygon-clipping directly via npm, however when I included in turf and run the same code it failed...

I notice in the package.json that you've listed a module and a main field here

The module field points to the src directory, however to build the dist version you're passing it through babel. You can read a little bit on the babel blog about those fields here and how various transpilers use them.

So the problem I'm flagging is the module field should point to something that has already gone through the babel process. I'm pretty sure you can configure webpack to spit out a module, so often what happens is you'll end up with a file like dist/polygon-clipping.es.js (I'm more familiar with how to do it with rollup).

Does that make sense?

Cheers
Rowan

PS. All that said within turf I can do something like import polygonClipping from 'polygon-clipping/dist/polygon-clipping.js'; however even that hasn't resolved my issue shrug

@mfogel
Copy link
Owner

mfogel commented Jan 25, 2019

Yeah - that makes sense. Specifically - set up webpack to spit out a ES6 module to somewhere in the dist/ directory, and then link to that from the module field of package.json.

@mfogel mfogel added the bug Something isn't working label Jan 25, 2019
@mfogel mfogel added this to the v0.11.2 milestone Jan 25, 2019
@mfogel mfogel closed this as completed in b72193e Jan 27, 2019
@mfogel
Copy link
Owner

mfogel commented Jan 27, 2019

Ok, so I switched everything from webpack to rollup to be able to build different types of modules in the dist/ directory. It seemed like a more straightforward process with rollup than with webpack.

@rowanwins could you take a look at what's in the dist/ directory now and see if it works as you might expect? Any thoughts / recommendations? If you see anything that's off I would love to fix it before pushing a new release to npm.

@rowanwins
Copy link
Contributor Author

Hey @mfogel

Looks good!

Probably the main suggestion would be tweaking the output name of the umd browser package here to address the issue in #47 where hyphens are a bit funky in browsers.

Cheers

mfogel added a commit that referenced this issue Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants