extension-develop 2.0.0-rc.26 → 2.0.0-rc.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -164,7 +164,7 @@ const GECKO_BASED_BROWSERS = [
164
164
  ];
165
165
  const external_console_namespaceObject = require("console");
166
166
  var package_namespaceObject = {
167
- i8: "2.0.0-rc.26"
167
+ i8: "2.0.0-rc.27"
168
168
  };
169
169
  function getLoggingPrefix(feature, type) {
170
170
  if ('error' === type) return `${external_chalk_default().bold(external_chalk_default().red('ERROR'))} in ${feature} ${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")}`;
@@ -307,6 +307,11 @@ function defaultPortInUse(port) {
307
307
  function noExtensionIdError() {
308
308
  return `${getLoggingPrefix('manifest.json', 'error')} Extension ID Not Defined\n\nFor MAIN world content_scripts, the extension ID must be specified.\nEnsure your extension have a fixed ID and that the ${external_chalk_default().yellow('publicPath')}\nof your ${external_chalk_default().yellow('extension.config.js')} is defined as your extension URL.`;
309
309
  }
310
+ function isUsingCustomLoader(file) {
311
+ const loaderName = file.split('.').shift() || 'custom';
312
+ const capitalizedLoaderName = loaderName.charAt(0).toUpperCase() + loaderName.slice(1);
313
+ return `${getLoggingPrefix(capitalizedLoaderName, 'info')} Using custom loader configuration from ${file}`;
314
+ }
310
315
  function plugin_compilation_define_property(obj, key, value) {
311
316
  if (key in obj) Object.defineProperty(obj, key, {
312
317
  value: value,
@@ -1060,6 +1065,27 @@ async function maybeUseReact(projectPath) {
1060
1065
  };
1061
1066
  }
1062
1067
  const external_vue_loader_namespaceObject = require("vue-loader");
1068
+ let load_loader_options_userMessageDelivered = false;
1069
+ async function loadLoaderOptions(projectPath, framework) {
1070
+ const loaderPath = external_path_namespaceObject.join(projectPath, `${framework}.loader.js`);
1071
+ const moduleLoaderPath = external_path_namespaceObject.join(projectPath, `${framework}.loader.mjs`);
1072
+ if (external_fs_namespaceObject.existsSync(loaderPath) || external_fs_namespaceObject.existsSync(moduleLoaderPath)) {
1073
+ const configPath = external_fs_namespaceObject.existsSync(loaderPath) ? loaderPath : moduleLoaderPath;
1074
+ if (!load_loader_options_userMessageDelivered) {
1075
+ console.log(isUsingCustomLoader(`${framework}.loader.js`));
1076
+ load_loader_options_userMessageDelivered = true;
1077
+ }
1078
+ try {
1079
+ const module = await import(configPath);
1080
+ return module.default || module;
1081
+ } catch (err) {
1082
+ const error = err;
1083
+ console.error(`Error loading ${framework} loader options: ${error.message}`);
1084
+ throw err;
1085
+ }
1086
+ }
1087
+ return null;
1088
+ }
1063
1089
  let vue_userMessageDelivered = false;
1064
1090
  function isUsingVue(projectPath) {
1065
1091
  const packageJsonPath = external_path_namespaceObject.join(projectPath, 'package.json');
@@ -1089,23 +1115,25 @@ async function maybeUseVue(projectPath) {
1089
1115
  console.log(youAreAllSet('Vue'));
1090
1116
  process.exit(0);
1091
1117
  }
1092
- const vueLoaders = [
1118
+ const customOptions = await loadLoaderOptions(projectPath, 'vue');
1119
+ const defaultLoaders = [
1093
1120
  {
1094
1121
  test: /\.vue$/,
1095
1122
  loader: require.resolve('vue-loader'),
1096
1123
  options: {
1097
- experimentalInlineMatchResource: true
1124
+ experimentalInlineMatchResource: true,
1125
+ ...customOptions || {}
1098
1126
  },
1099
1127
  include: projectPath,
1100
1128
  exclude: /node_modules/
1101
1129
  }
1102
1130
  ];
1103
- const vuePlugins = [
1131
+ const defaultPlugins = [
1104
1132
  new external_vue_loader_namespaceObject.VueLoaderPlugin()
1105
1133
  ];
1106
1134
  return {
1107
- plugins: vuePlugins,
1108
- loaders: vueLoaders,
1135
+ plugins: defaultPlugins,
1136
+ loaders: defaultLoaders,
1109
1137
  alias: void 0
1110
1138
  };
1111
1139
  }
@@ -1197,7 +1225,8 @@ async function maybeUseSvelte(projectPath, mode) {
1197
1225
  console.log(youAreAllSet('Svelte'));
1198
1226
  process.exit(0);
1199
1227
  }
1200
- const svelteLoaders = [
1228
+ const customOptions = await loadLoaderOptions(projectPath, 'svelte');
1229
+ const defaultLoaders = [
1201
1230
  {
1202
1231
  test: /\.svelte\.ts$/,
1203
1232
  use: [
@@ -1216,7 +1245,8 @@ async function maybeUseSvelte(projectPath, mode) {
1216
1245
  dev: 'development' === mode,
1217
1246
  css: 'injected'
1218
1247
  },
1219
- hotReload: 'development' === mode
1248
+ hotReload: 'development' === mode,
1249
+ ...customOptions || {}
1220
1250
  }
1221
1251
  },
1222
1252
  include: projectPath,
@@ -1231,7 +1261,7 @@ async function maybeUseSvelte(projectPath, mode) {
1231
1261
  ];
1232
1262
  return {
1233
1263
  plugins: void 0,
1234
- loaders: svelteLoaders,
1264
+ loaders: defaultLoaders,
1235
1265
  alias: void 0
1236
1266
  };
1237
1267
  }
@@ -52,3 +52,4 @@ export declare function certRequired(): string;
52
52
  export declare function defaultPortInUse(port: number): string;
53
53
  export declare function noExtensionIdError(): string;
54
54
  export declare function deprecatedShadowRoot(): string;
55
+ export declare function isUsingCustomLoader(file: string): string;
@@ -0,0 +1 @@
1
+ export declare function loadLoaderOptions(projectPath: string, framework: 'vue' | 'svelte'): Promise<any>;
@@ -0,0 +1,9 @@
1
+ import { Compiler } from '@rspack/core';
2
+ import { type PluginInterface } from '../../reload-types';
3
+ export declare class GenerateReloaderExtension {
4
+ private readonly browser;
5
+ constructor(options: PluginInterface);
6
+ private copyRecursively;
7
+ private copyExtensionFiles;
8
+ apply(compiler: Compiler): void;
9
+ }
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "dist"
22
22
  ],
23
23
  "name": "extension-develop",
24
- "version": "2.0.0-rc.26",
24
+ "version": "2.0.0-rc.27",
25
25
  "description": "The develop step of Extension.js",
26
26
  "author": {
27
27
  "name": "Cezar Augusto",
@@ -49,7 +49,7 @@
49
49
  "firefox-location2": "1.0.0",
50
50
  "firefox-profile": "^4.7.0",
51
51
  "fx-runner": "^1.4.0",
52
- "go-git-it": "4.0.0-1",
52
+ "go-git-it": "4.0.0",
53
53
  "ignore": "^6.0.2",
54
54
  "loader-utils": "^3.3.1",
55
55
  "micromatch": "^4.0.8",