Skip to content

Commit

Permalink
Merge pull request #29 from JakeGinnivan/feat/allow-exclude-from-bundle
Browse files Browse the repository at this point in the history
Allow bundling of all modules, except those specified
  • Loading branch information
JakeGinnivan authored Oct 14, 2019
2 parents db99cfc + 5347ad6 commit d4f753f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export interface BuildConfig {
/** if true, all externals will be bundled */
SERVER_BUNDLE_ALL: boolean

/** Include all modules, except those specified */
SERVER_BUNDLE_ALL_EXCEPT?: string[]

/** modules which the server build includes in the bundle */
SERVER_INCLUDE_IN_BUNDLE: string[]

Expand Down
11 changes: 10 additions & 1 deletion lib/config/webpack.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,17 @@ const serverBaseConfig = (options: CreateWebpackConfigOptions): webpack.Configur
// treat deep imports as externals as well
const moduleName = request.split('/')[0]

if (options.buildConfig.SERVER_BUNDLE_ALL) {
if (
options.buildConfig.SERVER_BUNDLE_ALL &&
!options.buildConfig.SERVER_BUNDLE_ALL_EXCEPT
) {
callback(undefined, undefined)
} else if (options.buildConfig.SERVER_BUNDLE_ALL_EXCEPT) {
if (options.buildConfig.SERVER_BUNDLE_ALL_EXCEPT.indexOf(moduleName) !== -1) {
callback(null, 'commonjs ' + request)
} else {
callback(undefined, undefined)
}
} else if (options.buildConfig.SERVER_INCLUDE_IN_BUNDLE.indexOf(moduleName) !== -1) {
callback(undefined, undefined)
} else if (nodeModules.indexOf(moduleName) !== -1) {
Expand Down
3 changes: 3 additions & 0 deletions lib/runtime/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export interface BuildConfig {
/** if true, all externals will be bundled */
SERVER_BUNDLE_ALL: boolean

/** Include all modules, except those specified */
SERVER_BUNDLE_ALL_EXCEPT?: string[]

/** modules which the server build includes in the bundle */
SERVER_INCLUDE_IN_BUNDLE: string[]

Expand Down

0 comments on commit d4f753f

Please sign in to comment.