Skip to content

Commit

Permalink
refactor: add tsup shims
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jun 3, 2023
1 parent 48269b7 commit bb2444b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
12 changes: 3 additions & 9 deletions src/rspack/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
import { resolve } from 'path'
import type { RspackPluginInstance, RuleSetUseItem } from '@rspack/core'
import { toArray } from '../utils'
import type {
Expand All @@ -9,18 +8,13 @@ import type {
} from '../types'
import { createRspackContext } from './context'

const _dirname
= typeof __dirname !== 'undefined'
? __dirname
: dirname(fileURLToPath(import.meta.url))

const TRANSFORM_LOADER = resolve(
_dirname,
__dirname,
__DEV__ ? '../../dist/rspack/loaders/transform' : 'rspack/loaders/transform',
)

const LOAD_LOADER = resolve(
_dirname,
__dirname,
__DEV__ ? '../../dist/rspack/loaders/load' : 'rspack/loaders/load',
)

Expand Down
9 changes: 3 additions & 6 deletions src/webpack/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import fs from 'fs'
import { fileURLToPath } from 'url'
import { dirname, resolve } from 'path'
import { resolve } from 'path'
import VirtualModulesPlugin from 'webpack-virtual-modules'
import type { ResolvePluginInstance, RuleSetUseItem } from 'webpack'
import type { ResolvedUnpluginOptions, UnpluginContextMeta, UnpluginFactory, UnpluginInstance, WebpackCompiler } from '../types'
import { normalizeAbsolutePath, toArray } from '../utils'
import { createContext } from './context'

const _dirname = typeof __dirname !== 'undefined' ? __dirname : dirname(fileURLToPath(import.meta.url))

const TRANSFORM_LOADER = resolve(
_dirname,
__dirname,
__DEV__ ? '../../dist/webpack/loaders/transform' : 'webpack/loaders/transform',
)

const LOAD_LOADER = resolve(
_dirname,
__dirname,
__DEV__ ? '../../dist/webpack/loaders/load' : 'webpack/loaders/load',
)

Expand Down
2 changes: 2 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export const tsup: Options = {
sourcemap: false,
clean: true,
format: ['cjs', 'esm'],
target: 'node16.14',
dts: true,
shims: true,
entryPoints: [
'src/index.ts',
'src/webpack/loaders/*',
Expand Down

0 comments on commit bb2444b

Please sign in to comment.