require() triggers a warning if running in browser
There is a warning in then console about the require function not being present when running twigjs as an imported module.
Please see https://github.com/symfony/symfony/discussions/52252#
The code still works, but it would be nice to get rid of this warning.
Looks like the loader could use some tweaks to have it function better with the browser: https://github.com/twigjs/twig.js/blob/master/src/twig.loader.fs.js#L9
I used to have something in place when I used webpack to avoid the error, but I don't know if it will work with modules. What is fs, and is there a package on jsdelivr that can be used for it?
In what context is the fs loader being used in the browser? Wouldn't you use a different loader in that case?
as a module. See the js console at https://jsfiddle.net/tacman1123/azb4dmwe/7/
On Tue, Nov 7, 2023 at 9:41 AM Will Rowe @.***> wrote:
In what context is the fs loader being used in the browser? Wouldn't you use a different loader in that case?
— Reply to this email directly, view it on GitHub https://github.com/twigjs/twig.js/issues/880#issuecomment-1798687240, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEXIQN3HJS5CGJVD5OEO73YDJCB3AVCNFSM6AAAAAA6MQ3LFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJYGY4DOMRUGA . You are receiving this because you authored the thread.Message ID: @.***>
Interesting, so it happens just by importing without doing anything else?
yes. But fortunately it works (beautifully). The code is wrapping in a try / catch, but still throws the warning.
On Tue, Nov 7, 2023 at 2:29 PM Will Rowe @.***> wrote:
Interesting, so it happens just by importing without doing anything else?
— Reply to this email directly, view it on GitHub https://github.com/twigjs/twig.js/issues/880#issuecomment-1799759098, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEXIQOOYHAN5VPKZHBJTRDYDKD3JAVCNFSM6AAAAAA6MQ3LFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJZG42TSMBZHA . You are receiving this because you authored the thread.Message ID: @.***>