osdevisnot/klap

Have an option to remove index.js from public directory

talentlessguy opened this issue · 6 comments

I want to use Klap as an app bundler, not for a library.

I'm not sure how to properly to do this but I'd like to setup Klap just to write a web app like with Parcel.

So I don't want index.js or any other JS files to be in public, now I get this:

Error: Could not resolve entry module (public/index.js).

Any way to avoid using this?

I am unsure what the end goal for your use case is, but in my opinion an app scope is much larger of an use case.

We would need to determine ways to handle CSS, cache busting and whole lot of other concerns.

My intent for klap is to create a tool optimized for NPM library use case. However, we might be able to accept small changes if they help solve app bundler use case.

@osdevisnot the case is using Klap as a web app bundler, e.g. having a similar experience like in Parcel.

In Parcel you just set an html file, then (optionally) edit package.json menus and it works, without limitations.

So would be epic for Klap not to force files locations (I mean just put a source: src/index.js and then import anything to it and it will work fine) and be more flexible

I understand that Klap is more like Microbundle 2, but I'd like to use it as a bundler because it is the only one bundler with ESM support that can be used for web development (web dev with Rollup sucks let's be honest, Parcel doesn't have ESM output, Pax is written in Rust and is hard to setup)

I may be reading this between the lines, but I believe you are looking for klap.example option. This will let you place the entrypoint wherever you wanted.

I may be reading this between the lines, but I believe you are looking for klap.example option. This will let you place the entrypoint wherever you wanted.

I didn't mean that, I meant Klap to be more flexible, not only buildings libs but also apps.

Like:

// src/index.js

import { h, render } from 'preact'

/** @jsx h */

render(<h1>Hello World</h1>, document.getElementById('app'))
// package.json

{
  "source": "src/index.js",
   "module": "dist/index.esm.js"
}

and then in index.html <script src="dist/index.esm.js"> and everything works

@talentlessguy here is a minimal example that works with latest version of klap - https://github.com/osdevisnot/klap/tree/master/examples/minimal

However, as I mentioned before the app use case is much broader scope which needs more careful considerations.

Having said that, we might still be able to accept changes if they help solve app bundler use case.

@osdevisnot thank you for creating this feature! Closing 😃