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

Chart from charting library doesn't work in webpack-encore #957

Closed
kinekt4 opened this issue Mar 31, 2021 · 3 comments
Closed

Chart from charting library doesn't work in webpack-encore #957

kinekt4 opened this issue Mar 31, 2021 · 3 comments

Comments

@kinekt4
Copy link

kinekt4 commented Mar 31, 2021

Summary

A chart (Brush Chart) from a charting library (ApexCharts) does not work in symfony/webpack-encore-bundle.

The chart on codepen: https://codepen.io/apexcharts/pen/rqWeBX

Resulting error when implemented in @symfony/webpack-encore:

Uncaught (in promise) ReferenceError: ApexCharts is not defined
    at apexcharts.common.js:6
    at Array.forEach (<anonymous>)
    at t.value (apexcharts.common.js:6)
    at t.value (apexcharts.common.js:6)
    at t.value (apexcharts.common.js:14)
    at t.create (apexcharts.common.js:6)
    at apexcharts.common.js:14
    at new Promise (<anonymous>)
    at t.value (apexcharts.common.js:14)
    at HTMLDocument.<anonymous> (brush.js:129)

I've reported the issue with ApexCharts but haven't got a response from them as yet: apexcharts/apexcharts.js#2315

Reproduce

Install framework and required backend and frontend components

symfony new apexcharts --version=4.4 --full
cd apexcharts
composer install
composer require symfony/webpack-encore-bundle
npm install

Setup controllers and assets

# Add new controller
php bin/console make:controller
# Setup new entrypoint in webpack.config.js
# .addEntry('brush', './assets/brush.js')
# Create assets
touch templates/chart/brush.html.twig
touch assets/brush.js
touch assets/css/brush.css

Contents of brush.js

import './styles/brush.css';
import './bootstrap';
import ApexCharts from 'apexcharts';

document.addEventListener("DOMContentLoaded", function (event) {

    // Paste contents from
    // https://codepen.io/apexcharts/pen/rqWeBX

});

Environment

OS: Fedora 33
PHP: 7.4
Symfony: v4.4
symfony/webpack-encore-bundle: v1.11
npm: v7.6.2
ApexCharts: v3.26
Browsers Tested: Opera, Chrome, Firefox

@kinekt4 kinekt4 changed the title ApexCharts Brush Chart doesn't work in webpack-encore Chart from charting library doesn't work in webpack-encore Mar 31, 2021
@kinekt4
Copy link
Author

kinekt4 commented Mar 31, 2021

From what I can tell ApexCharts hasn't been extensively tested with bundlers such as webpack: apexcharts/apexcharts.js#1760

@stof
Copy link
Member

stof commented Apr 9, 2021

This indeed looks like the apexcharts.js bug where the library does not work fine with webpack. That's not an issue in webpack-encore so I'm closing this ticket. There's nothing encore can do here.

@stof stof closed this as completed Apr 9, 2021
@kinekt4
Copy link
Author

kinekt4 commented Apr 12, 2021

I can replicate this issue in vanilla webpack. So yes, not a webpack-encore issue.

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

No branches or pull requests

2 participants