-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module): Support dual CJS/ESM package
* feat(module): Support dual CJS/ESM package - add `type:”module”` to package.json - Support for CJS/ESM by conditional exports - for CJS, will consume packaged with d3.js to solve compatibility issue - ESM build will distributed from ‘dist-esm’ (before dist/*.esm.js) Fix #2202 * skip: make peer dependency on webpack 5.48
- Loading branch information
Showing
23 changed files
with
593 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ package-lock.json | |
/.* | ||
/coverage | ||
/demo/work | ||
/dist | ||
/dist* | ||
/doc | ||
/monitor | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
npx --no-install commitlint -g ./config/commitlint.config.js --edit $1 | ||
npx --no-install commitlint -g ./config/commitlint.config.cjs --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const {resolve} = require("path"); | ||
const {execSync} = require("child_process"); | ||
|
||
module.exports = JSON.parse( | ||
execSync(`node ${resolve(__dirname, "./banner.js")}`, {encoding: "utf-8"}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Generate a CJS package.json file to dist folder. | ||
*/ | ||
import {resolvePath, writeJson} from "./util.js"; | ||
|
||
const content = { | ||
"type": "commonjs" | ||
}; | ||
|
||
writeJson(resolvePath("../dist/package.json"), content, e => { | ||
console.error(e); | ||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {dirname, resolve} from "path"; | ||
import {fileURLToPath} from "url"; | ||
import {execSync} from "child_process"; | ||
import {readFileSync, writeFileSync} from "fs"; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
/** | ||
* Get banner object | ||
*/ | ||
function getBanner() { | ||
return JSON.parse( | ||
execSync(`node ${resolvePath("./banner.js")}`, {encoding: "utf-8"}) | ||
); | ||
} | ||
|
||
/** | ||
* Resolve path | ||
* @param {string} path Path to resolve | ||
*/ | ||
function resolvePath(path) { | ||
return resolve(__dirname, path); | ||
} | ||
|
||
/** | ||
* Read json from the root of the project. | ||
* @param {string} path Path from the root | ||
*/ | ||
function readJson(path) { | ||
return JSON.parse(readFileSync(resolvePath(`../${path}`), "utf8")); | ||
} | ||
|
||
/** | ||
* Write json to file | ||
* @param {string} target Path from the root | ||
* @param {object} json JSON object | ||
*/ | ||
function writeJson(target, json) { | ||
writeFileSync(target, JSON.stringify(json), e => { | ||
console.error(e); | ||
}); | ||
} | ||
|
||
export { | ||
__dirname, | ||
getBanner, | ||
readJson, | ||
resolvePath, | ||
writeJson | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.