You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.
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.
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.
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 amodule
and amain
field hereThe
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 likedist/polygon-clipping.es.js
(I'm more familiar with how to do it withrollup
).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 shrugThe text was updated successfully, but these errors were encountered: