Skip to content

Commit

Permalink
docs(bundler): improve docs of bundle.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hulxv committed Sep 29, 2024
1 parent a282d35 commit 58a7343
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions crates/metassr-bundler/src/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,77 +16,77 @@ function safelyParseJSON(json) {

// Default configuration object for rspack bundling process
let config = {

output: {
filename: '[name].js',
filename: '[name].js', // Output filename with the entry name
library: {
type: 'commonjs2',
type: 'commonjs2', // Set library type to CommonJS2 (Node.js modules)
},
publicPath: ''
publicPath: '' // Specify the base path for all assets within the application
},
resolve: {
extensions: ['.js', '.jsx', '.tsx', '.ts']
extensions: ['.js', '.jsx', '.tsx', '.ts'] // Extensions that will be resolved
},
optimization: {
minimize: false,
minimize: false, // Disable minimization for easier debugging
},
module: {
rules: [
{
test: /\.(jsx|js)$/,
exclude: /node_modules/,
test: /\.(jsx|js)$/, // Rule for JavaScript and JSX files
exclude: /node_modules/, // Exclude node_modules directory
use: {
loader: 'builtin:swc-loader',
loader: 'builtin:swc-loader', // Use the SWC loader to transpile ES6+ and JSX
options: {
sourceMap: true,
sourceMap: true, // Enable source maps for easier debugging
jsc: {
parser: {
syntax: 'ecmascript',
jsx: true,
syntax: 'ecmascript', // Set parser syntax to ECMAScript
jsx: true, // Enable parsing JSX syntax
},
externalHelpers: false,
preserveAllComments: false,
externalHelpers: false, // Disable external helpers (use inline helpers)
preserveAllComments: false, // Remove comments from output
transform: {
react: {
runtime: 'automatic',
throwIfNamespace: true,
useBuiltins: false,
runtime: 'automatic', // Use React's automatic JSX runtime
throwIfNamespace: true, // Throw error if namespace is used
useBuiltins: false, // Don't include built-in polyfills
},
},
},
},

},
type: 'javascript/auto',
type: 'javascript/auto', // Specify the type as auto (for backward compatibility)
},
{
test: /\.(tsx|ts)$/,
exclude: /node_modules/,
test: /\.(tsx|ts)$/, // Rule for TypeScript and TSX files
exclude: /node_modules/, // Exclude node_modules directory
use: {
loader: 'builtin:swc-loader',
loader: 'builtin:swc-loader', // Use the SWC loader to transpile TS and TSX
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
syntax: 'typescript', // Set parser syntax to TypeScript
tsx: true, // Enable parsing TSX syntax
},
transform: {
react: {
runtime: 'automatic',
throwIfNamespace: true,
useBuiltins: false,
runtime: 'automatic', // Use React's automatic JSX runtime
throwIfNamespace: true, // Throw error if namespace is used
useBuiltins: false, // Don't include built-in polyfills
},
},
},
},
},
type: 'javascript/auto',
type: 'javascript/auto', // Specify the type as auto
},
{
test: /\.(png|svg|jpg)$/,
type: 'asset/inline',
test: /\.(png|svg|jpg)$/, // Rule for image files (PNG, SVG, JPG)
type: 'asset/inline', // Inline assets as Base64 strings
},
],
},
};

/**
* Bundles web resources using rspack.
Expand Down Expand Up @@ -131,5 +131,5 @@ async function web_bundling(entry, dist) {
}

module.exports = {
web_bundling
web_bundling // Export the web_bundling function to call it via metacall
};

0 comments on commit 58a7343

Please sign in to comment.