Open lishoulong opened 2 years ago
I am having this issue as well.
I also had this issue and I had to go back to parcel version 1 like this:
npm i --save-dev parcel-bundler@1.12.3
@hirwablessing This did not fix it for me. Im very confused and disappointed that tsdx is no longer working out of the box.
@MagnusBrzenk are you sure you installed that specific parcel version? Also make sure you don't have two versions of parcel in your project.
Edit: this worked at first, but subsequent attempts result in the same failure! It's really odd, but I have followed the following steps several times, and sometimes it works, and sometimes it doesn't. I have never seen a node setup to be so apparently non-deterministic.
❯ node --version
v18.6.0
❯ tsdx --version
tsdx, 0.14.1
❯ tsdx create temp
❯ react
❯ cd temp/example
❯ npm i
❯ npm run start
...
🚨 /Users/.../temp/example/index.tsx: Invalid Version: undefined
❯ npm i --save-dev parcel-bundler@1.12.3
❯ npm run start
Server running at http://localhost:1234
✨ Built in 8.97s.
### IT WORKS SOMETIMES, BUT NOT ALWAYS!
Edit: this worked at first, but subsequent attempts result in the same failure! It's really odd, but I have followed the following steps several times, and sometimes it works, and sometimes it doesn't. I have never seen a node setup to be so apparently non-deterministic.
❯ node --version v18.6.0 ❯ tsdx --version tsdx, 0.14.1 ❯ tsdx create temp ❯ react ❯ cd temp/example ❯ npm i ❯ npm run start ... 🚨 /Users/.../temp/example/index.tsx: Invalid Version: undefined ❯ npm i --save-dev parcel-bundler@1.12.3 ❯ npm run start Server running at http://localhost:1234 ✨ Built in 8.97s. ### IT WORKS SOMETIMES, BUT NOT ALWAYS!
I guess this is an issue related to tsdx
than any other thing.
Hi guy,
It works for me.
Step 1: Update parcel
to new version and change react-dom to ../node_modules/react-dom
if you use react 18, like this example/package.json
{
"name": "example",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html"
},
"dependencies": {
"react-app-polyfill": "^1.0.0"
},
"alias": {
"react": "../node_modules/react",
"react-dom": "../node_modules/react-dom",
"scheduler/tracing": "../node_modules/scheduler/tracing-profiling"
},
"devDependencies": {
"@types/react": "^16.9.11",
"@types/react-dom": "^16.8.4",
"parcel": "^2.7.0",
"typescript": "^3.4.5"
}
}
Step 2: Change example/index.html
like this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Playground</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./index.tsx"></script>
</body>
</html>
Step 3 (option): If you use react 18, change example/index.tsx
like this
import 'react-app-polyfill/ie11';
import React from 'react';
import ReactDOM from 'react-dom/client';
import { Thing } from '../.';
const App = () => {
return <div><Thing /></div>;
};
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
hope it will be useful!
I had this issue too @pvhieuit 's fix did get it running for me, but the example does not update when I change any library code. I have to restart tsdx and the example project to see any change in the browser.
I had this issue too @pvhieuit 's fix did get it running for me, but the example does not update when I change any library code. I have to restart tsdx and the example project to see any change in the browser.
try to add parcel-bundler
I just switched to using Vite in library mode. Flawless experience.
I just switched to using Vite in library mode. Flawless experience.
Is Vite really easy to configure for libraries? Seems like it demands quite a bit of manual config:
https://articles.wesionary.team/react-component-library-with-vite-and-deploy-in-npm-579c2880d6ff
TloT
I had this issue too @pvhieuit 's fix did get it running for me, but the example does not update when I change any library code. I have to restart tsdx and the example project to see any change in the browser.
I'm experiencing the same problem. Then I found this post:
https://github.com/parcel-bundler/parcel/issues/4332#issuecomment-1311704659
Which appears to indicate that the current setup with example running from a subfolder will prevent parcel from watching the files in dist. Looks like you need to trigger parcel to watch the folder, I used watchman, seems to work now:
"watch-src": "watchman watch ../dist && watchman -- trigger ../dist buildme '*.*' -- touch ../example/package.json",
Hi @chriszrc I honestly found it very little config and a very painless experience, I highly recommend it. Here is my little library if you fancy taking a look at the setup. It's literally a default Vite React set up with a lib directory where all the library code lives then the build option in vite.config.ts configured to bundle just the lib code. Hope that helps.
Current Behavior
tsdx cli project,
xx/xx/example/index.tsx: Invalid Version: undefined at new SemVer (/tsdx/mylib/example/node_modules/semver/semver.js:314:11) at compare (/tsdx/mylib/example/node_modules/semver/semver.js:647:10) at lt (/tsdx/mylib/example/node_modules/semver/semver.js:688:10)
Expected behavior
show start local server success
Suggested solution(s)
Additional context
Your environment