Google search terms
Didn't try to Google the issue, but rather to look into boilerplate examples
Describe the bug
If I try to import the files like so:
{
"content_scripts": [
{
"matches": ["https://example.com/*"],
"js": [
"lib/some-library.js",
"scripts/content-script.js"
]
}
]
}
Then the output of lib/some-library.js
will be empty.
Otherwise, if I do:
{
"content_scripts": [
{
"matches": ["https://example.com/*"],
"js": ["scripts/content-script.js"]
}
]
}
scripts/content-script.js
import { someFunction } from "../lib/some-library";
The output will be:
{
"web_accessible_resources": [
"some-library-cd51b70d.js",
"scripts/content-script.js"
]
}
What will be imported in scripts/content-script.js
:
import { someFunction } from "../some-library-cd51b70d-c791af63.js";
Because the filename to be imported is different from the one that actually exists, it will fail.
How do we reproduce?
Simply create 2 content scripts that need to be linked and import one's function/variable/whatever into the other.
Expected behavior
It should work correctly.
Actual behavior
It imports a different filename than there actually is.
Please complete the following information:
- Library Version: ^3.5.1
- Operating System: Windows 10 20H2 build 19042.685
- Browser: Chromium Edge 88.0.705.29
- Node Version: 14.15.3
Additional context
rollup.config.js
import {
chromeExtension,
simpleReloader
} from "rollup-plugin-chrome-extension";
import { terser } from "rollup-plugin-terser";
import { emptyDir } from "rollup-plugin-empty-dir";
import zip from "rollup-plugin-zip";
import resolve from "@rollup/plugin-node-resolve";
const isProduction = !process.env.ROLLUP_WATCH;
export default {
input: "src/manifest.json",
output: {
dir: "dist",
format: "esm"
},
plugins: [
// always put chromeExtension() before other plugins
chromeExtension(),
!isProduction && simpleReloader(),
resolve(),
emptyDir(),
isProduction && terser(),
isProduction && zip({ dir: "dist_packed" })
]
};