Try to fix cosmiconfig in the built version of Prettier (#2930)
parent
0d756080b5
commit
63916beebb
|
@ -11,7 +11,14 @@ export default Object.assign(baseConfig, {
|
|||
banner: "#!/usr/bin/env node",
|
||||
plugins: [
|
||||
replace({
|
||||
"#!/usr/bin/env node": ""
|
||||
"#!/usr/bin/env node": "",
|
||||
// The require-from-string module (a dependency of cosmiconfig) assumes
|
||||
// that `module.parent` exists, but it only does for `require`:ed modules.
|
||||
// Usually, require-from-string is _always_ `require`:ed, but when bundled
|
||||
// with rollup the module is turned into a plain function located directly
|
||||
// in bin/prettier.js so `module.parent` does not exist. Defaulting to
|
||||
// `module` instead seems to work.
|
||||
"module.parent": "(module.parent || module)"
|
||||
}),
|
||||
json(),
|
||||
resolve({ preferBuiltins: true }),
|
||||
|
|
|
@ -2,11 +2,25 @@ import baseConfig from "./rollup.base.config.js";
|
|||
import resolve from "rollup-plugin-node-resolve";
|
||||
import commonjs from "rollup-plugin-commonjs";
|
||||
import json from "rollup-plugin-json";
|
||||
import replace from "rollup-plugin-replace";
|
||||
|
||||
export default Object.assign(baseConfig, {
|
||||
entry: "index.js",
|
||||
dest: "dist/index.js",
|
||||
format: "cjs",
|
||||
plugins: [json(), resolve({ preferBuiltins: true }), commonjs()],
|
||||
plugins: [
|
||||
replace({
|
||||
// The require-from-string module (a dependency of cosmiconfig) assumes
|
||||
// that `module.parent` exists, but it only does for `require`:ed modules.
|
||||
// Usually, require-from-string is _always_ `require`:ed, but when bundled
|
||||
// with rollup the module is turned into a plain function located directly
|
||||
// in index.js so `module.parent` does not exist. Defaulting to `module`
|
||||
// instead seems to work.
|
||||
"module.parent": "(module.parent || module)"
|
||||
}),
|
||||
json(),
|
||||
resolve({ preferBuiltins: true }),
|
||||
commonjs()
|
||||
],
|
||||
external: ["assert"]
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue