robuild 0.0.8 → 0.0.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.
@@ -1043,11 +1043,48 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1043
1043
  }
1044
1044
  return;
1045
1045
  }
1046
- const externalDeps = [
1046
+ let externalDeps = [
1047
1047
  ...builtinModules,
1048
1048
  ...builtinModules.map((m) => `node:${m}`),
1049
1049
  ...[...Object.keys(ctx.pkg.dependencies || {}), ...Object.keys(ctx.pkg.peerDependencies || {})].flatMap((p) => [p, /* @__PURE__ */ new RegExp(`^${p}/`)])
1050
1050
  ];
1051
+ if (entry.noExternal) {
1052
+ const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1053
+ if (typeof entry.noExternal === "function") {
1054
+ const predicate = entry.noExternal;
1055
+ const depNames = [...Object.keys(ctx.pkg.dependencies || {}), ...Object.keys(ctx.pkg.peerDependencies || {})];
1056
+ const excludedNames = /* @__PURE__ */ new Set();
1057
+ for (const name of depNames) try {
1058
+ if (predicate(name)) excludedNames.add(name);
1059
+ } catch {}
1060
+ externalDeps = externalDeps.filter((dep) => {
1061
+ if (typeof dep === "string") return !excludedNames.has(dep);
1062
+ if (dep instanceof RegExp) {
1063
+ for (const name of excludedNames) if (dep.source.startsWith(`^${escapeRegExp(name)}/`)) return false;
1064
+ return true;
1065
+ }
1066
+ return true;
1067
+ });
1068
+ } else if (Array.isArray(entry.noExternal)) {
1069
+ const rules = entry.noExternal;
1070
+ externalDeps = externalDeps.filter((dep) => {
1071
+ for (const rule of rules) if (typeof rule === "string") {
1072
+ if (typeof dep === "string") {
1073
+ if (dep === rule) return false;
1074
+ } else if (dep instanceof RegExp) {
1075
+ if (dep.source.startsWith(`^${escapeRegExp(rule)}/`)) return false;
1076
+ }
1077
+ } else if (rule instanceof RegExp) {
1078
+ if (typeof dep === "string") {
1079
+ if (rule.test(dep)) return false;
1080
+ } else if (dep instanceof RegExp) {
1081
+ if (dep.source === rule.source && dep.flags === rule.flags) return false;
1082
+ }
1083
+ }
1084
+ return true;
1085
+ });
1086
+ }
1087
+ }
1051
1088
  if (entry.external) if (typeof entry.external === "function") {} else externalDeps.push(...entry.external);
1052
1089
  const defineOptions = {};
1053
1090
  if (entry.env) for (const [key, value] of Object.entries(entry.env)) defineOptions[`process.env.${key}`] = JSON.stringify(value);
@@ -2063,42 +2100,30 @@ async function triggerRebuild(watchCtx) {
2063
2100
  * Get patterns for files to watch
2064
2101
  */
2065
2102
  async function getWatchPatterns(config, ctx, watchOptions) {
2066
- if (watchOptions.include && watchOptions.include.length > 0) return watchOptions.include.map(normalizeGlobPattern);
2067
- const patterns = /* @__PURE__ */ new Set();
2068
- const addPattern = (pattern) => {
2069
- if (!pattern) return;
2070
- patterns.add(normalizeGlobPattern(pattern));
2071
- };
2072
- const addFilePatterns = (inputFile) => {
2073
- const absoluteInput = resolveToAbsolute(inputFile, ctx);
2074
- const filePattern = normalizeRelativeToPkg(absoluteInput, ctx);
2075
- if (filePattern && filePattern !== ".") addPattern(filePattern);
2076
- addPattern(getDirGlobPattern(dirname(absoluteInput), ctx));
2077
- };
2078
- const addDirectoryPatterns = (inputDir) => {
2079
- const absoluteDir = resolveToAbsolute(inputDir, ctx);
2080
- addPattern(getDirGlobPattern(absoluteDir, ctx));
2081
- };
2103
+ if (watchOptions.include && watchOptions.include.length > 0) return watchOptions.include;
2104
+ const patterns = [];
2082
2105
  for (const entry of config.entries || []) if (typeof entry === "string") {
2083
2106
  const [input] = entry.split(":");
2084
- if (input.endsWith("/")) addDirectoryPatterns(input);
2107
+ if (input.endsWith("/")) patterns.push(`${input}**/*`);
2085
2108
  else {
2086
2109
  const inputs = input.split(",");
2087
- for (const inputFile of inputs) addFilePatterns(inputFile);
2110
+ for (const inputFile of inputs) {
2111
+ patterns.push(inputFile);
2112
+ const dir = inputFile.substring(0, inputFile.lastIndexOf("/"));
2113
+ if (dir) patterns.push(`${dir}/**/*`);
2114
+ }
2088
2115
  }
2089
- } else if (entry.type === "transform") addDirectoryPatterns(entry.input);
2116
+ } else if (entry.type === "transform") patterns.push(`${entry.input}/**/*`);
2090
2117
  else {
2091
2118
  const inputs = Array.isArray(entry.input) ? entry.input : [entry.input];
2092
- for (const inputFile of inputs) addFilePatterns(inputFile);
2119
+ for (const inputFile of inputs) {
2120
+ patterns.push(inputFile);
2121
+ const dir = inputFile.substring(0, inputFile.lastIndexOf("/"));
2122
+ if (dir) patterns.push(`${dir}/**/*`);
2123
+ }
2093
2124
  }
2094
- if (patterns.size === 0) [
2095
- "src/**/*",
2096
- "*.ts",
2097
- "*.js",
2098
- "*.mjs",
2099
- "*.json"
2100
- ].forEach((pattern) => addPattern(pattern));
2101
- return Array.from(patterns);
2125
+ if (patterns.length === 0) patterns.push("src/**/*", "*.ts", "*.js", "*.mjs", "*.json");
2126
+ return [...new Set(patterns)];
2102
2127
  }
2103
2128
  /**
2104
2129
  * Get patterns for files to ignore
@@ -2121,26 +2146,6 @@ function getIgnorePatterns(config, watchOptions) {
2121
2146
  if (config.ignoreWatch && config.ignoreWatch.length > 0) allIgnores.push(...normalizeIgnorePatterns(config.ignoreWatch));
2122
2147
  return allIgnores;
2123
2148
  }
2124
- function resolveToAbsolute(path, ctx) {
2125
- return isAbsolute(path) ? path : join(ctx.pkgDir, path);
2126
- }
2127
- function normalizeGlobPattern(pattern) {
2128
- return pattern.replace(/\\/g, "/");
2129
- }
2130
- function normalizeRelativeToPkg(target, ctx) {
2131
- const relativePath = relative(ctx.pkgDir, target);
2132
- if (!relativePath || relativePath === "") return ".";
2133
- if (relativePath.includes(":")) return normalizeGlobPattern(target);
2134
- return normalizeGlobPattern(relativePath);
2135
- }
2136
- function getDirGlobPattern(directory, ctx) {
2137
- const normalizedDir = normalizeRelativeToPkg(directory, ctx);
2138
- if (!normalizedDir || normalizedDir === "." || normalizedDir === "./") return "**/*";
2139
- return `${stripTrailingSlash(normalizedDir)}/**/*`;
2140
- }
2141
- function stripTrailingSlash(path) {
2142
- return path.replace(/\/+$/, "");
2143
- }
2144
2149
 
2145
2150
  //#endregion
2146
2151
  //#region src/build.ts
@@ -1,7 +1,7 @@
1
1
  //#region package.json
2
2
  var name = "robuild";
3
3
  var type = "module";
4
- var version = "0.0.8";
4
+ var version = "0.0.10";
5
5
  var packageManager = "pnpm@10.11.1";
6
6
  var description = "Zero-config ESM/TS package builder. Powered by Rolldown and Oxc";
7
7
  var license = "MIT";
@@ -32,7 +32,7 @@ var scripts = {
32
32
  var dependencies = {
33
33
  "c12": "^3.0.4",
34
34
  "cac": "^6.7.14",
35
- "chokidar": "^4.0.3",
35
+ "chokidar": "^3.0.3",
36
36
  "consola": "^3.4.2",
37
37
  "defu": "^6.1.4",
38
38
  "exsolve": "^1.0.5",
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { build } from "./_chunks/build-CHtyq9DQ.mjs";
2
+ import { build } from "./_chunks/build-C8jF81Ux.mjs";
3
3
  import { consola } from "consola";
4
4
  import { parseArgs } from "node:util";
5
5
  import { loadConfig } from "c12";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { build } from "./_chunks/build-CHtyq9DQ.mjs";
1
+ import { build } from "./_chunks/build-C8jF81Ux.mjs";
2
2
  import { defineConfig } from "./_chunks/config-B_2eqpNJ.mjs";
3
3
 
4
4
  export { build, defineConfig };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "robuild",
3
3
  "type": "module",
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "packageManager": "pnpm@10.11.1",
6
6
  "description": "Zero-config ESM/TS package builder. Powered by Rolldown and Oxc",
7
7
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "c12": "^3.0.4",
36
36
  "cac": "^6.7.14",
37
- "chokidar": "^4.0.3",
37
+ "chokidar": "^3.0.3",
38
38
  "consola": "^3.4.2",
39
39
  "defu": "^6.1.4",
40
40
  "exsolve": "^1.0.5",