Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UMD module name #210

Closed
micene09 opened this issue Nov 21, 2018 · 5 comments
Closed

UMD module name #210

micene09 opened this issue Nov 21, 2018 · 5 comments
Labels
feature-request New feature or request

Comments

@micene09
Copy link

Hi, as i see in dist file, the UMD builded code is:

(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define("ApexCharts", [], factory);
	else if(typeof exports === 'object')
		exports["ApexCharts"] = factory();
	else
		root["ApexCharts"] = factory();
})(this, function() {

I'm currently using require.js to import this module.
Usually in AMD projects, using the module name in 3rd party dependency give some problems during imports (undefined references), can you make it anonymous as the example below please?

 define([], factory);
@junedchhipa
Copy link
Contributor

I have less knowledge about umd/amd, but you can try editing the webpack configuration here - https://github.com/apexcharts/apexcharts.js/blob/master/webpack.config.js

You can change libraryTarget: 'umd' to libraryTarget: 'amd'
Create a build - and see if it works correctly.
I would accept a PR if this isn't a breaking change.

Or - as an option - I can provide a separate file specifically for amd apexcharts.amd.min.js after testing it.

@micene09
Copy link
Author

A separate file should be the safer and fastest solution, if you feel confident too i think you can go and provide a separate amd build (normal + minified).

@junedchhipa
Copy link
Contributor

Cool, I'll try that

@junedchhipa junedchhipa added the feature-request New feature or request label Nov 21, 2018
@micene09
Copy link
Author

According to the webpack's doc, you can set the umdNamedDefine to false.

Just apply this and you don't need to provide a separate build, i tested it and it's working as expected:

(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory); // << anonymous define finally, we got it!
	else if(typeof exports === 'object')
		exports["ApexCharts"] = factory();
	else
		root["ApexCharts"] = factory();
})(this, function() {

@junedchhipa
Copy link
Contributor

Alright, the change will be released in 2.2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants