Giter VIP home page Giter VIP logo

Comments (4)

weaverryan avatar weaverryan commented on August 20, 2024

I'm not sure :). Each file should only run 1 time. Perhaps you can throw an error in the file to see where each "call" is coming from.

from webpack-encore-bundle.

KIMKYEONGYONG avatar KIMKYEONGYONG commented on August 20, 2024

html v1)

{% block javascripts %}

    {{ encore_entry_script_tags('media')}}
{% endblock %}

console result

test media ( 1 call)

html v2)

{% block javascripts %}
    {{ parent() }}
    
{% endblock %}

console result

test app ( 1 call)

html v3)

{% block javascripts %}
    {{ parent() }}
    {{ encore_entry_script_tags('media')}}
{% endblock %}

console result

app.js:29 test app.  
media.js:4 test media
app.js:29 test app
media.js:4 test media

why call console 2 time???

from webpack-encore-bundle.

KIMKYEONGYONG avatar KIMKYEONGYONG commented on August 20, 2024

The cause I think is this: TagRenderer entrypointLookupCollection

(yaml.xml)
2 call yaml.xml

'webpack_encore.entrypoint_lookup_collection' => static function(): EntrypointLookupCollectionInterface  {
        $serviceLocator = new ServiceLocator(['_default' => function() {
            return new EntrypointLookup(DIST_PATH . '/entrypoints.json');
        }]);
        return new EntrypointLookupCollection($serviceLocator);
    },
    'webpack_encore.packages'               => static fn(): Packages => new Packages(
        new Package(new JsonManifestVersionStrategy(DIST_PATH . '/manifest.json'))
    ),
    'webpack_encore.tag_renderer' => static fn(ContainerInterface $container): TagRenderer => new TagRenderer(
        $container->get('webpack_encore.entrypoint_lookup_collection'),
        $container->get('webpack_encore.packages')
    ),

1 call yaml.xml

    'webpack_encore.packages'               => static fn() => new Packages(
        new Package(new JsonManifestVersionStrategy(DIST_PATH . '/manifest.json'))
    ),
    'webpack_encore.tag_renderer'           => static fn(ContainerInterface $container) => new TagRenderer(
        new EntrypointLookup(DIST_PATH . '/entrypoints.json'),
        $container->get('webpack_encore.packages')
    ),

but 1 call yaml.xml is trigger_error !!

from webpack-encore-bundle.

KIMKYEONGYONG avatar KIMKYEONGYONG commented on August 20, 2024

before my code << encore_entry_script_tags * count is call ( new Instance )

'webpack_encore.entrypoint_lookup_collection' => static function(): EntrypointLookupCollectionInterface  {
        $serviceLocator = new ServiceLocator(['_default' => function() {
            return new EntrypointLookup(DIST_PATH . '/entrypoints.json');  
        }]);
        return new EntrypointLookupCollection($serviceLocator);
    },

after my code

  'webpack_encore.entrypoint_lookup_collection' => static function(): EntrypointLookupCollectionInterface  {
        $entrypointLookup = new EntrypointLookup(DIST_PATH . '/entrypoints.json');
        $serviceLocator =  new ServiceLocator(['_default' => function () use ($entrypointLookup) {
            return $entrypointLookup;
        }]);
        return new EntrypointLookupCollection($serviceLocator);
    },

from webpack-encore-bundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.