Skip to content

Commit

Permalink
Use cjs and esm folders to publish the icons
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oandregal committed Mar 8, 2018
1 parent b32bf60 commit a9010c9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
12 changes: 0 additions & 12 deletions .npmignore

This file was deleted.

6 changes: 3 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}]
Expand Down Expand Up @@ -147,7 +147,7 @@ module.exports = function( grunt ) {
cwd: 'svg-min-react/',
src: [ '**/*.svg' ],
filter: 'isFile',
dest: 'react-icons/'
dest: 'esm/'
}]
}
},
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 "
Expand Down

0 comments on commit a9010c9

Please sign in to comment.