From d142b32345ea7c63e081a1c43086786fe737d566 Mon Sep 17 00:00:00 2001 From: Tony Alves Date: Fri, 22 Mar 2019 08:24:46 -0700 Subject: [PATCH] feat: add ES module builds (#2215) --- babel.config.js | 90 +++++++++++++++---- package.json | 4 +- .../package.json | 4 +- .../package.json | 4 +- .../netlify-cms-backend-github/package.json | 4 +- .../netlify-cms-backend-gitlab/package.json | 4 +- .../netlify-cms-backend-test/package.json | 4 +- packages/netlify-cms-core/package.json | 4 +- packages/netlify-cms-core/src/bootstrap.js | 4 +- .../netlify-cms-default-exports/package.json | 3 +- .../package.json | 4 +- packages/netlify-cms-lib-auth/package.json | 4 +- packages/netlify-cms-lib-util/package.json | 4 +- .../package.json | 4 +- .../package.json | 4 +- packages/netlify-cms-ui-default/package.json | 4 +- .../netlify-cms-widget-boolean/package.json | 4 +- packages/netlify-cms-widget-date/package.json | 4 +- .../netlify-cms-widget-datetime/package.json | 4 +- packages/netlify-cms-widget-file/package.json | 4 +- .../netlify-cms-widget-image/package.json | 4 +- packages/netlify-cms-widget-list/package.json | 4 +- packages/netlify-cms-widget-map/package.json | 4 +- .../netlify-cms-widget-markdown/package.json | 4 +- .../netlify-cms-widget-number/package.json | 4 +- .../src/NumberControl.js | 7 +- .../netlify-cms-widget-object/package.json | 4 +- .../netlify-cms-widget-relation/package.json | 4 +- .../netlify-cms-widget-select/package.json | 4 +- .../netlify-cms-widget-string/package.json | 4 +- packages/netlify-cms-widget-text/package.json | 4 +- packages/netlify-cms/src/backends.js | 12 +-- packages/netlify-cms/src/editor-components.js | 4 +- packages/netlify-cms/src/index.js | 8 +- packages/netlify-cms/src/media-libraries.js | 6 +- packages/netlify-cms/src/widgets.js | 30 +++---- scripts/webpack.js | 3 +- yarn.lock | 13 +++ 38 files changed, 211 insertions(+), 77 deletions(-) diff --git a/babel.config.js b/babel.config.js index f9514913..56d12432 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,6 +1,9 @@ const path = require('path'); +const version = require('./packages/netlify-cms/package.json').version; +const coreVersion = require('./packages/netlify-cms-core/package.json').version; const isProduction = process.env.NODE_ENV === 'production'; const isTest = process.env.NODE_ENV === 'test'; +const isESM = process.env.NODE_ENV === 'esm'; const presets = () => { if (isTest) { @@ -32,23 +35,48 @@ const plugins = () => { '@babel/plugin-proposal-export-default-from', [ 'module-resolver', - { - root: path.join(__dirname, 'packages/netlify-cms-core/src/components'), - alias: { - coreSrc: path.join(__dirname, 'packages/netlify-cms-core/src'), - Actions: path.join(__dirname, 'packages/netlify-cms-core/src/actions/'), - Constants: path.join(__dirname, 'packages/netlify-cms-core/src/constants/'), - Formats: path.join(__dirname, 'packages/netlify-cms-core/src/formats/'), - Integrations: path.join(__dirname, 'packages/netlify-cms-core/src/integrations/'), - Lib: path.join(__dirname, 'packages/netlify-cms-core/src/lib/'), - Reducers: path.join(__dirname, 'packages/netlify-cms-core/src/reducers/'), - ReduxStore: path.join(__dirname, 'packages/netlify-cms-core/src/redux/'), - Routing: path.join(__dirname, 'packages/netlify-cms-core/src/routing/'), - ValueObjects: path.join(__dirname, 'packages/netlify-cms-core/src/valueObjects/'), - redux: 'redux', - localforage: 'localforage', - }, - }, + isESM + ? { + root: ['./src'], + alias: { + coreSrc: './src', + Actions: './src/actions', + App: './src/components/App', + Collection: './src/components/Collection', + Constants: './src/constants', + Editor: './src/components/Editor', + EditorWidgets: './src/components/EditorWidgets', + Formats: './src/formats', + Integrations: './src/integrations', + Lib: './src/lib', + MediaLibrary: './src/components/MediaLibrary', + Reducers: './src/reducers', + ReduxStore: './src/redux', + Routing: './src/routing', + UI: './src/components/UI', + Workflow: './src/components/Workflow', + ValueObjects: './src/valueObjects', + localforage: 'localforage', + redux: 'redux', + }, + } + : { + root: path.join(__dirname, 'packages/netlify-cms-core/src/components'), + alias: { + coreSrc: path.join(__dirname, 'packages/netlify-cms-core/src'), + Actions: path.join(__dirname, 'packages/netlify-cms-core/src/actions/'), + Constants: path.join(__dirname, 'packages/netlify-cms-core/src/constants/'), + Formats: path.join(__dirname, 'packages/netlify-cms-core/src/formats/'), + Integrations: path.join(__dirname, 'packages/netlify-cms-core/src/integrations/'), + Lib: path.join(__dirname, 'packages/netlify-cms-core/src/lib/'), + Reducers: path.join(__dirname, 'packages/netlify-cms-core/src/reducers/'), + ReduxStore: path.join(__dirname, 'packages/netlify-cms-core/src/redux/'), + Routing: path.join(__dirname, 'packages/netlify-cms-core/src/routing/'), + ValueObjects: path.join(__dirname, 'packages/netlify-cms-core/src/valueObjects/'), + localforage: 'localforage', + redux: 'redux', + }, + }, ], ]; @@ -65,6 +93,34 @@ const plugins = () => { ]; } + if (isESM) { + return [ + ...defaultPlugins, + [ + 'transform-define', + { + NETLIFY_CMS_VERSION: `${version}`, + NETLIFY_CMS_CORE_VERSION: `${coreVersion}`, + }, + ], + [ + 'emotion', + { + hoist: true, + autoLabel: true, + }, + ], + [ + 'inline-svg', + { + svgo: { + plugins: [{ removeViewBox: false }], + }, + }, + ], + ]; + } + if (isTest) { return [ ...defaultPlugins, diff --git a/package.json b/package.json index 8e00a049..012e931c 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,9 @@ "start": "run-s bootstrap develop", "watch": "lerna run watch --parallel", "develop": "lerna run develop --parallel", - "build": "run-s clean build:lerna", + "build": "run-s clean build:esm build:lerna", "build:lerna": "lerna run build", + "build:esm": "lerna run build:esm", "build-preview": "run-s build build-preview:lerna", "build-preview:lerna": "lerna run build-preview", "clean": "rimraf packages/*/dist dev-test/*.js", @@ -82,6 +83,7 @@ "babel-plugin-lodash": "^3.3.4", "babel-plugin-module-resolver": "^3.2.0", "babel-plugin-transform-builtin-extend": "^1.1.2", + "babel-plugin-transform-define": "1.3.1", "babel-plugin-transform-export-extensions": "^6.22.0", "babel-plugin-transform-inline-environment-variables": "^0.4.3", "cache-me-outside": "^0.0.4", diff --git a/packages/netlify-cms-backend-bitbucket/package.json b/packages/netlify-cms-backend-bitbucket/package.json index 58cbb8aa..76a28169 100644 --- a/packages/netlify-cms-backend-bitbucket/package.json +++ b/packages/netlify-cms-backend-bitbucket/package.json @@ -4,6 +4,7 @@ "version": "2.2.0", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-backend-bitbucket", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-backend-bitbucket.js", "license": "MIT", "keywords": [ @@ -16,7 +17,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "js-base64": "^2.5.1", diff --git a/packages/netlify-cms-backend-git-gateway/package.json b/packages/netlify-cms-backend-git-gateway/package.json index 91f333e4..467df1d0 100644 --- a/packages/netlify-cms-backend-git-gateway/package.json +++ b/packages/netlify-cms-backend-git-gateway/package.json @@ -4,6 +4,7 @@ "version": "2.3.1-beta.0", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-backend-git-gateway", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-backend-git-gateway.js", "license": "MIT", "keywords": [ @@ -17,7 +18,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "gotrue-js": "^0.9.24", diff --git a/packages/netlify-cms-backend-github/package.json b/packages/netlify-cms-backend-github/package.json index 407ed4f7..d6368929 100644 --- a/packages/netlify-cms-backend-github/package.json +++ b/packages/netlify-cms-backend-github/package.json @@ -5,6 +5,7 @@ "license": "MIT", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-backend-github", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-backend-github.js", "keywords": [ "netlify", @@ -16,7 +17,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "common-tags": "^1.8.0", diff --git a/packages/netlify-cms-backend-gitlab/package.json b/packages/netlify-cms-backend-gitlab/package.json index 03c3679f..d6589d96 100644 --- a/packages/netlify-cms-backend-gitlab/package.json +++ b/packages/netlify-cms-backend-gitlab/package.json @@ -5,6 +5,7 @@ "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-backend-gitlab", "bugs": "https://github.com/netlify/netlify-cms/issues", "license": "MIT", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-backend-gitlab.js", "keywords": [ "netlify", @@ -16,7 +17,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "js-base64": "^2.5.1", diff --git a/packages/netlify-cms-backend-test/package.json b/packages/netlify-cms-backend-test/package.json index 949821a6..b9b0c249 100644 --- a/packages/netlify-cms-backend-test/package.json +++ b/packages/netlify-cms-backend-test/package.json @@ -5,6 +5,7 @@ "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-backend-test", "bugs": "https://github.com/netlify/netlify-cms/issues", "license": "MIT", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-backend-test.js", "keywords": [ "netlify", @@ -15,7 +16,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "@emotion/core": "^10.0.9", diff --git a/packages/netlify-cms-core/package.json b/packages/netlify-cms-core/package.json index 2f8c638d..e7a1bb7b 100644 --- a/packages/netlify-cms-core/package.json +++ b/packages/netlify-cms-core/package.json @@ -4,13 +4,15 @@ "version": "2.9.1-beta.0", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-core.js", "files": [ "src/", "dist/" ], "scripts": { - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "keywords": [ "netlify", diff --git a/packages/netlify-cms-core/src/bootstrap.js b/packages/netlify-cms-core/src/bootstrap.js index 9c232e58..29ec8cf2 100644 --- a/packages/netlify-cms-core/src/bootstrap.js +++ b/packages/netlify-cms-core/src/bootstrap.js @@ -23,9 +23,7 @@ function bootstrap(opts = {}) { /** * Log the version number. */ - if (NETLIFY_CMS_VERSION) { - console.log(`netlify-cms ${NETLIFY_CMS_VERSION}`); - } else if (NETLIFY_CMS_CORE_VERSION) { + if (typeof NETLIFY_CMS_CORE_VERSION === 'string') { console.log(`netlify-cms-core ${NETLIFY_CMS_CORE_VERSION}`); } diff --git a/packages/netlify-cms-default-exports/package.json b/packages/netlify-cms-default-exports/package.json index 36a25967..4821aca9 100644 --- a/packages/netlify-cms-default-exports/package.json +++ b/packages/netlify-cms-default-exports/package.json @@ -4,6 +4,7 @@ "description": "NetlifyCMS default exports", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-default-exports", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-editor-component-image.js", "license": "MIT", "keywords": [ @@ -17,7 +18,7 @@ "watch": "webpack -w", "develop": "npm run watch", "build": "cross-env NODE_ENV=production webpack", - "build:dev": "cross-env NODE_ENV=development webpack" + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "@emotion/core": "^10.0.9", diff --git a/packages/netlify-cms-editor-component-image/package.json b/packages/netlify-cms-editor-component-image/package.json index a98dbba5..934c2a77 100644 --- a/packages/netlify-cms-editor-component-image/package.json +++ b/packages/netlify-cms-editor-component-image/package.json @@ -4,6 +4,7 @@ "version": "2.3.0", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-editor-component-image", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-editor-component-image.js", "license": "MIT", "keywords": [ @@ -16,7 +17,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "devDependencies": { "cross-env": "^5.2.0", diff --git a/packages/netlify-cms-lib-auth/package.json b/packages/netlify-cms-lib-auth/package.json index e687ef1f..0b08b2ba 100644 --- a/packages/netlify-cms-lib-auth/package.json +++ b/packages/netlify-cms-lib-auth/package.json @@ -4,6 +4,7 @@ "version": "2.1.0", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-lib-auth", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-lib-auth.js", "license": "MIT", "files": [ @@ -17,7 +18,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "immutable": "^3.7.6", diff --git a/packages/netlify-cms-lib-util/package.json b/packages/netlify-cms-lib-util/package.json index 533513c2..089e0e67 100644 --- a/packages/netlify-cms-lib-util/package.json +++ b/packages/netlify-cms-lib-util/package.json @@ -4,6 +4,7 @@ "version": "2.2.0", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-lib-util", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-lib-util.js", "license": "MIT", "keywords": [ @@ -13,7 +14,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "js-sha256": "^0.9.0", diff --git a/packages/netlify-cms-media-library-cloudinary/package.json b/packages/netlify-cms-media-library-cloudinary/package.json index 586aa68a..c7db369c 100644 --- a/packages/netlify-cms-media-library-cloudinary/package.json +++ b/packages/netlify-cms-media-library-cloudinary/package.json @@ -4,6 +4,7 @@ "version": "1.2.0", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-media-library-cloudinary", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-media-library-cloudinary.js", "license": "MIT", "keywords": [ @@ -21,7 +22,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "netlify-cms-lib-util": "^2.1.3-beta.0" diff --git a/packages/netlify-cms-media-library-uploadcare/package.json b/packages/netlify-cms-media-library-uploadcare/package.json index 1080280b..22b544ae 100644 --- a/packages/netlify-cms-media-library-uploadcare/package.json +++ b/packages/netlify-cms-media-library-uploadcare/package.json @@ -4,6 +4,7 @@ "version": "0.4.0", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-media-library-uploadcare", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-media-library-uploadcare.js", "license": "MIT", "keywords": [ @@ -19,7 +20,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "uploadcare-widget": "^3.7.0", diff --git a/packages/netlify-cms-ui-default/package.json b/packages/netlify-cms-ui-default/package.json index 8feb1e4d..ac056b37 100644 --- a/packages/netlify-cms-ui-default/package.json +++ b/packages/netlify-cms-ui-default/package.json @@ -5,6 +5,7 @@ "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-ui-default", "bugs": "https://github.com/netlify/netlify-cms/issues", "license": "MIT", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-ui-default.js", "keywords": [ "netlify-cms" @@ -13,7 +14,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "react-aria-menubutton": "^6.0.0", diff --git a/packages/netlify-cms-widget-boolean/package.json b/packages/netlify-cms-widget-boolean/package.json index c5302ed7..e056d605 100644 --- a/packages/netlify-cms-widget-boolean/package.json +++ b/packages/netlify-cms-widget-boolean/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#boolean", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-boolean", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-boolean.js", "license": "MIT", "keywords": [ @@ -17,7 +18,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "@emotion/core": "^10.0.9", diff --git a/packages/netlify-cms-widget-date/package.json b/packages/netlify-cms-widget-date/package.json index fa182732..9fa5834e 100644 --- a/packages/netlify-cms-widget-date/package.json +++ b/packages/netlify-cms-widget-date/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#date", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-date", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-date.js", "license": "MIT", "keywords": [ @@ -18,7 +19,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "react-datetime": "^2.16.3" diff --git a/packages/netlify-cms-widget-datetime/package.json b/packages/netlify-cms-widget-datetime/package.json index 1a0badcd..ab8b58a2 100644 --- a/packages/netlify-cms-widget-datetime/package.json +++ b/packages/netlify-cms-widget-datetime/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#datetime", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-datetime", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-datetime.js", "license": "MIT", "keywords": [ @@ -19,7 +20,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "@emotion/core": "^10.0.9", diff --git a/packages/netlify-cms-widget-file/package.json b/packages/netlify-cms-widget-file/package.json index 7bc9a60c..4326661e 100644 --- a/packages/netlify-cms-widget-file/package.json +++ b/packages/netlify-cms-widget-file/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#file", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-file", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-file.js", "license": "MIT", "keywords": [ @@ -19,7 +20,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "common-tags": "^1.8.0" diff --git a/packages/netlify-cms-widget-image/package.json b/packages/netlify-cms-widget-image/package.json index 5386a22e..ab41aa14 100644 --- a/packages/netlify-cms-widget-image/package.json +++ b/packages/netlify-cms-widget-image/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#image", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-image", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-image.js", "license": "MIT", "keywords": [ @@ -19,7 +20,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "@emotion/core": "^10.0.9", diff --git a/packages/netlify-cms-widget-list/package.json b/packages/netlify-cms-widget-list/package.json index 01299065..1d469e22 100644 --- a/packages/netlify-cms-widget-list/package.json +++ b/packages/netlify-cms-widget-list/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#list", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-list", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-list.js", "license": "MIT", "keywords": [ @@ -18,7 +19,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "react-sortable-hoc": "^1.0.0" diff --git a/packages/netlify-cms-widget-map/package.json b/packages/netlify-cms-widget-map/package.json index 3db69e7d..3a140ef0 100644 --- a/packages/netlify-cms-widget-map/package.json +++ b/packages/netlify-cms-widget-map/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#map", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-map", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-map.js", "license": "MIT", "keywords": [ @@ -18,7 +19,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "@emotion/core": "^10.0.9", diff --git a/packages/netlify-cms-widget-markdown/package.json b/packages/netlify-cms-widget-markdown/package.json index 656173d8..f5792021 100644 --- a/packages/netlify-cms-widget-markdown/package.json +++ b/packages/netlify-cms-widget-markdown/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#markdown", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-markdown", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-markdown.js", "license": "MIT", "keywords": [ @@ -18,7 +19,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "is-hotkey": "^0.1.4", diff --git a/packages/netlify-cms-widget-number/package.json b/packages/netlify-cms-widget-number/package.json index c655fabd..9a0387b1 100644 --- a/packages/netlify-cms-widget-number/package.json +++ b/packages/netlify-cms-widget-number/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#number", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-number", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-number.js", "license": "MIT", "keywords": [ @@ -17,7 +18,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "netlify-cms-ui-default": "^2.4.1-beta.0", diff --git a/packages/netlify-cms-widget-number/src/NumberControl.js b/packages/netlify-cms-widget-number/src/NumberControl.js index 78aa970d..1caa9218 100644 --- a/packages/netlify-cms-widget-number/src/NumberControl.js +++ b/packages/netlify-cms-widget-number/src/NumberControl.js @@ -1,7 +1,12 @@ import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import ValidationErrorTypes from 'netlify-cms-core/src/constants/validationErrorTypes'; +const ValidationErrorTypes = { + PRESENCE: 'PRESENCE', + PATTERN: 'PATTERN', + RANGE: 'RANGE', + CUSTOM: 'CUSTOM', +}; export default class NumberControl extends React.Component { static propTypes = { diff --git a/packages/netlify-cms-widget-object/package.json b/packages/netlify-cms-widget-object/package.json index 25504f24..21e9f054 100644 --- a/packages/netlify-cms-widget-object/package.json +++ b/packages/netlify-cms-widget-object/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#object", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-object", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-object.js", "license": "MIT", "keywords": [ @@ -19,7 +20,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "@emotion/core": "^10.0.9", diff --git a/packages/netlify-cms-widget-relation/package.json b/packages/netlify-cms-widget-relation/package.json index 8c8aad7a..3df4803a 100644 --- a/packages/netlify-cms-widget-relation/package.json +++ b/packages/netlify-cms-widget-relation/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#relation", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-relation", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-relation.js", "license": "MIT", "keywords": [ @@ -18,7 +19,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "react-select": "^2.4.2" diff --git a/packages/netlify-cms-widget-select/package.json b/packages/netlify-cms-widget-select/package.json index e1247aa0..43a55d29 100644 --- a/packages/netlify-cms-widget-select/package.json +++ b/packages/netlify-cms-widget-select/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#select", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-select", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-select.js", "license": "MIT", "keywords": [ @@ -19,7 +20,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "immutable": "^3.7.6", diff --git a/packages/netlify-cms-widget-string/package.json b/packages/netlify-cms-widget-string/package.json index 283ccba4..d0307dc1 100644 --- a/packages/netlify-cms-widget-string/package.json +++ b/packages/netlify-cms-widget-string/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#string", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-string", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-string.js", "license": "MIT", "keywords": [ @@ -17,7 +18,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "peerDependencies": { "netlify-cms-ui-default": "^2.4.1-beta.0", diff --git a/packages/netlify-cms-widget-text/package.json b/packages/netlify-cms-widget-text/package.json index 1c4a22e3..9e2eda8d 100644 --- a/packages/netlify-cms-widget-text/package.json +++ b/packages/netlify-cms-widget-text/package.json @@ -5,6 +5,7 @@ "homepage": "https://www.netlifycms.org/docs/widgets/#text", "repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-widget-text", "bugs": "https://github.com/netlify/netlify-cms/issues", + "module": "dist/esm/index.js", "main": "dist/netlify-cms-widget-text.js", "license": "MIT", "keywords": [ @@ -20,7 +21,8 @@ "scripts": { "watch": "webpack -w", "develop": "npm run watch", - "build": "cross-env NODE_ENV=production webpack" + "build": "cross-env NODE_ENV=production webpack", + "build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore src/**/__tests__/* --root-mode upward" }, "dependencies": { "react-textarea-autosize": "^7.1.0" diff --git a/packages/netlify-cms/src/backends.js b/packages/netlify-cms/src/backends.js index 5a3424b0..27a0a8dd 100644 --- a/packages/netlify-cms/src/backends.js +++ b/packages/netlify-cms/src/backends.js @@ -1,9 +1,9 @@ -import { registerBackend } from 'netlify-cms-core/src'; -import { GitHubBackend } from 'netlify-cms-backend-github/src'; -import { GitLabBackend } from 'netlify-cms-backend-gitlab/src'; -import { GitGatewayBackend } from 'netlify-cms-backend-git-gateway/src'; -import { BitbucketBackend } from 'netlify-cms-backend-bitbucket/src'; -import { TestBackend } from 'netlify-cms-backend-test/src'; +import { registerBackend } from 'netlify-cms-core'; +import { GitHubBackend } from 'netlify-cms-backend-github'; +import { GitLabBackend } from 'netlify-cms-backend-gitlab'; +import { GitGatewayBackend } from 'netlify-cms-backend-git-gateway'; +import { BitbucketBackend } from 'netlify-cms-backend-bitbucket'; +import { TestBackend } from 'netlify-cms-backend-test'; registerBackend('git-gateway', GitGatewayBackend); registerBackend('github', GitHubBackend); diff --git a/packages/netlify-cms/src/editor-components.js b/packages/netlify-cms/src/editor-components.js index e28bebe8..00f10da0 100644 --- a/packages/netlify-cms/src/editor-components.js +++ b/packages/netlify-cms/src/editor-components.js @@ -1,4 +1,4 @@ -import { registerEditorComponent } from 'netlify-cms-core/src'; -import image from 'netlify-cms-editor-component-image/src'; +import { registerEditorComponent } from 'netlify-cms-core'; +import image from 'netlify-cms-editor-component-image'; registerEditorComponent(image); diff --git a/packages/netlify-cms/src/index.js b/packages/netlify-cms/src/index.js index c7872237..9467500d 100644 --- a/packages/netlify-cms/src/index.js +++ b/packages/netlify-cms/src/index.js @@ -1,6 +1,6 @@ import createReactClass from 'create-react-class'; import React from 'react'; -import * as CMS from 'netlify-cms-core/src'; +import * as CMS from 'netlify-cms-core'; import './backends'; import './widgets'; import './editor-components'; @@ -23,6 +23,12 @@ if (typeof window !== 'undefined') { window.initCMS = CMS.init; window.createClass = window.createClass || createReactClass; window.h = window.h || React.createElement; + /** + * Log the version number. + */ + if (typeof NETLIFY_CMS_VERSION === 'string') { + console.log(`netlify-cms ${NETLIFY_CMS_VERSION}`); + } } export const NetlifyCms = CMS; diff --git a/packages/netlify-cms/src/media-libraries.js b/packages/netlify-cms/src/media-libraries.js index 204d518c..92687676 100644 --- a/packages/netlify-cms/src/media-libraries.js +++ b/packages/netlify-cms/src/media-libraries.js @@ -1,6 +1,6 @@ -import { registerMediaLibrary } from 'netlify-cms-core/src'; -import uploadcare from 'netlify-cms-media-library-uploadcare/src'; -import cloudinary from 'netlify-cms-media-library-cloudinary/src'; +import { registerMediaLibrary } from 'netlify-cms-core'; +import uploadcare from 'netlify-cms-media-library-uploadcare'; +import cloudinary from 'netlify-cms-media-library-cloudinary'; registerMediaLibrary(uploadcare); registerMediaLibrary(cloudinary); diff --git a/packages/netlify-cms/src/widgets.js b/packages/netlify-cms/src/widgets.js index 263e18e6..f0ace4a5 100644 --- a/packages/netlify-cms/src/widgets.js +++ b/packages/netlify-cms/src/widgets.js @@ -1,18 +1,18 @@ -import { registerWidget } from 'netlify-cms-core/src'; -import * as NetlifyCmsWidgetString from 'netlify-cms-widget-string/src'; -import * as NetlifyCmsWidgetNumber from 'netlify-cms-widget-number/src'; -import * as NetlifyCmsWidgetText from 'netlify-cms-widget-text/src'; -import * as NetlifyCmsWidgetImage from 'netlify-cms-widget-image/src'; -import * as NetlifyCmsWidgetFile from 'netlify-cms-widget-file/src'; -import * as NetlifyCmsWidgetSelect from 'netlify-cms-widget-select/src'; -import * as NetlifyCmsWidgetMarkdown from 'netlify-cms-widget-markdown/src'; -import * as NetlifyCmsWidgetList from 'netlify-cms-widget-list/src'; -import * as NetlifyCmsWidgetObject from 'netlify-cms-widget-object/src'; -import * as NetlifyCmsWidgetRelation from 'netlify-cms-widget-relation/src'; -import * as NetlifyCmsWidgetBoolean from 'netlify-cms-widget-boolean/src'; -import * as NetlifyCmsWidgetMap from 'netlify-cms-widget-map/src'; -import DateWidget from 'netlify-cms-widget-date/src'; -import DateTimeWidget from 'netlify-cms-widget-datetime/src'; +import { registerWidget } from 'netlify-cms-core'; +import * as NetlifyCmsWidgetString from 'netlify-cms-widget-string'; +import * as NetlifyCmsWidgetNumber from 'netlify-cms-widget-number'; +import * as NetlifyCmsWidgetText from 'netlify-cms-widget-text'; +import * as NetlifyCmsWidgetImage from 'netlify-cms-widget-image'; +import * as NetlifyCmsWidgetFile from 'netlify-cms-widget-file'; +import * as NetlifyCmsWidgetSelect from 'netlify-cms-widget-select'; +import * as NetlifyCmsWidgetMarkdown from 'netlify-cms-widget-markdown'; +import * as NetlifyCmsWidgetList from 'netlify-cms-widget-list'; +import * as NetlifyCmsWidgetObject from 'netlify-cms-widget-object'; +import * as NetlifyCmsWidgetRelation from 'netlify-cms-widget-relation'; +import * as NetlifyCmsWidgetBoolean from 'netlify-cms-widget-boolean'; +import * as NetlifyCmsWidgetMap from 'netlify-cms-widget-map'; +import DateWidget from 'netlify-cms-widget-date'; +import DateTimeWidget from 'netlify-cms-widget-datetime'; registerWidget( 'string', diff --git a/scripts/webpack.js b/scripts/webpack.js index eaa00e0b..7ef7ae0c 100644 --- a/scripts/webpack.js +++ b/scripts/webpack.js @@ -13,7 +13,8 @@ const rules = () => ({ use: { loader: 'babel-loader', options: { - configFile: path.resolve(`${__dirname}/../babel.config.js`), + rootMode: 'upward', + // configFile: path.resolve(`${__dirname}/../babel.config.js`), }, }, }), diff --git a/yarn.lock b/yarn.lock index 13cee92a..36cc2a71 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2741,6 +2741,14 @@ babel-plugin-transform-builtin-extend@^1.1.2: babel-runtime "^6.2.0" babel-template "^6.3.0" +babel-plugin-transform-define@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-define/-/babel-plugin-transform-define-1.3.1.tgz#b21b7bad3b84cf8e3f07cdc8c660b99cbbc01213" + integrity sha512-JXZ1xE9jIbKCGYZ4wbSMPSI5mdS4DRLi5+SkTHgZqWn5YIf/EucykkzUsPmzJlpkX8fsMVdLnA5vt/LvT97Zbg== + dependencies: + lodash "^4.17.11" + traverse "0.6.6" + babel-plugin-transform-export-extensions@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-export-extensions/-/babel-plugin-transform-export-extensions-6.22.0.tgz#53738b47e75e8218589eea946cbbd39109bbe653" @@ -12397,6 +12405,11 @@ tr46@^1.0.1: dependencies: punycode "^2.1.0" +traverse@0.6.6: + version "0.6.6" + resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137" + integrity sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc= + trim-lines@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/trim-lines/-/trim-lines-1.1.1.tgz#da738ff58fa74817588455e30b11b85289f2a396"