aurelia / new

The Aurelia 2 scaffolding repo used by our tools to setup new projects.
MIT License
35 stars 18 forks source link

feat: update babel decorator config to latest #103

Closed 3cp closed 4 months ago

3cp commented 4 months ago

au2 has adopted latest decorator spec.

closes aurelia/aurelia#1946, #102

ivanbacher commented 4 months ago

I get this error when making changes

Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL] /Users/ivan/Workspace/DLAB/Searobend/Repositories/searobend-client/src/main.js: The decorators plugin, when .version is '2018-09' or not specified, requires a 'decoratorsBeforeExport' option, whose value must be a boolean.
ivanbacher commented 4 months ago
{
  "presets": [
    [
      "@babel/preset-env",
      {
        "loose": true,
        "modules": false,
        "exclude": [
          "@babel/plugin-proposal-dynamic-import"
        ]
      }
    ]
  ],
  "plugins": [
    "@babel/plugin-transform-class-static-block",
    [
      "@babel/plugin-proposal-decorators",
      {
        "version": "2023-11"
      }
    ],
    [
      "@babel/plugin-transform-class-properties",
      {
        "loose": true
      }
    ],
    "@babel/plugin-syntax-dynamic-import"
  ]
}

I had to add @babel/plugin-transform-class-static-block to get it to work correctly. Also the decoratorsBeforeExport": true option in @babel/plugin-proposal-decorators did not really seem to do anything. Did not really matter if it was there or not.

3cp commented 4 months ago

transform-class-static-block, I assume you use static block in your code?

ivanbacher commented 4 months ago

transform-class-static-block, I assume you use static block in your code?

Hmm, never mind about the transform-class-static-block. After applying changes from your latest commits it seems to be working without it 🤯.

Thanks for making these changes so quickly.

3cp commented 4 months ago

Not tested. I rely on CI for the validation :-) TS is much easier to setup, since TS checks the typing of the decorator, it knows which version it uses.