-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor!: Convert all rules to ESM #535
Conversation
}), resolve({ preferBuiltins: false }), commonjs({ | ||
// disable __esModule interop | ||
// Node.js ESM does not recognize `__esModule` flag interop | ||
defaultIsModuleExports: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is incomatible issue between Node.js ESM and Rollup.
const newError = | ||
error instanceof Error | ||
? new Error( | ||
`Failed to load rule module: ${configDescriptorRule.id} | ||
|
||
Error: ${error.message}`, | ||
{ | ||
cause: error, | ||
} | ||
) | ||
: new Error(`Failed to load rule module: ${configDescriptorRule.id} | ||
|
||
Error: ${String(error)}`); | ||
errors.push(newError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve loading error.
@@ -4,13 +4,21 @@ import commonjs from "@rollup/plugin-commonjs"; | |||
|
|||
export default { | |||
input: "src/index.ts", | |||
// gcp rule is broken by moduleSideEffects option | |||
// treeshake: "smallest", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
treeshake: {
/**
* "smallest" will choose option values for you to minimize output size as much as possible. This should work for most code bases as long as you do not rely on certain patterns, which are currently:
*
* getters with side effects will only be retained if the return value is used (treeshake.propertyReadSideEffects: false)
* code from imported modules will only be retained if at least one exported value is used (treeshake.moduleSideEffects: false)
* you should not bundle polyfills that rely on detecting broken builtins (treeshake.tryCatchDeoptimization: false)
* some semantic issues may be swallowed (treeshake.unknownGlobalSideEffects: false, treeshake.correctVarValueBeforeDeclaration: false)
*/
propertyReadSideEffects: false,
tryCatchDeoptimization: false,
unknownGlobalSideEffects: false,
correctVarValueBeforeDeclaration: false,
moduleSideEffects: (id, external) => {
// node-fetch does not work
if (id.includes("node_modules/node-forge")) {
return true;
}
return false;
}
}
works, but file size is large.
node-forge is big.
Changes
Internal
Note
__esModule
flag by default__esModule
.commonjs({ defaultIsModuleExports: true })
to rollup.