web icon indicating copy to clipboard operation
web copied to clipboard

Document possibility for TypeScript path resolving

Open enjikaka opened this issue 3 years ago • 1 comments

Using rollup-plugin-typescript-paths works great for resolving custom imports; like @interal/helpers via TS config paths.

Example usage:

import { esbuildPlugin } from '@web/dev-server-esbuild';
import { fromRollup } from '@web/dev-server-rollup';

import rollupCommonjs from '@rollup/plugin-commonjs';
import { typescriptPaths as rollupTypescriptPaths } from 'rollup-plugin-typescript-paths';

import { chromeLauncher } from '@web/test-runner';

const commonjs = fromRollup(rollupCommonjs);
const typescriptPaths = fromRollup(rollupTypescriptPaths);

export default {
  files: ['src/**/*.test.ts'],
  coverage: true,
  nodeResolve: true,
  testFramework: {
    config: {
      ui: 'bdd',
      timeout: '20000',
    },
  },
  browsers: [
    chromeLauncher({ launchOptions: { args: ['--no-sandbox'] } })
  ],
  plugins: [
    typescriptPaths({
      tsConfigPath: './tsconfig.json',
      absolute: true,
      transform: path => path.replace('.js', '.ts')
    }),
    esbuildPlugin({ ts: true, target: 'es2020', tsconfig: './tsconfig.json' })
  ],
};

enjikaka avatar Sep 05 '22 12:09 enjikaka

⚠️ No Changeset found

Latest commit: 207774a73e68ef879b6c7caf5186f892aebcd963

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Sep 05 '22 12:09 changeset-bot[bot]