Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/twelve-impalas-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'ko': patch
---

feat(ko): #180 expose babelIncludes option for ES2020+ packages
1 change: 1 addition & 0 deletions packages/ko/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Config {
disableLazyImports: false,
},
autoPolyfills: false,
babelIncludes: [],
};
}
}
Expand Down
16 changes: 16 additions & 0 deletions packages/ko/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ export type IOptions = {
* @param {HookOptions[]}
*/
plugins?: HookOptions[];
/**
* Additional packages/paths to transpile via Babel, on top of ko's defaults.
*
* ko already transpiles these by default (they publish ES2020+ syntax):
* - `immer`
* - `react-grid-layout`
* - `monaco-editor`
* - internal `dt-common` source (`node_modules/dt-common/src/**`)
*
* You do not need to re-list them here. Use this to add your own
* ES2020+ packages that ko doesn't know about. Entries are matched
* as substring against the file path.
*
* @param {string[]}
*/
babelIncludes?: string[];
/**
* The path to the HTML template to use for the application.
* @param {string}
Expand Down
6 changes: 5 additions & 1 deletion packages/ko/src/webpack/loaders/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ class Script {
return true;
} else if (input.includes('monaco-editor')) {
return true;
} else if (input.includes('node_modules')) {
}
if (this.opts.babelIncludes?.some(item => item && input.includes(item))) {
return true;
}
if (input.includes('node_modules')) {
return false;
} else {
return true;
Expand Down