I have created npm package in order to use it withing our organization. It containing some reusable code for testing. It is published to our internal feed and i have installed in destination project without any problems.
Destination project containing playwright tests and when im trying to run them it started to show me error while im trying to import anything from that npm package:
SyntaxError: Unexpected token 'export
In this project im using node.js 20 and typescript, i have installed babel and configured to use typescript presets. In my tsconfig i also set to “module”: “ESNext”, however i have still this issue. My npm package have actually same configuration. Im bit lost what is missing here.
tsconfig
{
"compilerOptions": {
"jsx": "react",
"strict": true,
"forceConsistentCasingInFileNames": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"module": "ESNext",
"target": "ESNext",
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"allowJs": true,
"noEmit": true,
"lib": ["ESNext", "DOM"],
"baseUrl": "./src",
"paths": {}
},
"include": ["src/**/*",".vscode/babel.config.js"]
}
babel config
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
};
i also included this in package.json
"jest": {
"transform": {
"^.+\.jsx?$": "babel-jest"
},
"transformIgnorePatterns": [
"/node_modules/(?!(somePkg)|react-dnd|core-dnd|@react-dnd)"
]
},