rollup / plugins

🍣 The one-stop shop for official Rollup plugins
MIT License
3.57k stars 568 forks source link

Miss Transform Hook, leads to the failure of compiling Vue single-file components #1631

Open chinaliyun opened 7 months ago

chinaliyun commented 7 months ago

I am using Rollup to package a Vue component library, using the @rollup-plugin-vue@6.0.0 version plugin and the @rollup/plugin-typescript@11.1.5 version.

Here is transform hook function of the Vue plugin( look the line contains "return output" block):

        async transform(code, id) {
            const query = query_1.parseVuePartRequest(id);
            console.log('vue transform',{code,id, query,'filter-id': filter(id)});
            // *.vue file
            // generate an entry module that imports the actual blocks of the SFC
            if (!query.vue && filter(id)) {
                debug(`transform SFC entry (${id})`);
                const output = sfc_1.transformSFCEntry(code, id, options, rootContext, isProduction, isServer, filterCustomBlock, this);
                if (output) {
                    debug('SFC entry code:', '\n' + output.code + '\n');
                }
                console.log('vue transform output', output);
                return output;
            }
            // sub request for blocks
            if (query.vue) {
                if (!query.src && !filter(query.filename)) {
                    return null;
                }
                if (query.src) {
                    this.addWatchFile(query.filename);
                }
                if (query.type === 'template') {
                    debug(`transform template (${id})`);
                    return template_1.transformTemplate(code, id, options, query, this);
                }
                else if (query.type === 'style') {
                    debug(`transform style (${id})`);
                    return style_1.transformStyle(code, id, options, query, isProduction, this);
                }

                console.log('vue transform null');
            }
            return null;
        },

After the execution of the above code is completed, the returned output content is a TS (TypeScript) string.

This result should be further processed by the transform hook function of the TypeScript plugin, but the TypeScript plugin does not expose a transform hook function