prantlf / babel-plugin-amd-default-export

A Babel plugin to make the generated AMD modules export the default export directly and not wrapped in an object with a default property.
MIT License
1 stars 1 forks source link

Incompatible with Babel 7 #1

Open navarr opened 1 month ago

navarr commented 1 month ago
Error: Plugin/Preset files are not allowed to export objects, only functions. In /var/www/html/node_modules/babel-plugin-amd-default-export/index.js
    at createDescriptor (/var/www/html/node_modules/@babel/core/lib/config/config-descriptors.js:160:11)
    at createDescriptor.next (<anonymous>)
    at step (/var/www/html/node_modules/gensync/index.js:261:32)
    at evaluateAsync (/var/www/html/node_modules/gensync/index.js:291:5)
    at items.forEach (/var/www/html/node_modules/gensync/index.js:44:11)
    at Array.forEach (<anonymous>)
    at Function.async (/var/www/html/node_modules/gensync/index.js:43:15)
    at Function.all (/var/www/html/node_modules/gensync/index.js:216:13)
    at Generator.next (<anonymous>)
    at createDescriptors (/var/www/html/node_modules/@babel/core/lib/config/config-descriptors.js:102:41)

This functionality would come in real handy, unfortunately I don't understand enough about Babel plugins to even consider forking it

prantlf commented 1 month ago

Are you sure that you're not mixing babel 6, 7 and/or 8? There's a thread on stackoverflow about this problem.

navarr commented 1 month ago

Fairly sure

    "@babel/cli": "^7.24.5",
    "@babel/core": "^7.24.5",
    "@babel/plugin-transform-modules-amd": "^7.24.1",
    "@babel/preset-env": "^7.24.5",
    "@babel/preset-typescript": "^7.24.1",
    "babel-loader": "^9.1.3",

I did manage to tweak it such that I could get it working personally, but I'm not confident enough in my changes to consider suggesting them: https://github.com/navarr/babel-plugin-amd-default-export/commit/b74048d2cfbd5f3f366f56440b12351d6ca35b75?diff=unified&w=1