Closed benoror closed 9 years ago
I have successfully added CommonJS support to this module :smile: https://github.com/benoror/angular-color-picker/commit/2142f4129c5222a7406934b98ec4add9d599bc31
I can do this now:
import colorpicker from 'angular-color-picker/angularjs-color-picker.js';
import 'angular-color-picker/angularjs-color-picker.css';
/** ... **/
export default angular.module('app.xyz', [
colorpicker
])
.name;
But ... unfortunately I have issues with TinyColor, since it places the tinycolor
function in the global scope
Got it! I had to shim the module with imports-loader:
import tinycolor from 'tinycolor2';
import colorpicker from 'imports?tinycolor=tinycolor2!angular-color-picker/angularjs-color-picker.js';
import 'angular-color-picker/angularjs-color-picker.css';
*Source: http://webpack.github.io/docs/shimming-modules.html#imports-loader
Motivation
Hi!
I'm in the process of refactoring an app to support modern JS tooling like NPM-only, Webpack & ES6.
Code Change
A small change is needed to support CommonJS.
Working Examples
I have done other PRs for some of my dependencies:
Sources