@@ -10,20 +10,24 @@ import { describe, it, expect } from 'vitest';
10
10
import { rollup , type RollupLog , type Plugin , type RollupBuild } from 'rollup' ;
11
11
import nodeResolve from '@rollup/plugin-node-resolve' ;
12
12
13
- import lwc from '../../index' ;
13
+ import lwc , { type RollupLwcOptions } from '../../index' ;
14
14
15
15
const fixturesdir = path . resolve ( __dirname , 'fixtures' ) ;
16
16
17
17
async function runRollup (
18
18
pathname : string ,
19
- { plugins = [ ] as Plugin [ ] } = { }
19
+ {
20
+ plugins = [ ] as Plugin [ ] ,
21
+ external = [ 'lwc' , '@lwc/synthetic-shadow' , '@lwc/wire-service' ] ,
22
+ options = undefined as RollupLwcOptions | undefined ,
23
+ } = { }
20
24
) : Promise < { bundle : RollupBuild ; warnings : RollupLog [ ] } > {
21
25
const warnings : RollupLog [ ] = [ ] ;
22
26
23
27
const bundle = await rollup ( {
24
28
input : path . resolve ( fixturesdir , pathname ) ,
25
- plugins : [ lwc ( ) , ...plugins ] ,
26
- external : [ 'lwc' , '@lwc/synthetic-shadow' , '@lwc/wire-service' ] ,
29
+ plugins : [ lwc ( options ) , ...plugins ] ,
30
+ external,
27
31
onwarn ( warning ) {
28
32
warnings . push ( warning ) ;
29
33
} ,
@@ -36,9 +40,19 @@ async function runRollup(
36
40
}
37
41
38
42
describe ( 'resolver' , ( ) => {
39
- it ( 'should be capable to resolve all the base LWC module imports' , async ( ) => {
40
- const { warnings } = await runRollup ( 'lwc-modules/lwc-modules.js' ) ;
43
+ it ( 'should be capable to resolve all the base LWC module imports without @rollup/plugin-node-resolve' , async ( ) => {
44
+ const { warnings } = await runRollup ( 'lwc-modules/lwc-modules.js' , { external : [ ] } ) ;
45
+ expect ( warnings ) . toHaveLength ( 0 ) ;
46
+ } ) ;
41
47
48
+ it ( 'should be capable to resolve all the base LWC modules using @rollup/plugin-node-resolve' , async ( ) => {
49
+ const { warnings } = await runRollup ( 'lwc-modules/lwc-modules.js' , {
50
+ external : [ ] ,
51
+ plugins : [ nodeResolve ( ) ] ,
52
+ options : {
53
+ defaultModules : [ ] ,
54
+ } ,
55
+ } ) ;
42
56
expect ( warnings ) . toHaveLength ( 0 ) ;
43
57
} ) ;
44
58
@@ -75,7 +89,7 @@ describe('resolver', () => {
75
89
} ) ;
76
90
} ) ;
77
91
78
- it ( 'should properly resolve modules with @rollup/rollup -node-resolve and third-party package' , async ( ) => {
92
+ it ( 'should properly resolve modules with @rollup/plugin -node-resolve and third-party package' , async ( ) => {
79
93
const { warnings } = await runRollup ( 'third-party-import/src/main.js' , {
80
94
plugins : [ nodeResolve ( ) ] ,
81
95
} ) ;
0 commit comments