rolldown-plugin-dts 0.9.8 → 0.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +18 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -229,6 +229,7 @@ const RE_TS = /\.([cm]?)tsx?$/;
229
229
  const RE_DTS = /\.d\.([cm]?)ts$/;
230
230
  const RE_DTS_MAP = /\.d\.([cm]?)ts\.map$/;
231
231
  const RE_NODE_MODULES = /[\\/]node_modules[\\/]/;
232
+ const RE_CSS = /\.css$/;
232
233
  function filename_js_to_dts(id) {
233
234
  return id.replace(RE_JS, ".d.$1ts");
234
235
  }
@@ -289,7 +290,7 @@ function createFakeJsPlugin({ dtsInput, sourcemap }) {
289
290
  entryFileNames: options.entryFileNames ?? (dtsInput ? "[name].ts" : void 0),
290
291
  chunkFileNames(chunk) {
291
292
  const original = (typeof options.chunkFileNames === "function" ? options.chunkFileNames(chunk) : options.chunkFileNames) || "[name]-[hash].js";
292
- if (!original.includes(".d") && chunk.name.endsWith(".d")) return filename_js_to_dts(original);
293
+ if (!original.includes(".d") && chunk.name.endsWith(".d")) return original.replace(RE_JS, ".$1ts");
293
294
  return original;
294
295
  }
295
296
  };
@@ -881,6 +882,11 @@ function createDtsResolvePlugin({ tsconfig, resolve, resolvePaths }) {
881
882
  order: "pre",
882
883
  async handler(id, importer, options) {
883
884
  if (!importer || !RE_DTS.test(importer) && !this.getModuleInfo(importer)?.meta.dtsFile) return;
885
+ if (RE_CSS.test(id)) return {
886
+ id,
887
+ external: true,
888
+ moduleSideEffects: false
889
+ };
884
890
  if (RE_NODE_MODULES.test(importer)) {
885
891
  const resolution$1 = resolver(id, importer);
886
892
  if (resolution$1) return {
@@ -891,10 +897,17 @@ function createDtsResolvePlugin({ tsconfig, resolve, resolvePaths }) {
891
897
  if (!resolvePaths && (RE_NODE_MODULES.test(id) || !isRelative(id))) return resolveDependency(id, importer);
892
898
  let resolution = await this.resolve(id, importer, options);
893
899
  if (!resolution && !id.endsWith(".d")) resolution = await this.resolve(`${id}.d`, importer, options);
894
- if (resolution?.id.startsWith("\0")) return {
895
- ...resolution,
896
- meta
897
- };
900
+ if (resolution?.id) {
901
+ if (RE_CSS.test(resolution.id)) return {
902
+ id,
903
+ external: true,
904
+ moduleSideEffects: false
905
+ };
906
+ if (resolution.id.startsWith("\0")) return {
907
+ ...resolution,
908
+ meta
909
+ };
910
+ }
898
911
  if (resolvePaths && (RE_NODE_MODULES.test(resolution?.id || id) || !isRelative(resolution?.id || id))) return resolveDependency(id, importer);
899
912
  if (!resolution || resolution.external) return resolution;
900
913
  if (RE_JS.test(resolution.id)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "description": "A Rolldown plugin to bundle dts files",
5
5
  "type": "module",
6
6
  "license": "MIT",