小编Eri*_*ria的帖子

Vitest - @src 文件夹别名在测试文件中未解析

我有一个使用 Vite/Vitest 的 vue3 项目,如 Vue.js 文档中的推荐。

这是该项目的结构:

src
  components
    // my Vue components here, potentially in sub-folders. For example:
    HelloWorld.vue 
  router
    index.ts
  App.vue
  main.ts
vitest
  components
    // My test specs. For example:
    HelloWorld.spec.ts
// ...
tsconfig.app.json
tsconfig.json
tsconfig.vite-config.json
tsconfig.vitest.json
vite.config.ts
Run Code Online (Sandbox Code Playgroud)

@/文件夹的别名在src组件文件中正确解析。但是,在我的测试文件中,我收到错误:找不到模块。

例如,在HelloWorld.spec.ts

src
  components
    // my Vue components here, potentially in sub-folders. For example:
    HelloWorld.vue 
  router
    index.ts
  App.vue
  main.ts
vitest
  components
    // My test specs. For example:
    HelloWorld.spec.ts
// ...
tsconfig.app.json
tsconfig.json
tsconfig.vite-config.json
tsconfig.vitest.json …
Run Code Online (Sandbox Code Playgroud)

typescript vuejs3 vite vitest

34
推荐指数
3
解决办法
3万
查看次数

使用 vite 构建应用程序时如何从捆绑包中排除 JS 脚本?

由于另一个问题,我必须在 vue3 应用程序中静态导入 HTML 中的 JS 依赖项。

/index.html

<head>
    <!-- ... -->
    <script type="module" src="node_modules/@telekom/scale-components-neutral/dist/scale-components/scale-components.esm.js"></script>
</head>
Run Code Online (Sandbox Code Playgroud)

由于 Vite 无法正确捆绑此依赖项(由于问题,请参阅上面提到的帖子),我希望捆绑忽略它。在生产版本中,我希望 JS 模块按原样导入到 root 中index.html

我尝试了配置属性中的几乎所有内容optimizeDeps.exclude,但 Vite 仍然尝试分析和预捆绑它。

vite.config.ts

export default defineConfig({
  optimizeDeps: {
    exclude: [
      // I tried pretty much everything here: no way to force vite pre-bundling to ignore it...
      'scale-components-neutral'
      '@telekom/scale-components-neutral'
      '@telekom/scale-components-neutral/**/*'
      '@telekom/scale-components-neutral/**/*.js'
      'node_modules/@telekom/scale-components-neutral/**/*.js'
    ],
  },
  // ...
});
Run Code Online (Sandbox Code Playgroud)

在每种情况下,运行后npm run build,导入都会从 中删除dist/index.html

配置期望什么optimizeDeps.exclude


编辑

在https://vitejs.dev/guide/dep-pre-bundling.html中找到此注释: …

rollupjs vuejs3 vite

12
推荐指数
1
解决办法
2万
查看次数

使用Grunt管理AngularJS模块版本和发行版

目前,我有多个角度模块.自定义Grunt任务进行连接,缩小并打包每个模块,以便可以部署.我还没有做的唯一事情就是管理这些模块的版本.

每个项目(每个模块一个)包含一个package.json文件,其中我声明了组件的名称和版本:

{
    "name": "my-module",
    "version" : "1.0.0",
    // etc.
}
Run Code Online (Sandbox Code Playgroud)

所以每个模块都建在一个目录*/dist/my-module/1.0.0 /

但是,在模块本身,我需要访问它的版本.例如,在控制器中,我声明了一个变量$scope.version = '1.0.0'.但是目前,它在控制器脚本中是硬编码的.


第一个问题,有没有一种方法模块可以从package.json文件中获取版本?或者构建应用程序的grunt任务用模块的当前版本替换脚本中的给定标志?(例如,我可以声明我的变量$scope.version = 'FLAG_VERSION'知道在构建期间grunt将用正确的值替换标志)


第二个问题,是否有一些grunt组件允许在我的VCS(例如SVN)中标记模块的当前版本,然后增加当前版本?简而言之,执行模块的发布.

编辑:有关此问题的新问题,请参阅使用Grunt在SVN上Bump特定版本号


任何帮助或领导将不胜感激!

javascript angularjs gruntjs

8
推荐指数
1
解决办法
953
查看次数

AngularJS module.constant():如何仅在模块内定义常量?

在页面上,我有几个Angular模块.对于每个模块,我定义一个包含模块版本的常量.

var module1 = angular.module('module1').constant('version', '1.2.3');
var module2 = angular.module('module2').constant('version', '2.0.0');
...
Run Code Online (Sandbox Code Playgroud)

我虽然模块中定义了一个常量.但是当我在module1中使用常量时,我得到的值是'2.0.0'......

有没有办法定义一个适合模块的常量(或其他任何东西)?

编辑:对于替代解决方案,您能否解释一下如何使用它,例如在控制器声明中?

module2.controller('myCtrl', function( $scope, $http, $q, ..., version ){
    // Here I can use the constant 'version'
}
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

7
推荐指数
1
解决办法
6045
查看次数

使用 Quarkus 和 Resteasy 在运行时定义客户端目标 URL

我需要从 Quarkus 应用程序发送 HTTP 请求。按照本指南,我有这个 RestClient:

@Path("/v1")
@RegisterRestClient
public interface CountriesService {

    @GET
    @Path("/name/{name}")
    Set<Country> getByName(@PathParam String name);
}
Run Code Online (Sandbox Code Playgroud)

Path注释中,我可以配置路径。但根据本段,要调用的域/url 是在配置文件中定义的。

# Your configuration properties
org.acme.rest.client.CountriesService/mp-rest/url=https://restcountries.eu/rest # 
org.acme.rest.client.CountriesService/mp-rest/scope=javax.inject.Singleton #
Run Code Online (Sandbox Code Playgroud)

就我而言,我需要在运行时以编程方式定义此 URL,因为我将其作为回调 URL 接收。

有没有办法做到这一点?

java resteasy quarkus

7
推荐指数
1
解决办法
2644
查看次数

Node.js版本控制:v4 +和v0.12.X之间的差异

Node.js版本> = 4.0.0和版本0.1.X到0.12.X之间有什么区别?

在这个页面上https://nodejs.org/en/download/releases/,我知道Node.js v4 +是旧Node.js和io.js之间的融合.但v0.12.9已于2015-12-03发布, v4.0.0(2015-09-08)几个月.

那么,3个分支仍然活跃吗?他们之间有什么区别?

node.js

5
推荐指数
1
解决办法
1461
查看次数

使用 Spring Boot 的 Spring Batch - 永远不要重试写入错误

我使用 Spring Boot 创建了一个批处理。这是批处理的主要配置类:

@Configuration
@EntityScan({"my.domain"})
@EnableJpaRepositories({"my.domain"})
@EnableBatchProcessing
public class BatchConfiguration {

    /** Motif d'identification des fichiers d'entrée */
    @Value("${batch.input-file-pattern}")
    private String inputFilePattern;

    @Bean
    public BatchConfigurer configurer( EntityManagerFactory entityManagerFactory ){ 
        return new MapForcedBatchConfigurer( entityManagerFactory ); 
    }

    @Bean
    public Job myJob( JobBuilderFactory jobs, Step step1 ){
        return jobs.get("myJob")
                .incrementer( new RunIdIncrementer() )
                .flow( step1 )
                .end()
                .build();
    }

    @Bean
    public Step step1( StepBuilderFactory stepBuilderFactory, 
            StepExecutionListener stepExecutionListener,
            ItemReader<Input> myReader,
            ItemProcessor<Input, Dto> myProcessor, 
            ItemWriter<Dto> myWriter ){
        return stepBuilderFactory.get("myStep")
                .listener( stepExecutionListener )
                .<Input, Dto> …
Run Code Online (Sandbox Code Playgroud)

java spring spring-batch spring-boot

5
推荐指数
1
解决办法
4057
查看次数

Spring ResponseEntity:使用构造函数还是静态生成器?

在Spring Boot RestController中,我使用springframework类ResponseEntity返回端点调用的响应。

最近,我发现有两种方法可以实例化此类。

使用构造函数:

response = new ResponseEntity<MyDto>(myDto, myHeaders, HttpStatus.OK);
Run Code Online (Sandbox Code Playgroud)

使用静态生成器:

response = ResponseEntity.ok().headers(myHeaders).body(myDto);
Run Code Online (Sandbox Code Playgroud)

结果实例接缝是相同的。

我想知道每种技术的优缺点是什么? 在哪种情况下,我应该优先使用其中一种?

java spring spring-boot

5
推荐指数
2
解决办法
5622
查看次数

使用 Quarkus 和 Resteasy 从主控制器外部访问路径参数

我将 Resteasy 与 Quarkus 一起使用 ( io.quarkus.quarkus-resteasy)。

我有一个在控制器上声明参数的路径。

@RequestScoped
@Path("/v1/domain/{domain}/resource")
public class MyRestController {

    @POST
    @Consumes(APPLICATION_JSON)
    public Response create(Entity entity) {
        // here I create a new entity...
    }
    
    @GET
    @Path("/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response get(@PathParam("id") String id) {
        // get and return the entity...
    }

}
Run Code Online (Sandbox Code Playgroud)

我想从该控制器外部、例如domain标有 的提供程序中或在处理传入请求的任何拦截器中检索路径参数。@Dependent

@Dependent
public class DomainProvider {

    @Produces
    @RequestScoped
    public Domain domain() {
        // retrieve the path param here !
    }
}
Run Code Online (Sandbox Code Playgroud)

我没有找到一种方法来做到这一点,也没有找到相关的文档。

我都尝试过:

  • 注入io.vertx.ext.web.RoutingContext@Inject访问routingContext.pathParams() …

java resteasy quarkus

4
推荐指数
1
解决办法
3358
查看次数

在WS SoapFault中添加细节:不使用我的自定义ExceptionResolver

我正在使用Spring Boot(1.2.4.RELEASE)构建一个Web服务,我对这个框架很新.特别是,我正在尝试在抛出异常时自定义SoapFault内容(添加"detail"标记).

我按照这篇文章这样做:http://www.stevideter.com/2009/02/18/of-exceptionresolvers-and-xmlbeans/

这是我的例外:

package foo.bar.exception;

import org.springframework.ws.soap.server.endpoint.annotation.FaultCode;
import org.springframework.ws.soap.server.endpoint.annotation.SoapFault;

@SoapFault(faultCode = FaultCode.SERVER)
public class ServiceException extends Exception {

    private static final long serialVersionUID = -1804604596179996724L;

    private String tempFaultDetail;

    public ServiceException(){
        super("ServiceException");
    }

    public ServiceException(String message) {
        super(message);
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
    }

    public ServiceException(String message, Throwable cause, String fautDetail) {
        super(message, cause);
        setTempFaultDetail( fautDetail );
    }


    public String getTempFaultDetail() {
        return tempFaultDetail;
    }

    public void setTempFaultDetail(String tempFaultDetail) {
        this.tempFaultDetail …
Run Code Online (Sandbox Code Playgroud)

spring spring-ws spring-boot

3
推荐指数
1
解决办法
6235
查看次数