From a9010c937f93b56596c99721b2a78f5fefa967db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Thu, 8 Mar 2018 11:04:51 +0100 Subject: [PATCH] Use cjs and esm folders to publish the icons The idea is that we want to prepare Gridicons to be able to distribute both CommonJS and ECMAScript Modules. Initially, the idea was to use the directory root to publish the CJS modules so others could: import external from 'gridicons/external'; The main disadvantage of that approach is that, in the future, when ECMAScript modules become more common that namespaced will be taken by the CommonJS modules and we won't be able to change that if we want to be backwards-compatible. So, instead, the approach we're taking is being agnostic about what module system the library user wants to use by default. So, either: import external from 'gridicons/cjs/external'; import external from 'gridicons/esm/external'; will work. --- .npmignore | 12 ------------ Gruntfile.js | 6 +++--- package.json | 7 +++++-- 3 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 .npmignore diff --git a/.npmignore b/.npmignore deleted file mode 100644 index abc29743..00000000 --- a/.npmignore +++ /dev/null @@ -1,12 +0,0 @@ -.github/ -.idea/ -docs/ -grunt-tasks/ -pdf/ -php/ -sources/ -react-icons/ -svg-min/ -svg-min-react/ -svg-sprite/ -Gruntfile.js diff --git a/Gruntfile.js b/Gruntfile.js index cb1af1c5..3fc6ff37 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -100,9 +100,9 @@ module.exports = function( grunt ) { dist: { files: [{ expand: true, - cwd: 'react-icons/', + cwd: 'esm/', src: [ '**/*.jsx' ], - dest: 'react-icons/', + dest: 'cjs/', ext: '.js', filter: 'isFile' }] @@ -147,7 +147,7 @@ module.exports = function( grunt ) { cwd: 'svg-min-react/', src: [ '**/*.svg' ], filter: 'isFile', - dest: 'react-icons/' + dest: 'esm/' }] } }, diff --git a/package.json b/package.json index 727794f4..9c6f5154 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,13 @@ { "name": "gridicons", "version": "2.1.3", - "main": "build/index.js", + "main": "cjs/index.js", + "files": [ + "cjs" + ], "scripts": { "build": "grunt --verbose", - "prepublish": "npm run build && cp react-icons/*.js ." + "prepublish": "npm run build" }, "peerDependencies": { "react": "^15.3.0 || ^16.0.0 "