Giter Site home page Giter Site logo

Bundling a little better? about search-index HOT 9 CLOSED

eklem avatar eklem commented on June 2, 2024
Bundling a little better?

from search-index.

Comments (9)

fergiemcdowall avatar fergiemcdowall commented on June 2, 2024 1

I think that main and browser are correct, and that the only file that should be in the dist folder is that stand-alone version that can be included in a script tag. That said, I am not really an expert on package bundling, so it could be that there is a better way to do this.

from search-index.

fergiemcdowall avatar fergiemcdowall commented on June 2, 2024 1

I also think that we should probably be using shipping without a dist folder and instead make dist magically appear on installation by adding npm prepare to package.json. The UMD version could then be made available directly from GitHub for anybody wanting to bypass bundlers (and/or use it directly from a <script> tag)

from search-index.

eklem avatar eklem commented on June 2, 2024

I guess UMD is out of the question, since the build process has to split the result on either levelDB for node or indexedDB for the browser. But ESM for the browser is good. And named exports.

from search-index.

fergiemcdowall avatar fergiemcdowall commented on June 2, 2024

Sounds good. The more portable these formats are, the better 👍👏

from search-index.

eklem avatar eklem commented on June 2, 2024

I'll try to make CJS and ESM for NodeJS and ESM for the browser. Possibly also UMD for the browser. Even if it isn't anything unified about it, UMD has an easier way to be included in an HTML page. Also makes it easier for search-index to co-exist with other scripts.

from search-index.

eklem avatar eklem commented on June 2, 2024

And it seems I can look at how the browsers are doing imports now.
https://twitter.com/wesbos/status/1640722393688600578

from search-index.

eklem avatar eklem commented on June 2, 2024

It seems the bundled version pulls in the whole package.json-file. Does it need that?

And shouldn't main and browser in package.json point to files in the dist-folder?

from search-index.

eklem avatar eklem commented on June 2, 2024

And nother question: Where do you define that you build with browser.js? Or is that just for browser-tests?

from search-index.

eklem avatar eklem commented on June 2, 2024

I looked a bit at this, but there is too many moving parts that I don't understand, sorry.

from search-index.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.