@nx/rollup 19.5.2 → 19.5.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/rollup",
|
|
3
|
-
"version": "19.5.
|
|
3
|
+
"version": "19.5.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Rollup contains executors and generators that support building applications using Rollup.",
|
|
6
6
|
"repository": {
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"rollup-plugin-postcss": "^4.0.2",
|
|
45
45
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
46
46
|
"tslib": "^2.3.0",
|
|
47
|
-
"@nx/devkit": "19.5.
|
|
48
|
-
"@nx/js": "19.5.
|
|
49
|
-
"@nrwl/rollup": "19.5.
|
|
47
|
+
"@nx/devkit": "19.5.4",
|
|
48
|
+
"@nx/js": "19.5.4",
|
|
49
|
+
"@nrwl/rollup": "19.5.4"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
@@ -26,12 +26,14 @@ function updatePackageJson(options, packageJson) {
|
|
|
26
26
|
}
|
|
27
27
|
if (options.generateExportsField) {
|
|
28
28
|
for (const [exportEntry, filePath] of Object.entries(esmExports)) {
|
|
29
|
-
packageJson.exports[exportEntry] =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
packageJson.exports[exportEntry] =
|
|
30
|
+
// If CJS format is used, make sure `import` (from Node) points to same instance of the package.
|
|
31
|
+
// Otherwise, packages that are required to be singletons (like React, RxJS, etc.) will break.
|
|
32
|
+
// Reserve `module` entry for bundlers to accommodate tree-shaking.
|
|
33
|
+
{
|
|
34
|
+
[hasCjsFormat ? 'module' : 'import']: filePath,
|
|
35
|
+
types: filePath.replace(/\.js$/, '.d.ts'),
|
|
36
|
+
};
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -54,6 +56,8 @@ function updatePackageJson(options, packageJson) {
|
|
|
54
56
|
const fauxEsmFilePath = filePath.replace(/\.cjs\.js$/, '.cjs.mjs');
|
|
55
57
|
packageJson.exports[exportEntry]['import'] ??= fauxEsmFilePath;
|
|
56
58
|
packageJson.exports[exportEntry]['default'] ??= filePath;
|
|
59
|
+
// Set `types` field only if it's not already set as the preferred ESM Format.
|
|
60
|
+
packageJson.exports[exportEntry]['types'] ??= filePath.replace(/\.js$/, '.d.ts');
|
|
57
61
|
// Re-export from relative CJS file, and Node will synthetically export it as ESM.
|
|
58
62
|
// Make sure both ESM and CJS point to same instance of the package because libs like React, RxJS, etc. requires it.
|
|
59
63
|
// Also need a special .cjs.default.js file that re-exports the `default` from CJS, or else
|
|
@@ -72,6 +76,12 @@ function updatePackageJson(options, packageJson) {
|
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
}
|
|
79
|
+
if (packageJson.module) {
|
|
80
|
+
packageJson.types ??= packageJson.module.replace(/\.js$/, '.d.ts');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
packageJson.types ??= packageJson.main.replace(/\.js$/, '.d.ts');
|
|
84
|
+
}
|
|
75
85
|
(0, fileutils_1.writeJsonFile)((0, path_1.join)(devkit_1.workspaceRoot, options.outputPath, 'package.json'), packageJson);
|
|
76
86
|
}
|
|
77
87
|
function getExports(options) {
|