conf: pack-modules

main
Lei OT 4 months ago
parent cab2c11036
commit 51b446df17

@ -61,9 +61,9 @@ npm install http://xxxx/npm/haina-npm-0.1.0.tgz
// //
import { commons, request, utils, hooks } from '@haina/npm'; import { commons, request, utils, hooks } from '@haina/npm';
// Import only common utilities // Import only common utilities
import { isEmpty } from '@haina/npm/build/esm/utils/commons.js'; import { isEmpty } from '@haina/npm/esm/utils/commons.js';
// Import only request utilities // Import only request utilities
import { fetchJSON } from '@haina/npm/build/esm/utils/request.js'; import { fetchJSON } from '@haina/npm/esm/utils/request.js';
``` ```
### 安装单个模块 ### 安装单个模块

@ -75,7 +75,15 @@ function packDirectory(dirName, dirPath) {
description: `Haina ${dirName} module - part of @haina/npm utility library`, description: `Haina ${dirName} module - part of @haina/npm utility library`,
main: `build/cjs/${dirName}/index.js`, // Assuming there's an index.js in the directory main: `build/cjs/${dirName}/index.js`, // Assuming there's an index.js in the directory
module: `build/esm/${dirName}/index.js`, module: `build/esm/${dirName}/index.js`,
type: 'module', exports: {
".": {
"import": `./build/esm/${dirName}/index.js`,
"require": `./build/cjs/${dirName}/index.js`,
},
"./esm/*": "./build/esm/*",
"./cjs/*": "./build/cjs/*"
},
// type: 'module',
files: [ files: [
"build" "build"
], ],
@ -146,7 +154,13 @@ function packIndividualFile(fileName, parentDir, parentPath) {
description: `Haina ${parentDir}-${moduleName} module - part of @haina/npm utility library`, description: `Haina ${parentDir}-${moduleName} module - part of @haina/npm utility library`,
main: parentDir === 'src' ? `build/cjs/${fileName}` : `build/cjs/${parentDir}/${fileName}`, main: parentDir === 'src' ? `build/cjs/${fileName}` : `build/cjs/${parentDir}/${fileName}`,
module: parentDir === 'src' ? `build/esm/${fileName}` : `build/esm/${parentDir}/${fileName}`, module: parentDir === 'src' ? `build/esm/${fileName}` : `build/esm/${parentDir}/${fileName}`,
type: 'module', exports: {
".": {
"import": parentDir === 'src' ? `./build/esm/${fileName}` : `./build/esm/${parentDir}/${fileName}`,
"require": parentDir === 'src' ? `./build/cjs/${fileName}` : `./build/cjs/${parentDir}/${fileName}`
}
},
// type: 'module',
files: [ files: [
"build" "build"
], ],

Loading…
Cancel
Save