@@ -174,3 +174,43 @@ test('build as lib with --filename option', async () => {
174174 return window . testLib . bar
175175 } ) ) . toBe ( 2 )
176176} )
177+
178+ test ( 'build as lib without --name and --filename options (default to package name)' , async ( ) => {
179+ const project = await create ( 'build-lib-no-name-and-filename-option' , defaultPreset )
180+ await project . write ( 'package.json' , `
181+ {
182+ "name": "test-lib"
183+ }
184+ ` )
185+ await project . write ( 'src/main.js' , `
186+ export default { foo: 1 }
187+ export const bar = 2
188+ ` )
189+ const { stdout } = await project . run ( 'vue-cli-service build --target lib src/main.js' )
190+ expect ( stdout ) . toMatch ( 'Build complete.' )
191+
192+ expect ( project . has ( 'dist/demo.html' ) ) . toBe ( true )
193+ expect ( project . has ( 'dist/test-lib.common.js' ) ) . toBe ( true )
194+ expect ( project . has ( 'dist/test-lib.umd.js' ) ) . toBe ( true )
195+ expect ( project . has ( 'dist/test-lib.umd.min.js' ) ) . toBe ( true )
196+ } )
197+
198+ test ( 'build as lib without --name and --filename options (default to package name, minus scope)' , async ( ) => {
199+ const project = await create ( 'build-lib-no-name-and-filename-option-with-scope' , defaultPreset )
200+ await project . write ( 'package.json' , `
201+ {
202+ "name": "@foo/test-lib"
203+ }
204+ ` )
205+ await project . write ( 'src/main.js' , `
206+ export default { foo: 1 }
207+ export const bar = 2
208+ ` )
209+ const { stdout } = await project . run ( 'vue-cli-service build --target lib src/main.js' )
210+ expect ( stdout ) . toMatch ( 'Build complete.' )
211+
212+ expect ( project . has ( 'dist/demo.html' ) ) . toBe ( true )
213+ expect ( project . has ( 'dist/test-lib.common.js' ) ) . toBe ( true )
214+ expect ( project . has ( 'dist/test-lib.umd.js' ) ) . toBe ( true )
215+ expect ( project . has ( 'dist/test-lib.umd.min.js' ) ) . toBe ( true )
216+ } )
0 commit comments