💻
How are you using Babel?
babel-loader (webpack)
Input code
const el = document.createElement('foo-el')
document.body.append(el)
function element(name) {
return (Class) => {
customElements.define(name, Class) // Uncaught TypeError: undefined is not a function
}
}
function attribute(_, ctx) {
return (initial) => initial
}
@element('foo-el')
class Foo extends HTMLElement {
@attribute foo = 123
}
Configuration file name
babel.config.json
Configuration
module.exports = {
plugins: [
['@babel/plugin-transform-typescript', {allowDeclareFields: true}],
['@babel/plugin-proposal-decorators', {version: '2022-03'}],
['@babel/plugin-proposal-class-static-block'],
],
presets: [
['@babel/preset-typescript', {isTSX: true, allExtensions: true, onlyRemoveTypeImports: true}],
['babel-preset-solid'],
]
}
Current and expected behavior
Initializers in the output are undefined when constructor runs during the customElements.define() call (element upgrade) inside the @element decorator.
Environment
System:
OS: macOS 13.0.1
Binaries:
Node: 18.12.1 - ~/.n-node-versions/bin/node
npm: 8.19.3 - ~/.npm-packages/bin/npm
npmPackages:
@babel/cli: 7.18.10 => 7.18.10
@babel/core: 7.19.1 => 7.19.1
@babel/plugin-proposal-class-static-block: 7.18.6 => 7.18.6
@babel/plugin-proposal-decorators: 7.19.1 => 7.19.1
@babel/preset-typescript: 7.18.6 => 7.18.6
@babel/runtime: 7.19.0 => 7.19.0
babel-loader: 8.2.5 => 8.2.5
babel-preset-solid: 1.5.4 => 1.5.4
webpack: 5.74.0 => 5.74.0
Possible solution
No response
Additional context
No response
💻
How are you using Babel?
babel-loader (webpack)
Input code
Configuration file name
babel.config.json
Configuration
Current and expected behavior
Initializers in the output are
undefinedwhenconstructorruns during thecustomElements.define()call (element upgrade) inside the@elementdecorator.Environment
Possible solution
No response
Additional context
No response