File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
tools/package_json_rewriter/transformer/add_exports_field Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- const { loadHistoricalPathInfo, addHistoricalPathToExportsFields } = require ( './compatibility' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+
5
+ const {
6
+ loadHistoricalPathInfo,
7
+ addHistoricalPathToExportsFields,
8
+ } = require ( './compatibility' ) ;
4
9
5
10
const BASE_DIR = __dirname ;
6
11
12
+ function addMainFieldFromPackageJSON ( targetObject , manifestInfo ) {
13
+ const mainPath = manifestInfo . main ;
14
+ assert . strictEqual ( typeof mainPath , 'string' , `package.json's 'main' field is not string` ) ;
15
+ assert . ok ( mainPath . startsWith ( './' ) , `package.json's 'main' field should start with ./` ) ;
16
+
17
+ // eslint-disable-next-line no-param-reassign
18
+ targetObject [ '.' ] = mainPath ;
19
+ }
20
+
7
21
async function addExportsFields ( json ) {
8
22
const o = Object . create ( null ) ;
9
23
10
24
const histricalJSPathList = await loadHistoricalPathInfo ( BASE_DIR , '../../../pkg_files.json' ) ;
11
25
addHistoricalPathToExportsFields ( o , histricalJSPathList ) ;
12
26
27
+ // For the future, we may have a chance to remove this
28
+ // when https://github.com/nodejs/node/issues/32107/ has been fixed.
29
+ addMainFieldFromPackageJSON ( o , json ) ;
30
+
13
31
// eslint-disable-next-line no-param-reassign
14
32
json . exports = o ;
15
33
}
You can’t perform that action at this time.
0 commit comments