You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Implemented support for dynamic requires (transferred PR)
Moved from rollup/rollup-plugin-commonjs#331
* Only add dynamic loader code when dynamic feature is enabled
* test(commonjs): update snapshots for easier diffing
* Automatically remove user paths
* test(commonjs): Prepare tests to support code-splitting
* test(commonjs): Try to add a code-splitting test
* Fixed code-splitting support
* Cleanup: avoid importing commonjs-proxy when we only need to register
* Fixed test
* Updated pnpm-lock
* Updated snapshots
* Satisfy linter
Co-authored-by: Lukas Taegert-Atkinson <[email protected]>
Copy file name to clipboardExpand all lines: packages/commonjs/README.md
+27Lines changed: 27 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,33 @@ Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#comma
44
44
45
45
## Options
46
46
47
+
### `dynamicRequireTargets`
48
+
49
+
Type: `String|Array[String]`<br>
50
+
Default: `[]`
51
+
52
+
Some modules contain dynamic `require` calls, or require modules that contain circular dependencies, which are not handled well by static imports.
53
+
Including those modules as `dynamicRequireTargets` will simulate a CommonJS (NodeJS-like) environment for them with support for dynamic and circular dependencies.
54
+
55
+
_Note: In extreme cases, this feature may result in some paths being rendered as absolute in the final bundle. The plugin tries to avoid exposing paths from the local machine, but if you are `dynamicRequirePaths` with paths that are far away from your project's folder, that may require replacing strings like `"/Users/John/Desktop/foo-project/"` -> `"/"`._
56
+
57
+
Example:
58
+
59
+
```js
60
+
commonjs({
61
+
dynamicRequireTargets: [
62
+
// include using a glob pattern (either a string or an array of strings)
63
+
'node_modules/logform/*.js',
64
+
65
+
// exclude files that are known to not be required dynamically, this allows for better optimizations
0 commit comments