You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure its a bug, but I am running out of ideas.
I'm trying to import a self-written module.
React version: 16.13.1
Steps To Reproduce
I have the following setup
myRoot
|-- t-lib
| |-- src
| |-- config-overwrides.js (I'm using react-app-rewired, but I think it's not relevant)
| |-- package.json
| |-- ... other stuff
|-- t-consumer
| |-- src
| |-- package.json
| |-- ... other stuff
Inside t-lib/package.json I have name: 't-lib'.
So, while in the folder of t-consumer I did:
npm link ../t-lib
And in the t-consumer/src/App.js, I wrote import myLib from 't-lib'
What I get is
SyntaxError: C:\Users\...\t-lib\src\index.js: Support for the experimental syntax 'jsx' isn't currently enabled (7:3):
5 | function MountApp(element) {
6 | ReactDOM.render(
> 7 | <React.StrictMode>
| ^
8 | <App />
9 | </React.StrictMode>,
10 | element
Add @babel/plugin-transform-react-jsx (https://git.io/vb4yd) to the 'plugins' section of your Babel config to enable transformation.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-app-rewired build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: ...
The current behavior
I get the error metioned above.
I would like to note, that the error occures in the t-lib/src/index.js, not in the t-consumer project. So appearently the setup is correct, just babel gets confused somehow about the jsx.
The expected behavior
I would like it to actually build the project, or possibly a hint, on which settings I have done wrong.
Code
In case it's needed, here is the code: (both projects are basicly the same, and just trying to get it to work)
public/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script>
setTimeout(() => {
// I know this is bad practice, it's just a proof of concept to get a library to work.
const element = document.getElementById('root');
testConsumer.MountApp(element);
}, 1000);
</script>
</body>
</html>
src/App.js
import React from 'react';
import myLib from 't-lib'; // only in the consumer
function App() {
console.log(myLib);
return <div>consumer</div>;
}
export default App;
src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
function MountApp(element) {
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
element
);
}
export { MountApp };
Sounds like you're having an issue trying to get NPM link working with a Babel transform. Might try asking on Stack Overflow or posting in the Babel repo?
This is related to create-react-app working across workspaces in a monorepo facebook/create-react-app#1333 That thread has some suggestions on how to get babel transpilation working, would recommend you follow those.
This issue shouldn't be in this repo regardless, I think.
I'm not sure its a bug, but I am running out of ideas.
I'm trying to import a self-written module.
React version: 16.13.1
Steps To Reproduce
I have the following setup
Inside t-lib/package.json I have
name: 't-lib'
.So, while in the folder of
t-consumer
I did:And in the t-consumer/src/App.js, I wrote
import myLib from 't-lib'
What I get is
The current behavior
I get the error metioned above.
I would like to note, that the error occures in the t-lib/src/index.js, not in the t-consumer project. So appearently the setup is correct, just babel gets confused somehow about the jsx.
The expected behavior
I would like it to actually build the project, or possibly a hint, on which settings I have done wrong.
Code
In case it's needed, here is the code: (both projects are basicly the same, and just trying to get it to work)
public/index.html
src/App.js
src/index.js
config-overrides.js
package.json
The text was updated successfully, but these errors were encountered: