Skip to content

How to import another module from transformer #177

Closed Answered by mribbons
mribbons asked this question in Q&A
Discussion options

You must be logged in to vote

I got it working by bundling into a single script using vite.
Note that because I'm working in a package with "type": "module", I had to use cjs extensions to resolve missing import errors.

I'm not sure, but it's possible that type: module was also causing the issue with typescript imports, as ts-patch seems to want CommonJS modules.

Install vite:

pnpm add -D vite vite-plugin-dts

vite.config.ts:

import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'

export default defineConfig({
  build: {
    lib: {
      entry: './src/transformers/src/sample-transformer.ts',
      formats: ['cjs'],
      fileName: () => `transformer.bundle.cjs`
    },
    rollupOptions: {
      external: [

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mribbons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant