diff --git a/src/rspack/index.ts b/src/rspack/index.ts index 948420d9..d120973b 100644 --- a/src/rspack/index.ts +++ b/src/rspack/index.ts @@ -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 { @@ -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', ) diff --git a/src/webpack/index.ts b/src/webpack/index.ts index 7fa3e7bc..547e9473 100644 --- a/src/webpack/index.ts +++ b/src/webpack/index.ts @@ -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', ) diff --git a/tsup.config.ts b/tsup.config.ts index 60fb1d18..8fafdd81 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -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/*',