diff --git a/packages/nomodule-plugin/index.js b/packages/nomodule-plugin/index.js index df04883e0..7f9b99da1 100644 --- a/packages/nomodule-plugin/index.js +++ b/packages/nomodule-plugin/index.js @@ -32,7 +32,7 @@ function nomodulePlugin({} = {}) { // Update all the HTML files with + + diff --git a/packages/wmr/test/fixtures/htm-index/public/index.js b/packages/wmr/test/fixtures/htm-index/public/index.js new file mode 100644 index 000000000..eaf8f3ac3 --- /dev/null +++ b/packages/wmr/test/fixtures/htm-index/public/index.js @@ -0,0 +1,3 @@ +import { foo } from './foo.js'; + +document.querySelector('h1').textContent = foo; diff --git a/packages/wmr/test/fixtures/prod-htm-index/public/foo.js b/packages/wmr/test/fixtures/prod-htm-index/public/foo.js new file mode 100644 index 000000000..3329a7d97 --- /dev/null +++ b/packages/wmr/test/fixtures/prod-htm-index/public/foo.js @@ -0,0 +1 @@ +export const foo = 'foo'; diff --git a/packages/wmr/test/fixtures/prod-htm-index/public/index.htm b/packages/wmr/test/fixtures/prod-htm-index/public/index.htm new file mode 100644 index 000000000..82b5f8718 --- /dev/null +++ b/packages/wmr/test/fixtures/prod-htm-index/public/index.htm @@ -0,0 +1,7 @@ + + + +

Hello wmr

+ + + diff --git a/packages/wmr/test/fixtures/prod-htm-index/public/index.js b/packages/wmr/test/fixtures/prod-htm-index/public/index.js new file mode 100644 index 000000000..eaf8f3ac3 --- /dev/null +++ b/packages/wmr/test/fixtures/prod-htm-index/public/index.js @@ -0,0 +1,3 @@ +import { foo } from './foo.js'; + +document.querySelector('h1').textContent = foo; diff --git a/packages/wmr/test/production.test.js b/packages/wmr/test/production.test.js index 56786be9c..10e3bb4c1 100644 --- a/packages/wmr/test/production.test.js +++ b/packages/wmr/test/production.test.js @@ -24,6 +24,24 @@ describe('production', () => { cleanup.length = 0; }); + it('should build with .htm index file', async () => { + await loadFixture('prod-htm-index', env); + instance = await runWmr(env.tmp.path, 'build'); + const code = await instance.done; + console.info(instance.output.join('\n')); + expect(code).toBe(0); + + const readdir = async f => (await fs.readdir(path.join(env.tmp.path, f))).filter(f => f[0] !== '.'); + const readfile = async f => await fs.readFile(path.join(env.tmp.path, 'dist', f), 'utf-8'); + + const files = await readdir('dist/'); + const js = files.find(f => f.endsWith('.js')); + const html = files.find(f => f.endsWith('.htm')); + + expect(await readfile(js)).toMatch(/['"]foo["']/); + expect(await readfile(html)).toMatch(/Hello wmr/); + }); + describe('demo app', () => { it('should serve the demo app', async () => { await loadFixture('../../../../examples/demo', env);