Skip to content

Commit

Permalink
fix: support ts import in config file
Browse files Browse the repository at this point in the history
fix #340
  • Loading branch information
yyx990803 committed Jun 4, 2020
1 parent 1a7243a commit 3df3ecd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
File renamed without changes.
8 changes: 6 additions & 2 deletions src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3df3ecd

Please sign in to comment.