This is an automated email from the ASF dual-hosted git repository.
ovilia pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/echarts-custom-series.git
The following commit(s) were added to refs/heads/dev by this push:
new 2e12fe4 chore: (WIP) rename files in dist from index.js #10
2e12fe4 is described below
commit 2e12fe42d35d17e2a392e2e58ded1f3ab744743b
Author: Ovilia <[email protected]>
AuthorDate: Mon Dec 15 10:58:02 2025 +0800
chore: (WIP) rename files in dist from index.js #10
---
custom-series/barRange/README.md | 2 +-
custom-series/barRange/examples/index.html | 2 +-
custom-series/barRange/examples/ssr.js | 2 +-
custom-series/barRange/package.json | 12 ++++++------
scripts/build.js | 25 +++++++++++++++++--------
scripts/rollup.config.js | 22 ++++++++++++++++------
scripts/template/README.md | 2 +-
scripts/template/examples/index.html | 2 +-
scripts/template/examples/ssr.js | 2 +-
scripts/template/package.json | 12 ++++++------
10 files changed, 51 insertions(+), 32 deletions(-)
diff --git a/custom-series/barRange/README.md b/custom-series/barRange/README.md
index 0426e37..5a9e008 100644
--- a/custom-series/barRange/README.md
+++ b/custom-series/barRange/README.md
@@ -14,7 +14,7 @@ For browser usage, use the auto-registration version that
automatically installs
```html
<script src="./node_modules/echarts/dist/echarts.js"></script>
-<script
src="./node_modules/@echarts-x/custom-bar-range/dist/index.auto.js"></script>
+<script
src="./node_modules/@echarts-x/custom-bar-range/dist/bar-range.auto.js"></script>
<script>
// No need to call echarts.use(), automatically registered
const chart = echarts.init(...);
diff --git a/custom-series/barRange/examples/index.html
b/custom-series/barRange/examples/index.html
index 93b5434..f892382 100644
--- a/custom-series/barRange/examples/index.html
+++ b/custom-series/barRange/examples/index.html
@@ -31,7 +31,7 @@
></div>
<script src="../node_modules/echarts/dist/echarts.js"></script>
- <script src="../dist/index.auto.js"></script>
+ <script src="../dist/bar-range.auto.js"></script>
<script>
echarts.use(window.barRangeCustomSeriesInstaller);
const chart = echarts.init(document.getElementById('main'));
diff --git a/custom-series/barRange/examples/ssr.js
b/custom-series/barRange/examples/ssr.js
index f0567da..4555bc9 100644
--- a/custom-series/barRange/examples/ssr.js
+++ b/custom-series/barRange/examples/ssr.js
@@ -18,7 +18,7 @@
*/
const echarts = require('echarts');
-const barRangeInstaller = require('../dist/index.js');
+const barRangeInstaller = require('../dist/bar-range.js');
echarts.use(barRangeInstaller);
diff --git a/custom-series/barRange/package.json
b/custom-series/barRange/package.json
index 7b71676..cf79981 100644
--- a/custom-series/barRange/package.json
+++ b/custom-series/barRange/package.json
@@ -2,16 +2,16 @@
"name": "@echarts-x/custom-bar-range",
"version": "1.0.2",
"description": "Custom barRange series for Apache ECharts",
- "main": "dist/index.js",
- "module": "dist/index.esm.mjs",
+ "main": "dist/bar-range.js",
+ "module": "dist/bar-range.esm.mjs",
"exports": {
".": {
- "types": "./dist/index.d.ts",
- "import": "./dist/index.esm.mjs",
- "require": "./dist/index.js"
+ "types": "./dist/bar-range.d.ts",
+ "import": "./dist/bar-range.esm.mjs",
+ "require": "./dist/bar-range.js"
}
},
- "types": "dist/index.d.ts",
+ "types": "dist/bar-range.d.ts",
"keywords": [
"echarts",
"apache-echarts",
diff --git a/scripts/build.js b/scripts/build.js
index 9e63505..fb36f80 100644
--- a/scripts/build.js
+++ b/scripts/build.js
@@ -22,6 +22,13 @@ const path = require('path');
const { execSync } = require('child_process');
const chalk = require('chalk');
+function toFileBaseName(name) {
+ return name
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
+ .replace(/[_\s]+/g, '-')
+ .toLowerCase();
+}
+
/**
* Install dependencies before build if needed.
* If no `node_modules` directory, run `npm install`
@@ -108,6 +115,7 @@ function bundleWithRollup(seriesPath, dirName) {
const rollupPath = path.join(__dirname, '../node_modules/.bin/rollup');
const configPath = path.join(__dirname, 'rollup.config.js');
const distPath = path.join(seriesPath, 'dist');
+ const fileBaseName = toFileBaseName(dirName);
// Create dist directory if it doesn't exist
if (!fs.existsSync(distPath)) {
@@ -120,6 +128,7 @@ function bundleWithRollup(seriesPath, dirName) {
...process.env,
CUSTOM_SERIES_NAME: dirName,
CUSTOM_SERIES_PATH: seriesPath,
+ CUSTOM_SERIES_FILE_BASENAME: fileBaseName,
};
execSync(`${rollupPath} -c ${configPath}`, {
@@ -132,7 +141,7 @@ function bundleWithRollup(seriesPath, dirName) {
console.log(`Rollup bundling and minification completed for ${dirName}`);
// Create fixed type definition file in dist directory
- const distTypesPath = path.join(seriesPath, 'dist', 'index.d.ts');
+ const distTypesPath = path.join(seriesPath, 'dist',
`${fileBaseName}.d.ts`);
const fixedTypeDefinition = `// Tricky: use1 and use2 are incompatible.
import type {use as use1} from 'echarts/core';
import type {use as use2} from 'echarts';
@@ -144,13 +153,13 @@ export default _default;
// Check if the output files were created
const expectedFiles = [
- 'index.js',
- 'index.min.js',
- 'index.auto.js',
- 'index.auto.min.js',
- 'index.esm.mjs',
- 'index.esm.min.mjs',
- 'index.d.ts',
+ `${fileBaseName}.js`,
+ `${fileBaseName}.min.js`,
+ `${fileBaseName}.auto.js`,
+ `${fileBaseName}.auto.min.js`,
+ `${fileBaseName}.esm.mjs`,
+ `${fileBaseName}.esm.min.mjs`,
+ `${fileBaseName}.d.ts`,
];
for (const file of expectedFiles) {
diff --git a/scripts/rollup.config.js b/scripts/rollup.config.js
index bcdb799..bade22b 100644
--- a/scripts/rollup.config.js
+++ b/scripts/rollup.config.js
@@ -30,6 +30,16 @@ if (fs.existsSync(seriesConfigPath)) {
seriesRollupConfig = require(seriesConfigPath);
}
+function toFileBaseName(name) {
+ return name
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
+ .replace(/[_\s]+/g, '-')
+ .toLowerCase();
+}
+
+const fileBaseName =
+ process.env.CUSTOM_SERIES_FILE_BASENAME || toFileBaseName(seriesName);
+
const licenseHeader = `/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -138,7 +148,7 @@ module.exports = [
...baseConfig,
external: getUMDExternals(),
output: {
- file: path.join(seriesPath, 'dist/index.js'),
+ file: path.join(seriesPath, `dist/${fileBaseName}.js`),
format: 'umd',
name: `${seriesName}CustomSeriesInstaller`,
extend: true,
@@ -152,7 +162,7 @@ module.exports = [
...baseConfig,
external: getUMDExternals(),
output: {
- file: path.join(seriesPath, 'dist/index.min.js'),
+ file: path.join(seriesPath, `dist/${fileBaseName}.min.js`),
format: 'umd',
name: `${seriesName}CustomSeriesInstaller`,
extend: true,
@@ -167,7 +177,7 @@ module.exports = [
...baseConfig,
external: getUMDExternals(),
output: {
- file: path.join(seriesPath, 'dist/index.auto.js'),
+ file: path.join(seriesPath, `dist/${fileBaseName}.auto.js`),
format: 'iife',
name: `${seriesName}CustomSeriesInstaller`,
extend: true,
@@ -181,7 +191,7 @@ module.exports = [
...baseConfig,
external: getUMDExternals(),
output: {
- file: path.join(seriesPath, 'dist/index.auto.min.js'),
+ file: path.join(seriesPath, `dist/${fileBaseName}.auto.min.js`),
format: 'iife',
name: `${seriesName}CustomSeriesInstaller`,
extend: true,
@@ -196,7 +206,7 @@ module.exports = [
...baseConfig,
external: getUMDExternals(),
output: {
- file: path.join(seriesPath, 'dist/index.esm.mjs'),
+ file: path.join(seriesPath, `dist/${fileBaseName}.esm.mjs`),
format: 'esm',
},
plugins: [licensePlugin],
@@ -207,7 +217,7 @@ module.exports = [
...baseConfig,
external: getUMDExternals(),
output: {
- file: path.join(seriesPath, 'dist/index.esm.min.mjs'),
+ file: path.join(seriesPath, `dist/${fileBaseName}.esm.min.mjs`),
format: 'esm',
sourcemap: true,
},
diff --git a/scripts/template/README.md b/scripts/template/README.md
index 0590792..4cd467b 100644
--- a/scripts/template/README.md
+++ b/scripts/template/README.md
@@ -14,7 +14,7 @@ For browser usage, use the auto-registration version that
automatically installs
```html
<script src="./node_modules/echarts/dist/echarts.js"></script>
-<script
src="./node_modules/@echarts-x/custom-$CUSTOM_SERIES_KEBAB_NAME$/dist/index.auto.js"></script>
+<script
src="./node_modules/@echarts-x/custom-$CUSTOM_SERIES_KEBAB_NAME$/dist/$CUSTOM_SERIES_KEBAB_NAME$.auto.js"></script>
<script>
// No need to call echarts.use(), automatically registered
const chart = echarts.init(...);
diff --git a/scripts/template/examples/index.html
b/scripts/template/examples/index.html
index 573b600..b9c44c7 100644
--- a/scripts/template/examples/index.html
+++ b/scripts/template/examples/index.html
@@ -31,7 +31,7 @@
></div>
<script src="../node_modules/echarts/dist/echarts.js"></script>
- <script src="../dist/index.auto.js"></script>
+ <script src="../dist/$CUSTOM_SERIES_KEBAB_NAME$.auto.js"></script>
<script>
echarts.use(window.$CUSTOM_SERIES_NAME$CustomSeriesInstaller);
const chart = echarts.init(document.getElementById('main'));
diff --git a/scripts/template/examples/ssr.js b/scripts/template/examples/ssr.js
index 0d2d7a3..4d8921f 100644
--- a/scripts/template/examples/ssr.js
+++ b/scripts/template/examples/ssr.js
@@ -18,7 +18,7 @@
*/
const echarts = require('echarts');
-const $CUSTOM_SERIES_NAME$Installer = require('../dist/index.js');
+const $CUSTOM_SERIES_NAME$Installer =
require('../dist/$CUSTOM_SERIES_KEBAB_NAME$.js');
echarts.use($CUSTOM_SERIES_NAME$Installer);
diff --git a/scripts/template/package.json b/scripts/template/package.json
index 792b839..ae74042 100644
--- a/scripts/template/package.json
+++ b/scripts/template/package.json
@@ -2,16 +2,16 @@
"name": "@echarts-x/custom-$CUSTOM_SERIES_KEBAB_NAME$",
"version": "1.0.0-beta.0",
"description": "Custom $CUSTOM_SERIES_NAME$ series for Apache ECharts",
- "main": "dist/index.js",
- "module": "dist/index.esm.mjs",
+ "main": "dist/$CUSTOM_SERIES_KEBAB_NAME$.js",
+ "module": "dist/$CUSTOM_SERIES_KEBAB_NAME$.esm.mjs",
"exports": {
".": {
- "types": "./dist/index.d.ts",
- "import": "./dist/index.esm.mjs",
- "require": "./dist/index.js"
+ "types": "./dist/$CUSTOM_SERIES_KEBAB_NAME$.d.ts",
+ "import": "./dist/$CUSTOM_SERIES_KEBAB_NAME$.esm.mjs",
+ "require": "./dist/$CUSTOM_SERIES_KEBAB_NAME$.js"
}
},
- "types": "dist/index.d.ts",
+ "types": "dist/$CUSTOM_SERIES_KEBAB_NAME$.d.ts",
"keywords": [
"echarts",
"apache-echarts",
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]