Closed chicken-suop closed 3 years ago
Solved by @bathos.
Change var UpdatingElement = require('lit-element/lib/updating-element');
to import { UpdatingElement } from 'lit-element/lib/updating-element';
. Use this babel transform:
.transform(babelify, {
only: [
/components\/tool-panel\/node_modules\/(?:lit-element|lit-html)/,
/components\/tool-panel/
],
global: true,
presets: [
['@babel/preset-env', {
'targets': {
esmodules: true,
},
'bugfixes': true
}]
],
plugins: ['@babel/plugin-transform-modules-commonjs']
})
(or use @babel/plugin-transform-runtime)
Description
I'm trying to refactor a large legacy application, by componentizing various parts. It was going quite well, until I tried to use the component. The legacy component uses browserify to build a bundle. After importing the component in the legacy app, that browserify step fails with this error:
My component:
Now, I tried to solve this issue by adding a babel transform step to browserify:
That solves the above error, and lets me build a bundle successfully. Another issue appears though, when I load the legacy app in the browser:
Package versions
"@babel/core": "^7.12.3", "@babel/preset-env": "^7.12.1", "babelify": "10.0.0", "browserify": "^12.0.1", "lit-element": "^2.3.1",
Acceptance criteria
The component must be useable in the legacy app, without browser or build issues.