From 47c5d6daa3d02797b0fdc008c7a061d0d72c35a1 Mon Sep 17 00:00:00 2001 From: moklick Date: Sun, 17 Apr 2022 14:04:45 +0200 Subject: [PATCH] fix(build): repair nocss build --- nocss/package.json | 7 +++---- package.json | 4 ++++ rollup.config.js | 40 ++++++++++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/nocss/package.json b/nocss/package.json index 237eeb31..4dad90b4 100644 --- a/nocss/package.json +++ b/nocss/package.json @@ -1,7 +1,6 @@ { "internal": true, - "type": "module", - "main": "../dist/nocss/index.js", - "module": "../dist/nocss/index.js", - "types": "../dist/nocss/index.d.ts" + "main": "../dist/nocss/umd/index.js", + "module": "../dist/nocss/esm/index.js", + "types": "../dist/nocss/esm/index.d.ts" } diff --git a/package.json b/package.json index 27940158..55414fc6 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,10 @@ "import": "./dist/esm/index.js", "require": "./dist/umd/index.js" }, + "./nocss": { + "import": "./dist/nocss/esm/index.js", + "require": "./dist/nocss/umd/index.js" + }, "./package.json": "./package.json" }, "types": "dist/esm/index.d.ts", diff --git a/rollup.config.js b/rollup.config.js index f03126eb..845adf62 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -20,6 +20,18 @@ const defaultOutputOptions = { sourcemap: true, }; +const globals = { + react: 'React', + 'react-dom': 'ReactDOM', + classcat: 'cc', + 'd3-selection': 'd3', + 'd3-zoom': 'd3', + 'react-draggable': 'ReactDraggable', + zustand: 'zustand', + 'zustand/shallow': 'zustandShallow', + 'zustand/context': 'zustandContext', +}; + export const baseConfig = ({ outputOptions = {}, injectCSS = true } = {}) => { const output = { ...defaultOutputOptions, @@ -96,29 +108,33 @@ export const baseConfig = ({ outputOptions = {}, injectCSS = true } = {}) => { export default isProd && !isTesting ? [ + // esm build baseConfig(), + // umd build baseConfig({ outputOptions: { dir: 'dist/umd', format: 'umd', exports: 'named', name: 'ReactFlow', - globals: { - react: 'React', - 'react-dom': 'ReactDOM', - classcat: 'cc', - 'd3-selection': 'd3', - 'd3-zoom': 'd3', - 'react-draggable': 'ReactDraggable', - zustand: 'zustand', - 'zustand/shallow': 'zustandShallow', - 'zustand/context': 'zustandContext', - }, + globals, }, }), + // nocsss esm build baseConfig({ outputOptions: { - dir: 'dist/nocss', + dir: 'dist/nocss/esm', + }, + injectCSS: false, + }), + // nocsss umd build + baseConfig({ + outputOptions: { + dir: 'dist/nocss/umd', + format: 'umd', + exports: 'named', + name: 'ReactFlow', + globals, }, injectCSS: false,