webflow / js-webflow-api

Node.js SDK for the Webflow Data API
https://www.npmjs.com/package/webflow-api
296 stars 95 forks source link

Use ESM syntax in src/index.js to allow ESM loaders to work #54

Closed swaff closed 2 years ago

swaff commented 2 years ago

Using a test setup written in vitest the webflow-api module cannot be imported because the package.json sets the jsnext:main value to point to src/index.js which in turn exports code using common js.

Therefore this change uses import/export. The tests still pass and the output to the dist directory remains the same.

johnagan commented 2 years ago

Thanks @swaff!

At a glance this makes sense to me. I'll spend some time this week to test and confirm.

swaff commented 2 years ago

Hi @johnagan, thanks for your time on this.

With some help at work I have actually been able to get my setup working by importing webflow from the dist dir.

import Webflow from 'webflow-api/dist/Webflow';

The CommonJS/EMS area is quite precarious so I think it might be best to discard my proposed change. I would not want to cause issues for any other consumers of the library by changing the interface.

I will leave it to you to decide because you may well be more knowledgable about this area than me, but feel free to close without merging.

Thanks again.