appy-one / acebase-server

A fast, low memory, transactional, index & query enabled NoSQL database server for node.js that easily syncs with browser and node.js clients and servers
MIT License
32 stars 14 forks source link

Use ESM build when `import`ed #59

Closed appy-one closed 1 year ago

appy-one commented 1 year ago

@Azarattum this might be the reason Vite was using the CommonJS build, importing of ESM build was temporarily disabled

appy-one commented 1 year ago

@Azarattum have you tested your Vite build with this ESM import?

Azarattum commented 1 year ago

@appy-one, I can confirm that vite now uses the ESM build. swagger is still imported unless replace({"process.env.NODE_ENV": "false"}). However now the swagger build is actually functional. Vite produces multiple files, but it works: image

Also, when running build:esm on the acebase-server I get the following error:

src/logger.ts:43:5 - error TS2742: The inferred type of 'query' cannot be named without a reference to 'acebase-server/node_modules/acebase-core'. This is likely not portable. A type annotation is necessary.

43     query() {
       ~~~~~
appy-one commented 1 year ago

@Azarattum can you check if process.env.NODE_ENV?.trim() will work again then? Replacing some && some.thing with some?.thing is a thing I do very regularly and it might happen in the future to that line..

I'll look into the build error now.

appy-one commented 1 year ago

@Azarattum I think you got the build error because I was using an updated acebase-core version locally. I've published all new packages so if you pull the server code from github now all should build fine