@reticlehq/core 1.3.0
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/LICENSE +113 -0
- package/README.md +97 -0
- package/dist/babel.d.ts +7 -0
- package/dist/babel.js +32 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +11264 -0
- package/dist/eslint.d.ts +1 -0
- package/dist/eslint.js +134 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5543 -0
- package/dist/loader.cjs +52 -0
- package/dist/next.d.ts +21 -0
- package/dist/next.js +24 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +9486 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +9368 -0
- package/dist/vite.d.ts +1 -0
- package/dist/vite.js +196 -0
- package/package.json +98 -0
package/dist/loader.cjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Webpack pre-loader for `@reticlehq/core/next` — ships INTO the umbrella's dist/ alongside next.js and
|
|
3
|
+
// babel.js. Applies the Reticle source-mapping babel transform (stamps data-reticle-source) to the project's
|
|
4
|
+
// JSX/TSX, then hands the result to next-swc-loader. SWC still does the real compile; we only stamp
|
|
5
|
+
// source locations. Dev-only (wired by withReticle).
|
|
6
|
+
//
|
|
7
|
+
// Authored as plain CJS (module.exports = function) so webpack requires it directly. The babel plugin
|
|
8
|
+
// is NOT imported from the private @reticlehq/babel-plugin — it's pulled from the umbrella's own
|
|
9
|
+
// bundled ./babel (ESM) via dynamic import, so this loader is self-contained inside the published dist.
|
|
10
|
+
const babel = require('@babel/core');
|
|
11
|
+
|
|
12
|
+
let pluginPromise;
|
|
13
|
+
|
|
14
|
+
module.exports = function reticleNextLoader(source, inputMap) {
|
|
15
|
+
const callback = this.async();
|
|
16
|
+
const filename = this.resourcePath;
|
|
17
|
+
|
|
18
|
+
if (!/\.(t|j)sx$/.test(filename) || filename.includes('node_modules')) {
|
|
19
|
+
callback(null, source, inputMap);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// The bundled source-mapping plugin is the umbrella's ./babel default export.
|
|
24
|
+
pluginPromise = pluginPromise || import('./babel.js').then((m) => m.default || m);
|
|
25
|
+
|
|
26
|
+
pluginPromise
|
|
27
|
+
.then((plugin) =>
|
|
28
|
+
babel.transformAsync(source, {
|
|
29
|
+
filename,
|
|
30
|
+
sourceType: 'module',
|
|
31
|
+
plugins: [plugin],
|
|
32
|
+
parserOpts: { plugins: ['jsx', 'typescript'] },
|
|
33
|
+
generatorOpts: { retainLines: true },
|
|
34
|
+
configFile: false,
|
|
35
|
+
babelrc: false,
|
|
36
|
+
sourceMaps: true,
|
|
37
|
+
sourceFileName: filename,
|
|
38
|
+
}),
|
|
39
|
+
)
|
|
40
|
+
.then((result) => {
|
|
41
|
+
if (result && typeof result.code === 'string') {
|
|
42
|
+
callback(null, result.code, result.map || inputMap);
|
|
43
|
+
} else {
|
|
44
|
+
callback(null, source, inputMap);
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.catch((err) => {
|
|
48
|
+
// Never break the build for a source-map nicety — fall back to the original source.
|
|
49
|
+
callback(null, source, inputMap);
|
|
50
|
+
void err;
|
|
51
|
+
});
|
|
52
|
+
};
|
package/dist/next.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** A minimal mutable webpack config shape — avoids a hard dependency on `webpack`/`next` types. */
|
|
2
|
+
interface WebpackConfigLike {
|
|
3
|
+
module?: {
|
|
4
|
+
rules?: unknown[];
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
/** Minimal Next config shape — only the field we touch is typed; the rest passes through. */
|
|
8
|
+
interface NextConfigLike {
|
|
9
|
+
webpack?: (config: WebpackConfigLike, ctx: unknown) => WebpackConfigLike;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Wrap your Next config to stamp `data-reticle-source` on JSX in dev (so reticle_inspect maps DOM → file:line)
|
|
14
|
+
* without disabling SWC. Production builds are untouched. Usage:
|
|
15
|
+
*
|
|
16
|
+
* import { withReticle } from '@reticlehq/core/next';
|
|
17
|
+
* export default withReticle(nextConfig);
|
|
18
|
+
*/
|
|
19
|
+
declare function withReticle(nextConfig?: NextConfigLike): NextConfigLike;
|
|
20
|
+
|
|
21
|
+
export { withReticle };
|
package/dist/next.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/next.ts
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
var LOADER_PATH = fileURLToPath(new URL("./loader.cjs", import.meta.url));
|
|
4
|
+
function withReticle(nextConfig = {}) {
|
|
5
|
+
if (process.env["NODE_ENV"] === "production") return nextConfig;
|
|
6
|
+
const userWebpack = nextConfig.webpack;
|
|
7
|
+
return {
|
|
8
|
+
...nextConfig,
|
|
9
|
+
webpack(config, ctx) {
|
|
10
|
+
const mod = config.module ??= {};
|
|
11
|
+
const rules = mod.rules ??= [];
|
|
12
|
+
rules.push({
|
|
13
|
+
test: /\.(t|j)sx$/,
|
|
14
|
+
exclude: /node_modules/,
|
|
15
|
+
enforce: "pre",
|
|
16
|
+
use: [{ loader: LOADER_PATH }]
|
|
17
|
+
});
|
|
18
|
+
return typeof userWebpack === "function" ? userWebpack(config, ctx) : config;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
withReticle
|
|
24
|
+
};
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@reticlehq/server';
|