TeselaGen / tg-oss

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

the latest published ove package can not be imported correctly. #13

Closed sunm19810-pki closed 1 year ago

sunm19810-pki commented 1 year ago

Hi @tnrich, it seems the latest 'ove' version (0.3.7) can not be imported correctly, can we publish the 'ove' package and other packages like 'ui' without 'react' or 'react-dom' bundled (open-vector-editor do not set these two packages in the dependencies, it set the two in the peerDependencies and devDependencies)

currently published npm packages can not be used as es module easily. Thanks

tnrich commented 1 year ago

Hi @sunm19810-pki ,

Version 0.3.7 seems to be working in this simple react demo page - https://github.com/tnrich/ove-react-demo-repo

Does that demo work for you? In what ways is your set up different from that one?

Thanks

XingGao-PKI commented 1 year ago

@tnrich, it seems works fine with vite, but for webpack, it cannot load the the src/index.js as the source code It always shows an error like this.


Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> import "@fontsource/ubuntu-mono";
| import { FocusStyleManager } from "@blueprintjs/core";
| import { showContextMenu } from "@teselagen/ui";
XingGao-PKI commented 1 year ago

@tnrich you can try this repo https://github.com/XingGao-PKI/my-app

sunm19810-pki commented 1 year ago

Hi @tnrich, if we want to make the latest ove package been easily used in webpack, we may need to change some configurations in the vite.react.config.ts, maybe I can raise a PR tomorrow for it. Mainly need to change formats:, external of vite.react.config.ts file. And we need to change some value in publish.mjs to make the published package.json file able to be recognized as a es module.

tnrich commented 1 year ago

@sunm19810-pki thanks for looking into this. I'd be happy to review a PR if you make one.

tnrich commented 1 year ago

Ok, @XingGao-PKI @sunm19810-pki I published a new version of ove 0.3.9 that should work for vite and webpack builds. I added a vite and webpack demo to tg-oss

To try out the webpack demo within tg-oss run the following commands:

cd tg-oss;
yarn;
nx run:ove build; 
cd example-demos/oveWebpackDemo && yarn && yarn start

You should see something like this:

image

Lemme know if that works for y'all

sunm19810-pki commented 1 year ago

Thanks very much @tnrich, it indeed work now. We actually had similar code PR for webpack building, but we decide to use the previous version as the new version may need some time, it is really good as the new version is published so fast.

tnrich commented 1 year ago

Awesome, glad to hear it!