Skip to content

Commit

Permalink
fix(lib): Generate a module version of the library to be used as impo…
Browse files Browse the repository at this point in the history
…rt in a devlopment source
  • Loading branch information
jacques-lebourgeois committed Nov 22, 2024
1 parent ec1653b commit e21dbc8
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 16 deletions.
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"./dist/**/*"
],
"main": "./dist/ods-charts.js",
"module": "./dist/ods-charts.esm.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "webpack",
Expand All @@ -34,6 +35,7 @@
"typedoc": "^0.26.11",
"typescript": "^5.6.3",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4"
"webpack-cli": "^5.1.4",
"@types/echarts": "^4.9.22"
}
}
1 change: 1 addition & 0 deletions test/angular-echarts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/angular-ngx-echarts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions test/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
"module": "ESNext" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand All @@ -40,7 +40,7 @@
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
"resolveJsonModule": true /* Enable importing .json files. */,
// "resolveJsonModule": true /* Enable importing .json files. */,
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

Expand Down
35 changes: 28 additions & 7 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
const path = require('path');

module.exports = {
const defaultConfig = {
mode: 'development',
devtool: 'inline-source-map',
entry: {
main: './index.ts',
},
output: {
path: path.resolve(__dirname, './dist'),
filename: 'ods-charts.js',
libraryTarget: 'umd',
library: 'ODSCharts',
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
Expand All @@ -24,3 +18,30 @@ module.exports = {
],
},
};

module.exports = [
{
...defaultConfig,
output: {
path: path.resolve(__dirname, './dist'),
filename: 'ods-charts.js',
library: {
type: 'umd',
name: 'ODSCharts',
},
},
},
{
...defaultConfig,
output: {
path: path.resolve(__dirname, './dist'),
filename: 'ods-charts.esm.js',
library: {
type: 'module',
},
},
experiments: {
outputModule: true,
},
},
];

0 comments on commit e21dbc8

Please sign in to comment.