From adbeb2497929d73885f9bd9911beb76bcecc2223 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 27 Jun 2021 23:36:35 -0700 Subject: starting to work Former-commit-id: ae113559c6dd1e1e77b69ee5edee93fe59b4be2e --- src/js_parser/js_parser.zig | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/js_parser/js_parser.zig') diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig index 39c3af492..d4490a1c5 100644 --- a/src/js_parser/js_parser.zig +++ b/src/js_parser/js_parser.zig @@ -1611,6 +1611,9 @@ pub const Parser = struct { filepath_hash_for_hmr: u32 = 0, features: RuntimeFeatures = RuntimeFeatures{}, + // When platform is set to "speedy" + force_commonjs: bool = false, + // Used when bundling node_modules enable_bundling: bool = false, transform_require_to_import: bool = true, @@ -3132,8 +3135,13 @@ pub fn NewParser( p.hoistSymbols(p.module_scope); - p.exports_ref = try p.declareSymbol(.hoisted, logger.Loc.Empty, "exports"); - p.module_ref = try p.declareSymbol(.hoisted, logger.Loc.Empty, "module"); + if (p.options.force_commonjs) { + p.exports_ref = try p.declareCommonJSSymbol(.unbound, "exports"); + p.module_ref = try p.declareCommonJSSymbol(.unbound, "module"); + } else { + p.exports_ref = try p.declareSymbol(.hoisted, logger.Loc.Empty, "exports"); + p.module_ref = try p.declareSymbol(.hoisted, logger.Loc.Empty, "module"); + } if (p.options.enable_bundling) { p.bundle_export_ref = try p.declareSymbol(.unbound, logger.Loc.Empty, "IF_YOU_SEE_THIS_ITS_A_BUNDLER_BUG_PLEASE_FILE_AN_ISSUE_THX"); -- cgit v1.2.3