discourse/spec/tasks/assets_precompile_spec.rb
David Taylor 4e32eae3ef
DEV: Cache AssetProcessor code in development (#38036)
Previously, the asset-processor javascript was only cached in
production. In development, it would be built on-demand using esbuild
every time it was needed. Originally this was incredibly fast. But over
the years complexity has increased, and it now takes more than a second,
even on fast hardware.

This commit adds some caching logic, keyed on the filenames/content of
all known input files. In production, this will make things slightly
more efficient because the cache will be re-used if an up-to-date
version already exists. In development, it will be much more efficient,
because `esbuild` will only be invoked when changes are made to the
asset process source code.

A file-based lock is used to ensure multiple processes do not fight with
each other to generate the processor simultaneously.
2026-02-25 11:24:41 +00:00

13 lines
393 B
Ruby

# frozen_string_literal: true
RSpec.describe "assets:precompile" do
describe "assets:precompile:asset_processor" do
it "compiles the js processor" do
FileUtils.rm_rf AssetProcessor::PROCESSOR_DIR
Rake::Task["assets:precompile:asset_processor"].actions.first.call
path = AssetProcessor.processor_file_path
expect(File.exist?(path)).to eq(true)
end
end
end