-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): support named exports when building --target lib with js…
…/ts entry close #1436 BREAKING CHANGE: When building a js/ts entry file with --target lib, the library now exposes a Module with both default and named exports. This means in the UMD build, the default export now needs to be accessed as `window.yourLib.default`, and in the CommonJS build as `const yourLib = require('yourLib').default`. If you don't have named exports and want to retain the previous behavior, you can configure webpack to use `output.libraryExport: 'default'` in `vue.config.js`.
- Loading branch information
Showing
3 changed files
with
62 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/@vue/cli-service/lib/commands/build/demo-lib-js.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<title><%- htmlWebpackPlugin.options.libName %> demo</title> | ||
<script src="./<%- htmlWebpackPlugin.options.libName %>.umd.js"></script> | ||
<link rel="stylesheet" href="./<%- htmlWebpackPlugin.options.libName %>.css"> | ||
|
||
<script> | ||
console.log(<%- htmlWebpackPlugin.options.libName %>) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1dc47eb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could someone please explain where to put
output.libraryExport: 'default'
invue.config.js
? I looked at the help page and saw no such setting.