@seybel/breakhound 0.0.0-stage → 1.0.1

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.
package/dist/next.cjs ADDED
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/next.ts
21
+ var next_exports = {};
22
+ __export(next_exports, {
23
+ default: () => next_default,
24
+ withBreakhound: () => withBreakhound
25
+ });
26
+ module.exports = __toCommonJS(next_exports);
27
+
28
+ // ../../node_modules/tsup/assets/cjs_shims.js
29
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
30
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
31
+
32
+ // ../source/src/paths.ts
33
+ var import_node_fs = require("fs");
34
+ var import_node_url = require("url");
35
+ function loaderPath() {
36
+ for (const candidate of ["./source-loader.cjs", "./webpack-loader.ts"]) {
37
+ const path = (0, import_node_url.fileURLToPath)(new URL(candidate, importMetaUrl));
38
+ if ((0, import_node_fs.existsSync)(path)) return path;
39
+ }
40
+ throw new Error("breakhound: the source loader is missing from the package.");
41
+ }
42
+
43
+ // ../source/src/webpack.ts
44
+ function sourceRule(root) {
45
+ return {
46
+ test: /\.(jsx|tsx|vue|svelte)$/,
47
+ exclude: /[\\/]node_modules[\\/]/,
48
+ enforce: "pre",
49
+ use: [{ loader: loaderPath(), options: root ? { root } : {} }]
50
+ };
51
+ }
52
+
53
+ // ../source/src/next.ts
54
+ var DEV_PHASE = "phase-development-server";
55
+ function withBreakhound(config = {}) {
56
+ return async (phase, context) => {
57
+ const resolved = typeof config === "function" ? await config(phase, context) : config;
58
+ if (phase !== DEV_PHASE) return resolved;
59
+ const loader = loaderPath();
60
+ const rules = { ...resolved.turbopack?.rules };
61
+ for (const glob of ["*.jsx", "*.tsx"]) {
62
+ if (!rules[glob]) rules[glob] = { loaders: [loader] };
63
+ }
64
+ const userWebpack = resolved.webpack;
65
+ return {
66
+ ...resolved,
67
+ turbopack: { ...resolved.turbopack, rules },
68
+ webpack(webpackConfig, options) {
69
+ const out = userWebpack ? userWebpack(webpackConfig, options) : webpackConfig;
70
+ out.module.rules.unshift(sourceRule());
71
+ return out;
72
+ }
73
+ };
74
+ };
75
+ }
76
+
77
+ // ../source/src/transform.ts
78
+ var import_node_module = require("module");
79
+ var import_node_path = require("path");
80
+ var import_parser = require("@babel/parser");
81
+
82
+ // src/next.ts
83
+ var next_default = withBreakhound;
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ withBreakhound
87
+ });
@@ -0,0 +1,18 @@
1
+ export type NextConfig = Record<string, any>;
2
+ export type ConfigInput = NextConfig | ((phase: string, context: {
3
+ defaultConfig: NextConfig;
4
+ }) => NextConfig | Promise<NextConfig>);
5
+ /**
6
+ * `export default withBreakhound(nextConfig)`. Only `next dev` is changed:
7
+ * both Turbopack and webpack get a loader that marks elements with where
8
+ * they're written.
9
+ */
10
+ export declare function withBreakhound(config?: ConfigInput): (phase: string, context: {
11
+ defaultConfig: NextConfig;
12
+ }) => Promise<NextConfig>;
13
+
14
+ export {
15
+ withBreakhound as default,
16
+ };
17
+
18
+ export {};
package/dist/next.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ export type NextConfig = Record<string, any>;
2
+ export type ConfigInput = NextConfig | ((phase: string, context: {
3
+ defaultConfig: NextConfig;
4
+ }) => NextConfig | Promise<NextConfig>);
5
+ /**
6
+ * `export default withBreakhound(nextConfig)`. Only `next dev` is changed:
7
+ * both Turbopack and webpack get a loader that marks elements with where
8
+ * they're written.
9
+ */
10
+ export declare function withBreakhound(config?: ConfigInput): (phase: string, context: {
11
+ defaultConfig: NextConfig;
12
+ }) => Promise<NextConfig>;
13
+
14
+ export {
15
+ withBreakhound as default,
16
+ };
17
+
18
+ export {};
package/dist/next.js ADDED
@@ -0,0 +1,56 @@
1
+ // ../source/src/paths.ts
2
+ import { existsSync } from "fs";
3
+ import { fileURLToPath } from "url";
4
+ function loaderPath() {
5
+ for (const candidate of ["./source-loader.cjs", "./webpack-loader.ts"]) {
6
+ const path = fileURLToPath(new URL(candidate, import.meta.url));
7
+ if (existsSync(path)) return path;
8
+ }
9
+ throw new Error("breakhound: the source loader is missing from the package.");
10
+ }
11
+
12
+ // ../source/src/webpack.ts
13
+ function sourceRule(root) {
14
+ return {
15
+ test: /\.(jsx|tsx|vue|svelte)$/,
16
+ exclude: /[\\/]node_modules[\\/]/,
17
+ enforce: "pre",
18
+ use: [{ loader: loaderPath(), options: root ? { root } : {} }]
19
+ };
20
+ }
21
+
22
+ // ../source/src/next.ts
23
+ var DEV_PHASE = "phase-development-server";
24
+ function withBreakhound(config = {}) {
25
+ return async (phase, context) => {
26
+ const resolved = typeof config === "function" ? await config(phase, context) : config;
27
+ if (phase !== DEV_PHASE) return resolved;
28
+ const loader = loaderPath();
29
+ const rules = { ...resolved.turbopack?.rules };
30
+ for (const glob of ["*.jsx", "*.tsx"]) {
31
+ if (!rules[glob]) rules[glob] = { loaders: [loader] };
32
+ }
33
+ const userWebpack = resolved.webpack;
34
+ return {
35
+ ...resolved,
36
+ turbopack: { ...resolved.turbopack, rules },
37
+ webpack(webpackConfig, options) {
38
+ const out = userWebpack ? userWebpack(webpackConfig, options) : webpackConfig;
39
+ out.module.rules.unshift(sourceRule());
40
+ return out;
41
+ }
42
+ };
43
+ };
44
+ }
45
+
46
+ // ../source/src/transform.ts
47
+ import { createRequire } from "module";
48
+ import { extname, join, relative, sep } from "path";
49
+ import { parse } from "@babel/parser";
50
+
51
+ // src/next.ts
52
+ var next_default = withBreakhound;
53
+ export {
54
+ next_default as default,
55
+ withBreakhound
56
+ };