Permalink
Browse files

fix(bundler): fix conventional html view dependency with SystemJS

closes #1023
  • Loading branch information...
huochunpeng committed Jan 22, 2019
1 parent e188c85 commit ae249ca5e49a1fca9a1c1cbdfa6fc8997d69c651
Showing with 13 additions and 1 deletion.
  1. +1 −1 lib/build/find-deps.js
  2. +12 −0 spec/lib/build/find-deps.spec.js
@@ -253,7 +253,7 @@ exports.findJsDeps = function(filename, contents, loaderType = 'require') {
let fileParts = path.parse(filename);
let htmlPair = fileParts.name + '.html';
if (fs.existsSync(fileParts.dir + path.sep + htmlPair)) {
add('text!./' + htmlPair);
add(auDep('./' + htmlPair, loaderType));
}

return Array.from(deps);
@@ -44,6 +44,7 @@ let html = `
</template>
`;
let htmlDeps = ['a/b', 'lv1', 'lv2', 'lvm2', 'text!./c.html', 'text!d/e.css', 'v2', 'vm1', 'vm2'];
let htmlDepsSystemJS = ['./c.html!text', 'a/b', 'd/e.css!text', 'lv1', 'lv2', 'lvm2', 'v2', 'vm1', 'vm2'];

let css = `
@import 'other.css';
@@ -335,7 +336,9 @@ exports.MyComp = MyComp;
fsConfig['src/foo.html'] = 'contents';
mockfs(fsConfig);
expect(findJsDeps('src/foo.js', 'a();')).toEqual(['text!./foo.html']);
expect(findJsDeps('src/foo.js', 'a();', 'system')).toEqual(['./foo.html!text']);
expect(findDeps('src/foo.js', 'a();')).toEqual(['text!./foo.html']);
expect(findDeps('src/foo.js', 'a();', 'system')).toEqual(['./foo.html!text']);
});

it('remove inner defined modules', () => {
@@ -352,6 +355,9 @@ define('another', ['M', 'N', 'a', 'b'], function() {});
it('find all require deps', () => {
expect(findHtmlDeps('ignore.html', html).sort())
.toEqual(htmlDeps);

expect(findHtmlDeps('ignore.html', html, 'system').sort())
.toEqual(htmlDepsSystemJS);
});

it('silent at syntax error', () => {
@@ -372,8 +378,14 @@ define('another', ['M', 'N', 'a', 'b'], function() {});
expect(findDeps('ignore.html', html).sort())
.toEqual(htmlDeps);

expect(findDeps('ignore.html', html, 'system').sort())
.toEqual(htmlDepsSystemJS);

expect(findDeps('IGNORE.HTM', html).sort())
.toEqual(htmlDeps);

expect(findDeps('IGNORE.HTM', html, 'system').sort())
.toEqual(htmlDepsSystemJS);
});

it('passes other files', () => {

0 comments on commit ae249ca

Please sign in to comment.