-
-
Notifications
You must be signed in to change notification settings - Fork 148
Recursive vue imports with inline typescript #260
Comments
Shouldn't |
I don't know how webpack resolves things internally and how they deal with vue imports, so I can't say if they should have a similar problem. Looks like they use a sync version of webpack's resolver with the same typescript API in the end. Doesn't looks like there is an alternative in rollup. I'm also looking into possibly preprocessing files to detect imports, sending them off to rollup resolver (which would hit vue plugin and cause it to generate new module), then using those resolutions. This might be a problem if I can't request module source from rollup from within transform call. |
Let me know if you some approach, maybe I can help. |
So the main problem is typescript not knowing what shape .vue module is, because inline script is not exposed yet. I don't see a good way to fix this without mixing areas of concern -- either rpt2 will need to know how to parse vue or vue plugin will need to know how to parse typescript (see below). There are two flows currently (plugin order is not very important because we look at different file types):
Vue plugin could do the preprocessing when it first extracts typescript source -- there is Vue plugin can check if any imports are vue and handle them recursively creating new modules for the whole tree, preferably leaves first. If rollup preserves order when serving new modules, flattened depth first dependency tree will handle first scenario. Scenario 2 is worse because typescript only knows about dynamic modules when declare namespace ts {
function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo;
} interface PreProcessedFileInfo {
referencedFiles: FileReference[];
typeReferenceDirectives: FileReference[];
libReferenceDirectives: FileReference[];
importedFiles: FileReference[];
ambientExternalModules?: string[];
isLibFile: boolean;
} |
cc: @Rich-Harris |
There is a parallel discussion here too: ezolenko/rollup-plugin-typescript2#129 |
Expected behavior
Ideally
rollup-plugin-vue
handles all inline vue imports and creates multiple?rollup-plugin-vue=script.ts
modules in rollup before passing them down the chain.Actual behavior
See ezolenko/rollup-plugin-typescript2#129, basically
rollup-plugin-vue
generates typescript code that gets passed torollup-plugin-typescript2
, but that code has anotherimport "something.vue"
statement and I can't pass it back to rollup because typescript demands cold hard values and doesn't take promises.Steps to reproduce the behavior
See the test repo in the referenced bug.
The text was updated successfully, but these errors were encountered: