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

[Feature]: Support different extensions for JS files #740

Open
Esemesek opened this issue Jan 31, 2025 · 1 comment
Open

[Feature]: Support different extensions for JS files #740

Esemesek opened this issue Jan 31, 2025 · 1 comment
Assignees

Comments

@Esemesek
Copy link

Esemesek commented Jan 31, 2025

What problem does this feature solve?

Currently, RSDoctor doesn't work correctly out of the box whenever used in Re.Pack projects. It detects no Javascript files, doesn't display Bundle Analyzer Graph at all and probably few other things that I haven't managed to spot. This is most likely caused by React Native using .bundle extensions instead of .js.
I was able to make things somewhat work:

  • Bundle Analyzer Graph by patching the webpack-bundle-analyzer
diff --git a/lib/analyzer.js b/lib/analyzer.js
index 96c52ee4845334e3a717758b9c18fafa0feb0cdf..025bbd375235e2f856c8bbf1ad7737a2bc2a99a3 100644
--- a/lib/analyzer.js
+++ b/lib/analyzer.js
@@ -23,7 +23,7 @@ const {
 } = require('./utils');
 
 const FILENAME_QUERY_REGEXP = /\?.*$/u;
-const FILENAME_EXTENSIONS = /\.(js|mjs|cjs)$/iu;
+const FILENAME_EXTENSIONS = /\.(js|mjs|cjs|bundle)$/iu;
 module.exports = {
   getViewerData,
   readStatsFromFile
  • Javascript files are displayed correctly by hacking JSExtension variable from @rsdoctor/types and changing it from .js to .bundle
diff --git a/dist/constants.js b/dist/constants.js
index 2abd2ebe15b280026f61485b0d513980df7cc876..ee7c71da9afb51aca58661e7333c0e0266d4da03 100644
--- a/dist/constants.js
+++ b/dist/constants.js
@@ -1,7 +1,7 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.WINDOW_RSDOCTOR_TAG = exports.RsdoctorClientUrl = exports.RsdoctorProcessEnvDebugKey = exports.RsdoctorMonitorDocBId = exports.RsdoctorMonitorWebBId = exports.RsdoctorMonitorNodeBId = exports.StatsFilePath = exports.RsdoctorOutputManifestPath = exports.RsdoctorOutputManifest = exports.RsdoctorOutputFolder = exports.MapExtensions = exports.FontExtensions = exports.MediaExtensions = exports.ImgExtensions = exports.HtmlExtension = exports.CSSExtension = exports.JSExtension = void 0;
-exports.JSExtension = '.js';
+exports.JSExtension = '.bundle';
 exports.CSSExtension = '.css';
 exports.HtmlExtension = '.html';
 exports.ImgExtensions = [

Repro available here: https://github.com/ZephyrCloudIO/zephyr-repack-example

What does the proposed API look like?

I just want the plugin to work with RePack projects.

@Esemesek Esemesek changed the title [Feature]: React Native support via Re.Pack [Feature]: Support different extensions for JS files Jan 31, 2025
@easy1090
Copy link
Contributor

easy1090 commented Feb 6, 2025

Understood, we will support this later.

@easy1090 easy1090 self-assigned this Feb 6, 2025
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

No branches or pull requests

2 participants