Recently, I have been working on turning this into an npm package:
Test.tsx:
import React from "react";
export default class Test extends React.Component {
public render() {
return (
<h1>
Hallo
</h1>
)
}
public blub() {
return 12;
}
}
index.tsx:
import Test from './Test';
module.exports = { Test }
This project was created using create-react-app eject feature. the compiled file (/dist/static/js/main.chunk.js) contains these lines:
module.exports = {
Test: _Test__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"]
};
The package.json file is structured like this:
{
"name": "npmreacttestcrm",
"version": "0.1.12",
"private": false,
"main": "dist/static/js/main.chunk.js",
"dependencies": {
...
},
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js",
"publish:npm": "npm run build && npm publish && python updater.py"
},
"eslintConfig": {
"extends": "react-app"
},
"devDependencies": {
...
},
"jest": {
...
},
"babel": {
"presets": [
"react-app",
"@babel/preset-typescript"
]
}
}
However, when trying to import the package into a different project, only the number 1 is returned.
import Test1 from 'npmreacttestcrm';
console.log('test1', Test1);
const Test = require("npmreacttestcrm");
console.log('test', Test);
Output in console: test1 1 test 1
Can you provide guidance on how to correctly import my package?