TeselaGen / tg-oss

Teselagen Open Source modules
https://teselagen.github.io/tg-oss/
MIT License
40 stars 17 forks source link

Fix ove and ui imports for vitest #25

Closed smeng9 closed 1 year ago

smeng9 commented 1 year ago

Hi @tnrich, we just noticed the https://github.com/TeselaGen/openVectorEditor gets moved to here. We are trying to switch to the @teselagen/ove with our current build system and expecting to be simple name replacements but we found some issues with our testing.

As a follow up of https://github.com/TeselaGen/tg-oss/issues/13 and https://github.com/TeselaGen/tg-oss/pull/16 , We noticed the exports needs to be done correctly with the correct format in order to be used in vitest. I changed the file name format in vite.react.config.ts and updated all package.json to use the updated files. Some package.json not exporting the files causing tests to fail.

I have also updated your example to demonstrate vitest. We need to add vitest dependency, update vite.config.js configs, fix the test.jsx file extension, and update the test cases.

If you publish a new versions of ove and ui, and bump the internal ove's dependency on ui with this merge request, the test cases will probably pass. For now it throws various errors complaining package exports are not setup correctly.

smeng9 commented 1 year ago

I also think you can put a deprecation on the https://www.npmjs.com/package/open-vector-editor and archive https://github.com/TeselaGen/openVectorEditor so we would immediately know next time when we perform dependency install.

smeng9 commented 1 year ago

Hi @tnrich, I realized there are some additional issue and the tests are not passing.

smeng9 commented 1 year ago
  1. The https://www.npmjs.com/package/@teselagen/ui seems is not updated. In the package.json file https://www.npmjs.com/package/@teselagen/ui?activeTab=code it is still not exporting the index.cjs.js and index.es.js files.

  2. The published ove package.json is referencing an old copy of ui of 0.3.13 here https://www.npmjs.com/package/@teselagen/ove?activeTab=code .

  3. Since we publish both es and cjs files, we have to omit the type field in package.json in the published packages. Then the bundler can determine the correct type, for now webpack failed to build.

tnrich commented 1 year ago

@smeng9 whoops, yeah looks like I only published ove, re-publishing both ui and ove now

smeng9 commented 1 year ago

Also need to merge https://github.com/TeselaGen/tg-oss/pull/26 to fix the file type used by web pack bundler

smeng9 commented 1 year ago

All vitest passing in the example-demos/oveViteDemo now. Thanks!