Does Chrome Extensions Allow Webpack Bundle in Production mode?

1,172 views
Skip to first unread message

Ngoc Duc Huynh

unread,
Feb 28, 2021, 6:10:30 AM2/28/21
to Chromium Extensions
Hi, I'm writing an extension using React Typescript and webpack, does chrome extensions allow publish the code bundled using webpack in production mode?

ilyaigpetrov

unread,
Feb 28, 2021, 9:19:30 AM2/28/21
to Chromium Extensions, provan...@gmail.com
1) WebStore requires you to use minification but not obfuscation. See https://stackoverflow.com/a/56006881/521957 and https://developer.chrome.com/docs/webstore/program_policies/:

> Minification is allowed, including the following forms:
> - Removal of whitespace, newlines, code comments, and block delimiters
> - Shortening of variable and function names
> - Collapsing files together

You will help us with your question if you share some details about what kind of minification library are you going to use in your extension.

2) WebStore requires you to provide clear and strong justifications if you use `eval` in a mv2 extension. In mv3 remote code is no longer allowed: see https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/#remotely-hosted-code.

Whatever package bundler (webpack or not) you use you have to abide 1) and 2).

Ngoc Duc Huynh

unread,
Feb 28, 2021, 9:42:21 AM2/28/21
to Chromium Extensions, ilyaigpetrov
Hi, I use this template on github, here is the webpack config for publish into store:
The code:

const path = require("path"); module.exports = { entry: { popup: path.join(__dirname, "src/popup/index.tsx"), eventPage: path.join(__dirname, "src/eventPage.ts") }, output: { path: path.join(__dirname, "dist/js"), filename: "[name].js" }, module: { rules: [ { exclude: /node_modules/, test: /\.tsx?$/, use: "ts-loader" }, { exclude: /node_modules/, test: /\.scss$/, use: [ { loader: "style-loader" // Creates style nodes from JS strings }, { loader: "css-loader" // Translates CSS into CommonJS }, { loader: "sass-loader" // Compiles Sass to CSS } ] } ] }, resolve: { extensions: [".ts", ".tsx", ".js"] } };

Screenshot_20210228-223851_Samsung Internet.jpg
 Does this config is safe? Or I just need submit typescript source code into chrome extension and they will convert to javascript files?


Vào lúc 22:19:30 UTC+8 ngày Chủ Nhật, 28 tháng 2, 2021, ilyaigpetrov đã viết:

ilyaigpetrov

unread,
Feb 28, 2021, 9:50:46 AM2/28/21
to Ngoc Duc Huynh, Chromium Extensions
> Or I just need submit typescript source code into chrome extension and they will convert to javascript files?

No, you have to convert ts to js yourself. In the final bundle there should be no ts.

> Does this config is safe?

I've looked at this boilerplate quickly and didn't find any minification library, only a transpiler from typescript to js.
If there is no minification then you are fine with minification requirement. 
Reply all
Reply to author
Forward
0 new messages