|
1 | | -const { join } = require('path'); |
| 1 | +const { join, relative } = require('path'); |
2 | 2 | const { access, mkdir, readdir, readFile, rename, unlink, writeFile } = |
3 | 3 | require('fs').promises; |
4 | 4 | const looksLike = require('html-looks-like'); |
5 | 5 | const { create, build, buildFast } = require('./lib/cli'); |
6 | | -const { snapshot } = require('./lib/utils'); |
| 6 | +const { expand, snapshot } = require('./lib/utils'); |
7 | 7 | const { subject } = require('./lib/output'); |
8 | 8 | const images = require('./images/build'); |
9 | 9 | const minimatch = require('minimatch'); |
@@ -84,6 +84,26 @@ describe('preact build', () => { |
84 | 84 | await expect(buildFast(dir)).resolves.not.toThrow(); |
85 | 85 | }); |
86 | 86 |
|
| 87 | + it.only('lazy loads routes with preact-iso `lazy`', async () => { |
| 88 | + let dir = await subject('lazy-load-iso'); |
| 89 | + await buildFast(dir, { prerender: false }); |
| 90 | + |
| 91 | + let output = await expand(join(dir, 'build')).then(arr => { |
| 92 | + return arr.map(x => relative(dir, x)); |
| 93 | + }); |
| 94 | + |
| 95 | + let expected = [ |
| 96 | + /build\/a\.chunk\.\w{5}\.js$/, |
| 97 | + /build\/a\.chunk\.\w{5}\.css$/, |
| 98 | + /build\/b\.chunk\.\w{5}\.js$/, |
| 99 | + /build\/b\.chunk\.\w{5}\.css$/, |
| 100 | + ]; |
| 101 | + |
| 102 | + expected.forEach(pattern => { |
| 103 | + expect(output.find(file => pattern.test(file))).not.toBeUndefined(); |
| 104 | + }); |
| 105 | + }); |
| 106 | + |
87 | 107 | it('should patch global location object', async () => { |
88 | 108 | let dir = await subject('location-patch'); |
89 | 109 |
|
|
0 commit comments