Skip to content
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

Improve named export analysis #1649

Merged
merged 2 commits into from
Nov 26, 2020
Merged

Conversation

FredKSchott
Copy link
Owner

@FredKSchott FredKSchott commented Nov 18, 2020

Changes

  • Update cjs-module-lexer to latest v1.0.0+
  • Fixed some oddity around cjs-module-lexer version support, where TS was getting mad about the parse function not existing.
  • Add UMD runtime scanning support

Testing

  • Test added.

Docs

  • N/A

@vercel
Copy link

vercel bot commented Nov 18, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pikapkg/snowpack/k27ir9ik3
✅ Preview: https://snowpack-git-improve-named-export-analysis.pikapkg.vercel.app

? cjsAutoDetectExportsRuntime(val)
: cjsAutoDetectExportsStatic(val);
? cjsAutoDetectExportsTrusted(val)
: cjsAutoDetectExportsUntrusted(val);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chose more appropriate names, now that there's a (sandboxed) runtime aspect to our untrusted scanner.

export default cjs;"
var all = cjs.all;
export default cjs;
export { cjs as __moduleExports, all };"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected bug fix ftw!

// Uses VM2 to run safely sandbox untrusted code (no access no Node.js primitives, just JS).
if (isMainEntrypoint && exports.length === 0 && reexports.length === 0) {
const vm = new VM2({wasm: false, fixAsync: false});
exports = Object.keys(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if module.exports isn't an object? || {}?

@FredKSchott FredKSchott merged commit cd3027f into main Nov 26, 2020
@FredKSchott FredKSchott deleted the improve-named-export-analysis branch November 26, 2020 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants