I manage to reproduce the issue in this repository.
Step by step to reproduce:
git clone https://github.com/pyk/cf-worker-secrets-test.git cd with-webpack/
wrangler.toml and update
Create the secret using the following command:
wrangler secret put MY_SECRET
Then publish the worker:
You should see an error.
Where project without webpack runs fine.
Am I missing something here?