Skip to content

Commit

Permalink
fix(bundler): fix conventional html view dependency with SystemJS
Browse files Browse the repository at this point in the history
closes #1023
  • Loading branch information
3cp committed Jan 22, 2019
1 parent e188c85 commit ae249ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/build/find-deps.js
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/build/find-deps.spec.js
Expand Up @@ -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';
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand Down

0 comments on commit ae249ca

Please sign in to comment.