Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ESM bundle for Kedro-Viz #2268

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ strawberry-server:
strawberry server --app-dir=package kedro_viz.api.graphql.schema --host 127.0.0.1

version:
npm run build:esm
python3 tools/versioning.py $(VERSION)

sign-off:
Expand Down
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Please follow the established format:

## Bug fixes and other changes

- Add ESM bundle for Kedro-Viz. (#2268)
- Fix `%run_viz` using old process in jupyter notebook. (#2267)

## Community contributions
Expand Down
2 changes: 2 additions & 0 deletions esm/d1fbb23f3ade3692e5ec.worker.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions esm/d1fbb23f3ade3692e5ec.worker.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @license kiwi.js v1.1.2
* #------------------------------------------------------------------------------
* # Copyright (c) 2013, Nucleic Development Team & H. Rutjes.
* #
* # Distributed under the terms of the Modified BSD License.
* #
* # The full license is in the file COPYING.txt, distributed with this software.
* #------------------------------------------------------------------------------
**/
2 changes: 2 additions & 0 deletions esm/kedro-viz.production.mjs

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions esm/kedro-viz.production.mjs.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */

/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/

/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react-is.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* use-sync-external-store-shim.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* use-sync-external-store-shim/with-selector.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* what-input - A global utility for tracking the current input method (mouse, keyboard or touch).
* @version v5.2.12
* @link https://github.com/ten1seven/what-input
* @license MIT
*/

/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/** @license kiwi.js v1.1.2
* #------------------------------------------------------------------------------
* # Copyright (c) 2013, Nucleic Development Team & H. Rutjes.
* #
* # Distributed under the terms of the Modified BSD License.
* #
* # The full license is in the file COPYING.txt, distributed with this software.
* #------------------------------------------------------------------------------
**/
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"proxy": "http://localhost:4142/",
"scripts": {
"build": "cross-env GENERATE_SOURCEMAP=false react-scripts build && cp ./build/index.html ./build/404.html",
"build:esm": "rm -rf esm && webpack --config webpack.config.js",
"postbuild": "rm -rf build/api",
"start": "REACT_APP_DATA_SOURCE=$DATA NODE_OPTIONS=\"--dns-result-order=ipv4first\" npm-run-all -p start:app start:lib",
"start:dev": "rm -rf node_modules/.cache && npm start",
Expand Down
5 changes: 5 additions & 0 deletions src/utils/viz-entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import KedroViz from '../components/app/index';

export { React, createRoot, KedroViz };
3 changes: 2 additions & 1 deletion trufflehog-ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ src/utils/random-utils.js
src/components/update-reminder/update-reminder-content.js
src/components/feature-hints/feature-hints-content.js
cypress/fixtures/graphql/
demo-project/build/graphql/
demo-project/build/graphql/
esm/
58 changes: 58 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
mode: 'production', // Ensures optimizations for production by default
entry: {
"kedro-viz": './src/utils/viz-entry.js',
},
output: {
path: path.resolve(__dirname, 'esm'),
filename: '[name].production.mjs',
library: {
type: 'module',
},
},
externalsType: 'module',
externals: {
'plotly.js-dist-min': 'https://cdn.plot.ly/plotly-2.26.0.min.js',
},
experiments: {
outputModule: true,
ravi-kumar-pilla marked this conversation as resolved.
Show resolved Hide resolved
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: [/node_modules/, /(?:\.test\.js|\.spec\.js)$/],
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
sideEffects: false,
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
sideEffects: true,
},
],
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true, // Removes console logs
},
output: {
comments: false, // Remove comments
},
},
}),
],
},
};
Loading