diff --git a/playground/plugins/jsPlugin.js b/playground/plugins/jsPlugin.ts similarity index 100% rename from playground/plugins/jsPlugin.js rename to playground/plugins/jsPlugin.ts diff --git a/src/node/config.ts b/src/node/config.ts index 4bfa4508bf2368..23bf2be84394b2 100644 --- a/src/node/config.ts +++ b/src/node/config.ts @@ -11,7 +11,7 @@ import Rollup, { } from 'rollup' import { createEsbuildPlugin } from './build/buildPluginEsbuild' import { ServerPlugin } from './server' -import { Resolver } from './resolver' +import { Resolver, supportedExts } from './resolver' import { Transform, CustomBlockTransform } from './transform' import { DepOptimizationOptions } from './optimizer' import { IKoaProxiesOptions } from 'koa-proxies' @@ -339,13 +339,17 @@ export async function resolveConfig( // transpile es import syntax to require syntax using rollup. const rollup = require('rollup') as typeof Rollup const esbuildPlugin = await createEsbuildPlugin(false, {}) + // use node-resolve to support .ts files + const nodeResolve = require('@rollup/plugin-node-resolve').nodeResolve({ + extensions: supportedExts + }) const bundle = await rollup.rollup({ external: (id: string) => (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5, id.length) === '.json', input: resolvedPath, treeshake: false, - plugins: [esbuildPlugin] + plugins: [esbuildPlugin, nodeResolve] }) const {