ui5-community / babel-plugin-transform-modules-ui5

A Babel transformer plugin for OpenUI5/SAPUI5. It allows you to develop UI5 applications by using the latest ECMAScript or TypeScript, including new syntax and objective oriented programming technology.
MIT License
33 stars 16 forks source link

@babel/core module not found when use plugin #133

Closed coderjinhui closed 2 days ago

coderjinhui commented 5 days ago

Hi,

I meet the problem when using the babel preset. here is the code:

{
    "targets": "node > 20",
    "presets": ["@babel/preset-env", "transform-ui5", "@babel/preset-typescript"],
    "plugins": [],
    "sourceMaps": true,
    "ignore": [
        "**/*.d.ts"
    ]
}

And when compile the code, it shows error:

Error: babel-plugin-transform-modules-ui5 tried to access @babel/core, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

And I double confirmed the package, it already in the dependency in package.json file.

...
"devDependencies": {
        "@babel/core": "^7.25.2",
        "@babel/cli": "^7.24.8",
        "@babel/preset-env": "^7.25.3",
        "@babel/preset-typescript": "*",
        "@sapui5/types": "1.127.1",
        "@types/luxon": "^3.4.2",
        "@typescript-eslint/eslint-plugin": "^8.2.0",
        "@typescript-eslint/parser": "^8.2.0",
        "@ui5/cli": "^4.0.4",
        "@ui5/ts-interface-generator": "^0.8.3",
        "babel-preset-transform-ui5": "^7.6.0",
        "eslint": "^9.9.0",
        "typescript": "^5.5.4",
        "typescript-eslint": "^8.2.0"
    },
...

BTW, We use the yarn pnp mode as the package manager.

petermuessig commented 5 days ago

Hmm, good catch @coderjinhui

I think the dependencies aren't modelled properly. All dependencies are only devDependencies which isn't correct. Since we took over the plugin from Ryan Murphy who started the plugin, we never questioned the dependencies as it always worked. But in many cases, the project using the plugin had already defined the dependency to Babel. Could be also related to yarn which handles the devDeps a bit more strict.

We'll investigate! Thx for reporting...