Answer the question
In order to leave comments, you need to log in
How to import files in manifest for firefox extension?
Hello, I'm learning TypeScript and decided to use it in one of my projects - an extension for Firefox.
I want to make a module system so that the project can be easily scaled in the future, so I'm trying to separate the functionality into files (the core.ts file tries to import modules/log. ts, etc., and they are inherited from modules/module.ts)
File structure:
{
"version": "1.0",
"manifest_version": 2,
"name": "надрез мозжечка",
"description": "Манипулятор ВКонтакте с функцией самоподрыва от Альянса Злодеев",
"applications": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "95.0.2"
}
},
"content_scripts": [
{
"matches": [
"*://*.vk.com/*"
],
"js": [
"/system/modules/module.js",
"/system/modules/log.js",
"/system/modules/visor.js",
"/system/modules/killer.js",
"/system/core.js"
]
}
]
}
/**
* @author Arsen Mirzaev Tatyano-Muradovich <[email protected]>
*/
export default class module {
}
import module from "./module";
export default class log extends module {
constructor(public debug: boolean = false) {
super();
}
/**
* Запись в журнал
*
* @param text Текст для записи
*/
write(...text: string[]) {
if (this.debug) {
// Активен режим отладки
console.log('[надрез мозжечка]', ...text);
}
}
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
exports.__esModule = true;
var module_1 = require("./module");
var log = /** @class */ (function (_super) {
__extends(log, _super);
function log(debug) {
if (debug === void 0) { debug = false; }
var _this = _super.call(this) || this;
_this.debug = debug;
return _this;
}
/**
* Запись в журнал
*
* @param text Текст для записи
*/
log.prototype.write = function () {
var text = [];
for (var _i = 0; _i < arguments.length; _i++) {
text[_i] = arguments[_i];
}
if (this.debug) {
// Активен режим отладки
console.log.apply(console, __spreadArray(['[надрез мозжечка]'], text, false));
}
};
return log;
}(module_1["default"]));
exports["default"] = log;
Answer the question
In order to leave comments, you need to log in
I decided to leave TS for now, I develop on raw JS. I rewrote all this for him and got the same problem.
I seem to understand: all the files are already loaded, since they are indicated in
manifest.json
. all import expressions and everything works
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question