Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
fix: Use automatic runtime for React.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShogunPanda committed Jun 1, 2021
1 parent 19c849a commit 6275b49
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 26 deletions.
8 changes: 6 additions & 2 deletions dist/cjs/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ async function setupRules(options) {
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: { presets: babelPresets.concat('@babel/react'), plugins: babelPlugins, ...babelConfiguration }
options: {
presets: babelPresets.concat(['@babel/react', { runtime: 'automatic' }]),
plugins: babelPlugins,
...babelConfiguration
}
}
});
if (useTypescript) {
Expand All @@ -115,7 +119,7 @@ async function setupRules(options) {
use: {
loader: 'babel-loader',
options: {
presets: babelPresets.concat('@babel/react', '@babel/typescript'),
presets: babelPresets.concat(['@babel/react', { runtime: 'automatic' }], '@babel/typescript'),
plugins: babelPlugins,
...babelConfiguration
}
Expand Down
4 changes: 2 additions & 2 deletions dist/mjs/icons.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { loadFontAwesomeIcons } from "./fontAwesome.js";
export { generateSVG as generateFontAwesomeSVG, loadFontAwesomeIcons } from "./fontAwesome.js";
import { loadFontAwesomeIcons } from "./fontAwesome.mjs";
export { generateSVG as generateFontAwesomeSVG, loadFontAwesomeIcons } from "./fontAwesome.mjs";
export async function loadIcons(options) {
var _a;
const toLoad = ((_a = options.icons) !== null && _a !== void 0 ? _a : {});
Expand Down
26 changes: 13 additions & 13 deletions dist/mjs/index.mjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { generateVersion, normalizeAssetPath } from '@cowtech/webpack-utils';
import { resolve } from 'path';
import TerserPlugin from 'terser-webpack-plugin';
import { autoDetectEntries } from "./entries.js";
import { runHook, setupEnvironment } from "./environment.js";
import { loadIcons } from "./icons.js";
import { setupPlugins } from "./plugins.js";
import { setupRules } from "./rules.js";
import { setupServer } from "./server.js";
export * from "./entries.js";
export * from "./environment.js";
export * from "./icons.js";
export * from "./plugins.js";
export * from "./rules.js";
export * from "./server.js";
export * from "./types.js";
import { autoDetectEntries } from "./entries.mjs";
import { runHook, setupEnvironment } from "./environment.mjs";
import { loadIcons } from "./icons.mjs";
import { setupPlugins } from "./plugins.mjs";
import { setupRules } from "./rules.mjs";
import { setupServer } from "./server.mjs";
export * from "./entries.mjs";
export * from "./environment.mjs";
export * from "./icons.mjs";
export * from "./plugins.mjs";
export * from "./rules.mjs";
export * from "./server.mjs";
export * from "./types.mjs";
export async function setup(options = {}) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
if (!options.environment || typeof options.environment !== 'string') {
Expand Down
4 changes: 2 additions & 2 deletions dist/mjs/plugins.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { Compilation, DefinePlugin, EnvironmentPlugin, HotModuleReplacementPlugi
// @ts-expect-error - Even if @types/webpack-bundle-analyzer, it generates a conflict with Webpack 5. Revisit in the future.
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import { InjectManifest } from 'workbox-webpack-plugin';
import { runHook } from "./environment.js";
export * from "./babel-remove-function.js";
import { runHook } from "./environment.mjs";
export * from "./babel-remove-function.mjs";
export const serviceWorkerDefaultInclude = [
/\.(?:html|js|json|mjs|css)$/,
/images.+\.(?:bmp|jpg|jpeg|png|svg|webp)$/
Expand Down
12 changes: 8 additions & 4 deletions dist/mjs/rules.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { imagesExtensions } from '@cowtech/webpack-utils';
import globby from 'globby';
import { resolve } from 'path';
import { babelRemoveFunction } from "./babel-remove-function.js";
import { runHook } from "./environment.js";
import { babelRemoveFunction } from "./babel-remove-function.mjs";
import { runHook } from "./environment.mjs";
/*
Refresh the following two constants periodically by running with 'last 2 versions' and debug=true
Modifications:
Expand Down Expand Up @@ -97,7 +97,11 @@ export async function setupRules(options) {
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: { presets: babelPresets.concat('@babel/react'), plugins: babelPlugins, ...babelConfiguration }
options: {
presets: babelPresets.concat(['@babel/react', { runtime: 'automatic' }]),
plugins: babelPlugins,
...babelConfiguration
}
}
});
if (useTypescript) {
Expand All @@ -107,7 +111,7 @@ export async function setupRules(options) {
use: {
loader: 'babel-loader',
options: {
presets: babelPresets.concat('@babel/react', '@babel/typescript'),
presets: babelPresets.concat(['@babel/react', { runtime: 'automatic' }], '@babel/typescript'),
plugins: babelPlugins,
...babelConfiguration
}
Expand Down
2 changes: 1 addition & 1 deletion dist/mjs/server.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFile } from 'fs/promises';
import globby from 'globby';
import { resolve } from 'path';
import { runHook } from "./environment.js";
import { runHook } from "./environment.mjs";
export async function setupServer(options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
const serverOptions = (_a = options.server) !== null && _a !== void 0 ? _a : {};
Expand Down
8 changes: 6 additions & 2 deletions src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ export async function setupRules(options: Options): Promise<Array<RuleSetRule>>
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: { presets: babelPresets.concat('@babel/react'), plugins: babelPlugins, ...babelConfiguration }
options: {
presets: babelPresets.concat(['@babel/react', { runtime: 'automatic' }]),
plugins: babelPlugins,
...babelConfiguration
}
}
})

Expand All @@ -126,7 +130,7 @@ export async function setupRules(options: Options): Promise<Array<RuleSetRule>>
use: {
loader: 'babel-loader',
options: {
presets: babelPresets.concat('@babel/react', '@babel/typescript'),
presets: babelPresets.concat(['@babel/react', { runtime: 'automatic' }], '@babel/typescript'),
plugins: babelPlugins,
...babelConfiguration
}
Expand Down

0 comments on commit 6275b49

Please sign in to comment.