plugins-index.mjs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import "./shared/binding-C5G6_6ql.mjs";
  2. import { a as makeBuiltinPluginCallable, n as BuiltinPlugin } from "./shared/normalize-string-or-regex-C5RWbu3O.mjs";
  3. import { t as esmExternalRequirePlugin } from "./shared/constructors-Ctal_Rbv.mjs";
  4. //#region src/builtin-plugin/replace-plugin.ts
  5. /**
  6. * Replaces targeted strings in files while bundling.
  7. *
  8. * @example
  9. * **Basic usage**
  10. * ```js
  11. * replacePlugin({
  12. * 'process.env.NODE_ENV': JSON.stringify('production'),
  13. * __buildVersion: 15
  14. * })
  15. * ```
  16. * @example
  17. * **With options**
  18. * ```js
  19. * replacePlugin({
  20. * 'process.env.NODE_ENV': JSON.stringify('production'),
  21. * __buildVersion: 15
  22. * }, {
  23. * preventAssignment: false,
  24. * })
  25. * ```
  26. *
  27. * @see https://rolldown.rs/builtin-plugins/replace
  28. * @category Builtin Plugins
  29. */
  30. function replacePlugin(values = {}, options = {}) {
  31. Object.keys(values).forEach((key) => {
  32. const value = values[key];
  33. if (typeof value !== "string") values[key] = String(value);
  34. });
  35. return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:replace", {
  36. ...options,
  37. values
  38. }));
  39. }
  40. //#endregion
  41. export { esmExternalRequirePlugin, replacePlugin };