indix / web-auto-extractor

Automatically extracts structured information from webpages
MIT License
108 stars 30 forks source link

babel seems to mess with the ES export #30

Open maxlath opened 11 months ago

maxlath commented 11 months ago

Hi!

// in src/index.js
export default function

becomes

// in dist/index.js
exports.default = function () {

so the ES import currently needs to look like this:

import WAE from 'web-auto-extractor'
WAE.default().parse(html)

instead of

import WAE from 'web-auto-extractor'
WAE.parse(html)

which is what the readme says.

That could maybe be solved by making ES imports directly import the src files, something like this:

// in package.json
{
    "exports": {
        "import": "./src/index.js",
        "require": "./dist/index.js"
    }
}

see documentation