diff --git a/README.md b/README.md index 64e4772e..4847f3cc 100644 --- a/README.md +++ b/README.md @@ -156,11 +156,7 @@ See [#108](https://github.com/ezolenko/rollup-plugin-typescript2/issues/108) * `rollupCommonJSResolveHack`: false - On windows typescript resolver favors POSIX path, while commonjs plugin (and maybe others?) uses native path as module id. This can result in `namedExports` being ignored if rollup happened to use typescript's resolution. Set to true to pass resolved module path through `resolve()` to match up with `rollup-plugin-commonjs`. - - `rollup-plugin-commonjs` fixed this in `10.1.0`, so projects using this option who update to new version will be broken again. - - This also works around the similar bug affecting code splitting (see [rollup/rollup#3094](https://github.com/rollup/rollup/issues/3094)). + _Deprecated_. OS native paths are now _always_ used since [`0.30.0`](https://github.com/ezolenko/rollup-plugin-typescript2/releases/0.30.0) (see [#251](https://github.com/ezolenko/rollup-plugin-typescript2/pull/251)), so this no longer has any effect -- as if it is always `true`. * `objectHashIgnoreUnknownHack`: false diff --git a/package-lock.json b/package-lock.json index fadcfcc8..57834d70 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "@rollup/pluginutils": "^4.1.2", "find-cache-dir": "^3.3.2", "fs-extra": "^10.0.0", - "resolve": "^1.20.0", "tslib": "^2.4.0" }, "devDependencies": { @@ -2420,6 +2419,7 @@ }, "node_modules/function-bind": { "version": "1.1.1", + "dev": true, "license": "MIT" }, "node_modules/gensync": { @@ -2504,6 +2504,7 @@ }, "node_modules/has": { "version": "1.0.3", + "dev": true, "license": "MIT", "dependencies": { "function-bind": "^1.1.1" @@ -2585,6 +2586,7 @@ }, "node_modules/is-core-module": { "version": "2.2.0", + "dev": true, "license": "MIT", "dependencies": { "has": "^1.0.3" @@ -4995,6 +4997,7 @@ }, "node_modules/path-parse": { "version": "1.0.7", + "dev": true, "license": "MIT" }, "node_modules/picocolors": { @@ -5089,6 +5092,7 @@ }, "node_modules/resolve": { "version": "1.20.0", + "dev": true, "license": "MIT", "dependencies": { "is-core-module": "^2.2.0", @@ -7602,7 +7606,8 @@ "optional": true }, "function-bind": { - "version": "1.1.1" + "version": "1.1.1", + "dev": true }, "gensync": { "version": "1.0.0-beta.2", @@ -7660,6 +7665,7 @@ }, "has": { "version": "1.0.3", + "dev": true, "requires": { "function-bind": "^1.1.1" } @@ -7716,6 +7722,7 @@ }, "is-core-module": { "version": "2.2.0", + "dev": true, "requires": { "has": "^1.0.3" } @@ -9498,7 +9505,8 @@ "dev": true }, "path-parse": { - "version": "1.0.7" + "version": "1.0.7", + "dev": true }, "picocolors": { "version": "1.0.0", @@ -9566,6 +9574,7 @@ }, "resolve": { "version": "1.20.0", + "dev": true, "requires": { "is-core-module": "^2.2.0", "path-parse": "^1.0.6" diff --git a/package.json b/package.json index 35efeb6d..81d6cb38 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "@rollup/pluginutils": "^4.1.2", "find-cache-dir": "^3.3.2", "fs-extra": "^10.0.0", - "resolve": "^1.20.0", "tslib": "^2.4.0" }, "peerDependencies": { diff --git a/src/index.ts b/src/index.ts index ea3cfcd7..30352ab7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,9 @@ -import { relative, dirname, normalize as pathNormalize, resolve as pathResolve } from "path"; +import { relative, dirname, normalize as pathNormalize, resolve } from "path"; import * as tsTypes from "typescript"; import { PluginImpl, PluginContext, InputOptions, OutputOptions, TransformResult, SourceMap, Plugin } from "rollup"; import { normalizePath as normalize } from "@rollup/pluginutils"; import * as _ from "lodash"; import { blue, red, yellow, green } from "colors/safe"; -import * as resolve from "resolve"; import findCacheDir from "find-cache-dir"; import { RollupContext } from "./rollupcontext"; @@ -115,6 +114,9 @@ const typescript: PluginImpl = (options) => if (pluginOptions.objectHashIgnoreUnknownHack) context.warn(() => `${yellow("You are using 'objectHashIgnoreUnknownHack' option")}. If you enabled it because of async functions, try disabling it now.`); + if (pluginOptions.rollupCommonJSResolveHack) + context.warn(() => `${yellow("You are using 'rollupCommonJSResolveHack' option")}. This is no longer needed, try disabling it now.`); + if (watchMode) context.info(`running in watch mode`); } @@ -155,7 +157,7 @@ const typescript: PluginImpl = (options) => // TODO: use module resolution cache const result = tsModule.nodeModuleNameResolver(importee, importer, parsedConfig.options, tsModule.sys); - let resolved = result.resolvedModule?.resolvedFileName; + const resolved = result.resolvedModule?.resolvedFileName; if (!resolved) return; @@ -166,9 +168,6 @@ const typescript: PluginImpl = (options) => if (resolved.endsWith(".d.ts")) return; - if (pluginOptions.rollupCommonJSResolveHack) - resolved = resolve.sync(resolved); - context.debug(() => `${blue("resolving")} '${importee}' imported by '${importer}'`); context.debug(() => ` to '${resolved}'`); @@ -332,7 +331,7 @@ const typescript: PluginImpl = (options) => // invert back to absolute, then make relative to declarationDir parsedText.sources = parsedText.sources.map(source => { - const absolutePath = pathResolve(cachePlaceholder, source); + const absolutePath = resolve(cachePlaceholder, source); return normalize(relative(declarationDir, absolutePath)); }); entryText = JSON.stringify(parsedText);