diff --git a/CHANGELOG.md b/CHANGELOG.md index 04d4df7c..8c621533 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [0.2.5](https://github.com/unjs/unplugin/compare/v0.2.4...v0.2.5) (2021-08-31) + + +### Bug Fixes + +* __dirname mjs support, close [#10](https://github.com/unjs/unplugin/issues/10) ([2a5da06](https://github.com/unjs/unplugin/commit/2a5da067c671eb95bb1ccc8e33e94a821616dd89)) + ### [0.2.4](https://github.com/unjs/unplugin/compare/v0.2.3...v0.2.4) (2021-08-30) diff --git a/package.json b/package.json index 37c2eb6e..f6b15379 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin", - "version": "0.2.4", + "version": "0.2.5", "description": "Unified plugin system for build tools", "repository": "unjs/unplugin", "license": "MIT", diff --git a/src/webpack/index.ts b/src/webpack/index.ts index 7e5eb014..11002d00 100644 --- a/src/webpack/index.ts +++ b/src/webpack/index.ts @@ -1,11 +1,13 @@ import fs from 'fs' -import { join, resolve } from 'upath' +import { fileURLToPath } from 'url' +import { dirname, join, resolve } from 'upath' import type { Resolver } from 'enhanced-resolve' import VirtualModulesPlugin from 'webpack-virtual-modules' import type { UnpluginContextMeta, UnpluginInstance, UnpluginFactory, WebpackCompiler, ResolvedUnpluginOptions } from '../types' -const TRANSFORM_LOADER = resolve(__dirname, 'webpack/loaders/transform.cjs') -const LOAD_LOADER = resolve(__dirname, 'webpack/loaders/load.cjs') +const _dirname = typeof __dirname !== 'undefined' ? __dirname : dirname(fileURLToPath(import.meta.url)) +const TRANSFORM_LOADER = resolve(_dirname, 'webpack/loaders/transform.cjs') +const LOAD_LOADER = resolve(_dirname, 'webpack/loaders/load.cjs') export function getWebpackPlugin ( factory: UnpluginFactory