@luxfi/ui 7.4.8 → 7.4.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.
- package/dist/next.cjs +6 -19
- package/dist/next.js +5 -18
- package/package.json +1 -1
- package/src/engine.ts +0 -25
- package/src/next.ts +48 -23
package/dist/next.cjs
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
-
});
|
|
3
|
+
var module$1 = require('module');
|
|
4
|
+
|
|
5
|
+
// src/next.ts
|
|
9
6
|
|
|
10
7
|
// src/engine.ts
|
|
11
8
|
var GUI_PACKAGES = [
|
|
@@ -90,9 +87,10 @@ var ALIASABLE = [
|
|
|
90
87
|
"@tanstack/react-query",
|
|
91
88
|
...GUI_PACKAGES
|
|
92
89
|
];
|
|
90
|
+
|
|
91
|
+
// src/next.ts
|
|
93
92
|
function guiAliases(from) {
|
|
94
|
-
const
|
|
95
|
-
const require_ = createRequire(`${from.replace(/\/?$/, "/")}noop.js`);
|
|
93
|
+
const require_ = module$1.createRequire(`${from.replace(/\/?$/, "/")}noop.js`);
|
|
96
94
|
const alias = {};
|
|
97
95
|
for (const pkg of ALIASABLE) {
|
|
98
96
|
try {
|
|
@@ -102,19 +100,9 @@ function guiAliases(from) {
|
|
|
102
100
|
}
|
|
103
101
|
return alias;
|
|
104
102
|
}
|
|
105
|
-
|
|
106
|
-
// src/next.ts
|
|
107
103
|
function withLuxUi(config = {}) {
|
|
108
104
|
const userWebpack = config.webpack;
|
|
109
105
|
const engine = guiAliases(config.dir ?? process.cwd());
|
|
110
|
-
const root = config.dir ?? process.cwd();
|
|
111
|
-
const path = __require("path");
|
|
112
|
-
const engineTurbopack = {};
|
|
113
|
-
for (const [key, abs] of Object.entries(engine)) {
|
|
114
|
-
const rel = path.relative(root, abs);
|
|
115
|
-
if (rel.startsWith("..") || path.isAbsolute(rel)) continue;
|
|
116
|
-
engineTurbopack[key.replace(/\$$/, "")] = `./${rel}`;
|
|
117
|
-
}
|
|
118
106
|
const { dir: _dir, ...rest } = config;
|
|
119
107
|
return {
|
|
120
108
|
...rest,
|
|
@@ -123,7 +111,6 @@ function withLuxUi(config = {}) {
|
|
|
123
111
|
...config.turbopack,
|
|
124
112
|
resolveAlias: {
|
|
125
113
|
"react-native": "react-native-web",
|
|
126
|
-
...engineTurbopack,
|
|
127
114
|
...config.turbopack?.resolveAlias
|
|
128
115
|
}
|
|
129
116
|
},
|
package/dist/next.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
|
|
3
|
+
// src/next.ts
|
|
7
4
|
|
|
8
5
|
// src/engine.ts
|
|
9
6
|
var GUI_PACKAGES = [
|
|
@@ -88,8 +85,9 @@ var ALIASABLE = [
|
|
|
88
85
|
"@tanstack/react-query",
|
|
89
86
|
...GUI_PACKAGES
|
|
90
87
|
];
|
|
88
|
+
|
|
89
|
+
// src/next.ts
|
|
91
90
|
function guiAliases(from) {
|
|
92
|
-
const { createRequire } = __require("module");
|
|
93
91
|
const require_ = createRequire(`${from.replace(/\/?$/, "/")}noop.js`);
|
|
94
92
|
const alias = {};
|
|
95
93
|
for (const pkg of ALIASABLE) {
|
|
@@ -100,19 +98,9 @@ function guiAliases(from) {
|
|
|
100
98
|
}
|
|
101
99
|
return alias;
|
|
102
100
|
}
|
|
103
|
-
|
|
104
|
-
// src/next.ts
|
|
105
101
|
function withLuxUi(config = {}) {
|
|
106
102
|
const userWebpack = config.webpack;
|
|
107
103
|
const engine = guiAliases(config.dir ?? process.cwd());
|
|
108
|
-
const root = config.dir ?? process.cwd();
|
|
109
|
-
const path = __require("path");
|
|
110
|
-
const engineTurbopack = {};
|
|
111
|
-
for (const [key, abs] of Object.entries(engine)) {
|
|
112
|
-
const rel = path.relative(root, abs);
|
|
113
|
-
if (rel.startsWith("..") || path.isAbsolute(rel)) continue;
|
|
114
|
-
engineTurbopack[key.replace(/\$$/, "")] = `./${rel}`;
|
|
115
|
-
}
|
|
116
104
|
const { dir: _dir, ...rest } = config;
|
|
117
105
|
return {
|
|
118
106
|
...rest,
|
|
@@ -121,7 +109,6 @@ function withLuxUi(config = {}) {
|
|
|
121
109
|
...config.turbopack,
|
|
122
110
|
resolveAlias: {
|
|
123
111
|
"react-native": "react-native-web",
|
|
124
|
-
...engineTurbopack,
|
|
125
112
|
...config.turbopack?.resolveAlias
|
|
126
113
|
}
|
|
127
114
|
},
|
package/package.json
CHANGED
package/src/engine.ts
CHANGED
|
@@ -140,28 +140,3 @@ export const ALIASABLE: ReadonlyArray<string> = [
|
|
|
140
140
|
'@tanstack/react-query',
|
|
141
141
|
...GUI_PACKAGES,
|
|
142
142
|
];
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Exact-match aliases pinning every aliasable package to ONE entry file, for
|
|
146
|
-
* bundlers that have no `dedupe` of their own (webpack, turbopack).
|
|
147
|
-
*
|
|
148
|
-
* Keys carry webpack's `$` exact-match suffix so only the bare specifier is
|
|
149
|
-
* redirected — a deep import keeps resolving normally. Packages that are not
|
|
150
|
-
* physically installed are skipped rather than throwing: the list is the
|
|
151
|
-
* engine's full surface and no single app pulls all of it.
|
|
152
|
-
*/
|
|
153
|
-
export function guiAliases(from: string): Record<string, string> {
|
|
154
|
-
// Deferred so this module stays importable from a browser bundle (the
|
|
155
|
-
// wrappers are build-time only, but `engine.ts` is plain values).
|
|
156
|
-
const { createRequire } = require('node:module') as typeof import('node:module');
|
|
157
|
-
const require_ = createRequire(`${ from.replace(/\/?$/, '/') }noop.js`);
|
|
158
|
-
const alias: Record<string, string> = {};
|
|
159
|
-
for (const pkg of ALIASABLE) {
|
|
160
|
-
try {
|
|
161
|
-
alias[`${ pkg }$`] = require_.resolve(pkg);
|
|
162
|
-
} catch {
|
|
163
|
-
// Not installed in this app — nothing to dedupe.
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return alias;
|
|
167
|
-
}
|
package/src/next.ts
CHANGED
|
@@ -18,7 +18,38 @@
|
|
|
18
18
|
// Node-only (a build-time module) and dependency-free: it takes and returns a
|
|
19
19
|
// plain object, so it does not force `next` into anyone's type graph.
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import { createRequire } from 'node:module';
|
|
22
|
+
|
|
23
|
+
import { ALIASABLE, GUI_DEFINES, GUI_PACKAGES } from './engine';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Exact-match aliases pinning every aliasable package to ONE entry file, for
|
|
27
|
+
* bundlers that have no `dedupe` of their own.
|
|
28
|
+
*
|
|
29
|
+
* Lives HERE, not in ./engine, because it needs `node:module`. `engine.ts` is
|
|
30
|
+
* plain values so a browser bundle can import it; a `require('node:module')`
|
|
31
|
+
* deferred inside it survived the CJS build and then died the moment a surface
|
|
32
|
+
* used an ESM `next.config.mjs` — esbuild emits `Dynamic require of "module" is
|
|
33
|
+
* not supported` and Next never boots. A build-time concern belongs in the
|
|
34
|
+
* build-time module.
|
|
35
|
+
*
|
|
36
|
+
* Keys carry webpack's `$` exact-match suffix so only the bare specifier is
|
|
37
|
+
* redirected — a deep import keeps resolving normally. Packages that are not
|
|
38
|
+
* physically installed are skipped rather than throwing: the list is the
|
|
39
|
+
* engine's full surface and no single app pulls all of it.
|
|
40
|
+
*/
|
|
41
|
+
function guiAliases(from: string): Record<string, string> {
|
|
42
|
+
const require_ = createRequire(`${ from.replace(/\/?$/, '/') }noop.js`);
|
|
43
|
+
const alias: Record<string, string> = {};
|
|
44
|
+
for (const pkg of ALIASABLE) {
|
|
45
|
+
try {
|
|
46
|
+
alias[`${ pkg }$`] = require_.resolve(pkg);
|
|
47
|
+
} catch {
|
|
48
|
+
// Not installed in this app — nothing to dedupe.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return alias;
|
|
52
|
+
}
|
|
22
53
|
|
|
23
54
|
interface WebpackConfig {
|
|
24
55
|
resolve?: { alias?: Record<string, unknown> };
|
|
@@ -49,28 +80,23 @@ export function withLuxUi(config: LuxUiNextConfig = {}): LuxUiNextConfig {
|
|
|
49
80
|
// so the equivalent is an exact-match alias per package, resolved from the app
|
|
50
81
|
// root — see ./engine for why two copies is a crash and not a size problem.
|
|
51
82
|
const engine = guiAliases(config.dir ?? process.cwd());
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
83
|
+
// Turbopack gets `react-native` and NOTHING ELSE, on purpose.
|
|
84
|
+
//
|
|
85
|
+
// It is the only dev bundler from Next 16, so a path-based dedupe here looked
|
|
86
|
+
// like the way to kill the dev-mode `setReference` storm. It is not. Turbopack
|
|
87
|
+
// resolves an alias VALUE against its own project root, which it infers from
|
|
88
|
+
// the workspace and which is not the app directory: an absolute value comes
|
|
89
|
+
// back as `Can't resolve './Users/…/react/index.js' — server relative imports
|
|
90
|
+
// are not implemented yet`, and a value made relative to `dir` re-anchors to
|
|
91
|
+
// that other root and mis-resolves Next's own runtime — the bootnode console
|
|
92
|
+
// 500'd on every route with `Could not find the module
|
|
93
|
+
// "[project]/work/hanzo/bootnode/web/…/global-error.js#default" in the React
|
|
94
|
+
// Client Manifest`.
|
|
95
|
+
//
|
|
96
|
+
// Prod builds still dedupe through `webpack()` below. A dev-only duplicate is
|
|
97
|
+
// a package-manager problem and belongs in the app's `pnpm.overrides`, not in
|
|
98
|
+
// an alias map that can take the dev server down.
|
|
57
99
|
//
|
|
58
|
-
// Two shape differences from webpack, both load-bearing:
|
|
59
|
-
// - no `$` exact-match suffix; a bare key is already exact.
|
|
60
|
-
// - an ABSOLUTE path is not a valid alias value. Turbopack reads it as a
|
|
61
|
-
// server-relative URL and fails with `Can't resolve
|
|
62
|
-
// './Users/.../react/index.js' — server relative imports are not
|
|
63
|
-
// implemented yet`, which takes the whole dev server down. The value has
|
|
64
|
-
// to be a project-relative `./…` specifier, so a package resolved outside
|
|
65
|
-
// the project root is skipped rather than mis-aliased.
|
|
66
|
-
const root = config.dir ?? process.cwd();
|
|
67
|
-
const path = require('node:path') as typeof import('node:path');
|
|
68
|
-
const engineTurbopack: Record<string, string> = {};
|
|
69
|
-
for (const [ key, abs ] of Object.entries(engine)) {
|
|
70
|
-
const rel = path.relative(root, abs);
|
|
71
|
-
if (rel.startsWith('..') || path.isAbsolute(rel)) continue;
|
|
72
|
-
engineTurbopack[key.replace(/\$$/, '')] = `./${ rel }`;
|
|
73
|
-
}
|
|
74
100
|
// `dir` is OURS, not Next's — leaving it on the returned object makes Next
|
|
75
101
|
// print `Unrecognized key(s) in object: 'dir'` on every boot of every surface
|
|
76
102
|
// that passes it. Consume it here.
|
|
@@ -82,7 +108,6 @@ export function withLuxUi(config: LuxUiNextConfig = {}): LuxUiNextConfig {
|
|
|
82
108
|
...config.turbopack,
|
|
83
109
|
resolveAlias: {
|
|
84
110
|
'react-native': 'react-native-web',
|
|
85
|
-
...engineTurbopack,
|
|
86
111
|
...config.turbopack?.resolveAlias,
|
|
87
112
|
},
|
|
88
113
|
},
|