Skip to content

Commit c8ee27f

Browse files
committed
remove .ts[x] extname in src value
1 parent b065d70 commit c8ee27f

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

src/VueProgram.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,19 @@ class VueProgram {
216216
if (!script) {
217217
return {
218218
scriptKind: ts.ScriptKind.JS,
219-
content: '// tslint:disable\nexport default {};\n',
219+
content: '// tslint:disable\nexport default {};\n'
220220
};
221221
}
222222

223223
const scriptKind = VueProgram.getScriptKindByLang(script.lang);
224224

225225
// There is src attribute
226226
if (script.attrs.src) {
227+
// import path cannot be end with '.ts[x]'
228+
const src = script.attrs.src.replace(/\.tsx?$/i, '');
227229
return {
228230
scriptKind,
229-
content: `// tslint:disable\nexport { default } from '${src}';`,
231+
content: `// tslint:disable\nexport { default } from '${src}';`
230232
};
231233
}
232234

test/integration/vue.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ describe('[INTEGRATION] vue', function () {
154154
});
155155
});
156156

157+
it('should resolve src attribute and check referred source', function (callback) {
158+
createCompiler({ vue: true, tsconfig: 'tsconfig-attrs.json' });
159+
160+
compiler.run(function(error, stats) {
161+
expect(stats.compilation.errors.length).to.be.equal(1);
162+
callback();
163+
});
164+
});
165+
157166
[
158167
'example-ts.vue',
159168
'example-tsx.vue',
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<script lang="ts" src="./test.ts"></script>
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const a: number = "";
2+
export default { a }
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {},
3+
"include": [
4+
"src/attrs/Test.vue"
5+
],
6+
"exclude": [
7+
"node_modules"
8+
]
9+
}

0 commit comments

Comments
 (0)