-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Milestone
Description
The way externals are currently defined makes it impossible for to export own's library to the global this.
Example config:
module.exports = {
// ...
name: 'myPlugin',
entry: {
components: filePath( 'assets/src/components/index.js' ),
dashboard: filePath( 'assets/src/dashboard.js' ),
preview: filePath( 'assets/src/preview.js' ),
},
output: {
library: [ 'myPlugin', '[name]' ],
libraryTarget: 'this',
path: filePath( '/assets/dist/' ),
},
resolve: {
alias: {
'@myPlugin/components': filePath( '/assets/src/components/' ),
},
},
};The intention was to make the entrypoints available under this.myPlugin object. However, since webpack helpers defined the externals differently, they're overriden by this config.
From webpack docs:
Note that not setting a output.library will cause all properties returned by the entry point to be assigned to the given object; there are no checks against existing property names.
One possible solution is to update externals definition to:
[ `@wordpress/${ name }` ]: { this: [ 'wp', camelCaseDash( name ) ] }Metadata
Metadata
Assignees
Labels
No labels