Don't assign the normalEvaluator per default#4548
Don't assign the normalEvaluator per default#4548JeroenBoersma wants to merge 4 commits intoalpinejs:mainfrom
Conversation
Assigning the normal evaluator to theEvaluatorFunction means that it always needs to be exported. CSP doesn't use the normalEvaluator and should not include it in any build. alpinsjs/src/index.js always assigns the normalEvaluator manually and works as expected, and it isn't included anymore in the csp builds. * normalEvaluator also needed dependencies for unsafe functions which we don't want to include in the csp build
* I forgot to redirect some alpinejs to @/alpine * tested build on my alpinejs merge request alpinejs/alpine#4548
+ it would really helpfull for developers to have sourcemap files alongside of the js and minified js files
The sourcemap change is unrelated to the CSP evaluator fix and should be a separate PR if desired. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Review: #4548 — Don't assign the normalEvaluator per defaultType: Bug fix What's happening (plain English)
I verified this empirically:
Other approaches considered
The PR's approach is the laziest correct solution. One line change, zero risk. Changes Made
Test Results
No new tests needed — this is a build/bundling optimization. The existing CSP tests verify the CSP evaluator works correctly, and the evaluator tests verify the normal evaluator works. The fix was verified empirically by inspecting bundle output. Code ReviewThe core change ( // Before (main):
let theEvaluatorFunction = normalEvaluator
// After (this PR):
let theEvaluatorFunction = () => {}Both SecurityThis PR improves security. The CSP build was inadvertently shipping VerdictMerge. This is a clean, one-line fix for a real problem. The CSP build was shipping unsafe-eval code it shouldn't have. The fix is the simplest possible approach, verified empirically, all tests pass, and it has community support (1 approval from @ekwoka, 3 thumbs-up reactions, 1 rocket). I removed the unrelated sourcemap commit to keep the PR focused. Reviewed by Claude |
Assigning the normal evaluator to theEvaluatorFunction means that it always needs to be exported.
CSP doesn't use the normalEvaluator and should not include it in any build. alpinsjs/src/index.js always assigns the normalEvaluator manually and works as expected, and it isn't included anymore in the csp builds.