mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-04 21:54:41 +08:00
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.
13 lines
393 B
Ruby
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
|