如何在 Gradle 项目中为 @vaadin/vaadin-element-mixin 添加依赖?

huangapple go评论48阅读模式
英文:

How to add dependency for @vaadin/vaadin-element-mixin in a gradle project

问题

The code you provided appears to be an error message and code related to building a web component, specifically involving Vaadin components in a JavaScript project. It seems to be missing a dependency and encountering issues with the build process.

The error message indicates that the dependency '@vaadin/vaadin-element-mixin' is missing, and it suggests that this module should be added to 'build.rollupOptions.external.' It also mentions issues with TypeScript and Gradle.

It seems like you are looking for a solution or hint on how to resolve these issues. To address this problem, you may need to:

  1. Ensure that you have the necessary dependencies installed. You should have '@vaadin/vaadin-element-mixin' in your project's dependencies.

  2. Check your project's configuration files, such as 'package.json' and any configuration files for your build tools. Make sure that the dependencies are correctly listed.

  3. If you're using Gradle, make sure you've added the dependency correctly in your Gradle configuration.

  4. Verify that the versions of the dependencies are compatible with your project.

  5. It's important to ensure that the module paths and imports in your code are accurate and match the project structure.

  6. If you're encountering TypeScript issues, check your TypeScript configuration files (e.g., 'tsconfig.json') to make sure the paths and typings are correctly set up.

  7. Make sure you have all the required files and resources in the right locations.

The specific solution to your problem may require more detailed analysis of your project's setup and configuration. You may also want to consult the documentation for Vaadin and your build tools to resolve these issues.

英文:

While trying to change and build the web-component SelectionGrid

import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
import { ElementMixin } from '@vaadin/vaadin-element-mixin';
import { GridElement } from  '@vaadin/vaadin-grid/src/vaadin-grid.js';

import {
_getItemOverriden,
_selectionGridSelectRow,
_selectionGridSelectRowWithItem
} from './helpers';

class VcfSelectionGridElement extends ElementMixin(ThemableMixin(GridElement)) {

    constructor() {

....

i get a

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':vaadinBuildFrontend'.
> Vite process exited with non-zero exit code.
  Stderr: 'vite v3.2.5 building for production...
  transforming...
  ✓ 112 modules transformed.
  [vite]: Rollup failed to resolve import "@vaadin/vaadin-element-mixin" from "frontend/src/vcf-sel-table.js".
  This is most likely unintended because it can break your application at runtime.
  If you do want to externalize this module explicitly add it to
  `build.rollupOptions.external`
  error during build:
  Error: [vite]: Rollup failed to resolve import "@vaadin/vaadin-element-mixin" from "frontend/src/vcf-sel-table.js".
  This is most likely unintended because it can break your application at runtime.
  If you do want to externalize this module explicitly add it to
  `build.rollupOptions.external`
      at onRollupWarning ()
      at onwarn ()
      at Object.onwarn ()
      at ModuleLoader.handleResolveId ()
      at 

Obviously the dependency @vaadin/vaadin-element-mixin is missing. The dependency for the @vaadin/vaadin-themable-mixin is present in the packages.json; but not the element-mixin. Since packages.json is generated by the vaadinPrepareFrontend task i do not have a clue where i can add that dependency.

I m also wondering where and how that @vaadin in typescript is resolved. I assume all the ts for the web-components is packaged in jar files ...

I tried to add a dependency to the gradle file - of course to no avail

dependencies {
    implementation("org.webjars.bowergithub.vaadin:vaadin-element-mixin:2.4.2")

Any hint appreciated what i should investigate ...

答案1

得分: 3

The correct import path is now:

import { ElementMixin } from '@vaadin/component-base/src/element-mixin';
英文:

You are probably using Vaadin 23 and you have copied the code from the components repository's master branch, which is for Vaadin 14.

The correct import path is now:

import { ElementMixin } from '@vaadin/component-base/src/element-mixin';

huangapple
  • 本文由 发表于 2023年3月7日 21:41:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75662736.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定