@gjsify/rolldown-plugin-gjsify 0.3.20 → 0.3.21
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/lib/plugins/alias.js +9 -1
- package/package.json +5 -5
- package/src/plugins/alias.ts +9 -1
package/lib/plugins/alias.js
CHANGED
|
@@ -13,6 +13,13 @@
|
|
|
13
13
|
// - exact string match (no prefix-aware semantics needed at this layer)
|
|
14
14
|
// - `node:<name>` specifiers map to the same target as `<name>`
|
|
15
15
|
// (handled in the alias-builder helpers, not here).
|
|
16
|
+
//
|
|
17
|
+
// `extraOptions.kind` is forwarded to `this.resolve()` so package.json
|
|
18
|
+
// `exports` conditions ("import" / "require") match the original call site.
|
|
19
|
+
// Without this, a CJS `require('stream')` in a bundled npm package would
|
|
20
|
+
// resolve through the "import" condition (Rolldown's default), bypassing the
|
|
21
|
+
// `cjs-compat.cjs` shim that unwraps named-export ESM modules to their
|
|
22
|
+
// constructor — breaking `util.inherits(Child, Stream)` patterns.
|
|
16
23
|
export function aliasPlugin(options) {
|
|
17
24
|
const entries = options.entries;
|
|
18
25
|
const keys = Object.keys(entries);
|
|
@@ -20,7 +27,7 @@ export function aliasPlugin(options) {
|
|
|
20
27
|
name: 'gjsify-alias',
|
|
21
28
|
resolveId: {
|
|
22
29
|
order: 'pre',
|
|
23
|
-
async handler(source, importer) {
|
|
30
|
+
async handler(source, importer, extraOptions) {
|
|
24
31
|
if (!Object.prototype.hasOwnProperty.call(entries, source)) {
|
|
25
32
|
return null;
|
|
26
33
|
}
|
|
@@ -31,6 +38,7 @@ export function aliasPlugin(options) {
|
|
|
31
38
|
return null;
|
|
32
39
|
const resolved = await this.resolve(target, importer, {
|
|
33
40
|
skipSelf: true,
|
|
41
|
+
kind: extraOptions?.kind,
|
|
34
42
|
});
|
|
35
43
|
if (resolved !== null) {
|
|
36
44
|
return resolved;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/rolldown-plugin-gjsify",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.21",
|
|
4
4
|
"description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
],
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@gjsify/resolve-npm": "^0.3.
|
|
46
|
-
"@gjsify/rolldown-plugin-deepkit": "^0.3.
|
|
47
|
-
"@gjsify/rolldown-plugin-pnp": "^0.3.
|
|
48
|
-
"@gjsify/vite-plugin-blueprint": "^0.3.
|
|
45
|
+
"@gjsify/resolve-npm": "^0.3.21",
|
|
46
|
+
"@gjsify/rolldown-plugin-deepkit": "^0.3.21",
|
|
47
|
+
"@gjsify/rolldown-plugin-pnp": "^0.3.21",
|
|
48
|
+
"@gjsify/vite-plugin-blueprint": "^0.3.21",
|
|
49
49
|
"@rollup/pluginutils": "^5.3.0",
|
|
50
50
|
"acorn": "^8.16.0",
|
|
51
51
|
"acorn-walk": "^8.3.5",
|
package/src/plugins/alias.ts
CHANGED
|
@@ -13,6 +13,13 @@
|
|
|
13
13
|
// - exact string match (no prefix-aware semantics needed at this layer)
|
|
14
14
|
// - `node:<name>` specifiers map to the same target as `<name>`
|
|
15
15
|
// (handled in the alias-builder helpers, not here).
|
|
16
|
+
//
|
|
17
|
+
// `extraOptions.kind` is forwarded to `this.resolve()` so package.json
|
|
18
|
+
// `exports` conditions ("import" / "require") match the original call site.
|
|
19
|
+
// Without this, a CJS `require('stream')` in a bundled npm package would
|
|
20
|
+
// resolve through the "import" condition (Rolldown's default), bypassing the
|
|
21
|
+
// `cjs-compat.cjs` shim that unwraps named-export ESM modules to their
|
|
22
|
+
// constructor — breaking `util.inherits(Child, Stream)` patterns.
|
|
16
23
|
|
|
17
24
|
import type { Plugin } from 'rolldown';
|
|
18
25
|
|
|
@@ -28,7 +35,7 @@ export function aliasPlugin(options: AliasPluginOptions): Plugin {
|
|
|
28
35
|
name: 'gjsify-alias',
|
|
29
36
|
resolveId: {
|
|
30
37
|
order: 'pre' as const,
|
|
31
|
-
async handler(source, importer) {
|
|
38
|
+
async handler(source, importer, extraOptions) {
|
|
32
39
|
if (!Object.prototype.hasOwnProperty.call(entries, source)) {
|
|
33
40
|
return null;
|
|
34
41
|
}
|
|
@@ -39,6 +46,7 @@ export function aliasPlugin(options: AliasPluginOptions): Plugin {
|
|
|
39
46
|
|
|
40
47
|
const resolved = await this.resolve(target, importer, {
|
|
41
48
|
skipSelf: true,
|
|
49
|
+
kind: extraOptions?.kind,
|
|
42
50
|
});
|
|
43
51
|
if (resolved !== null) {
|
|
44
52
|
return resolved;
|