@crxjs/vite-plugin 1.0.3 → 1.0.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @crxjs/vite-plugin
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - b83a4bd: Check for manifest assets first in the project root, then check in
8
+ the public dir. Throw an informative error if the file does not exist in
9
+ either dir.
10
+
3
11
  ## 1.0.3
4
12
 
5
13
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -17,6 +17,7 @@ var vite = require('vite');
17
17
  var module$1 = require('module');
18
18
  var cheerio = require('cheerio');
19
19
  var jsesc = require('jsesc');
20
+ var fs = require('fs');
20
21
  var injector = require('connect-injector');
21
22
 
22
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -2731,7 +2732,14 @@ const pluginManifest = (_manifest) => () => {
2731
2732
  const files = await manifestFiles(manifest2);
2732
2733
  await Promise.all(assetTypes.map((k) => files[k]).flat().map(async (f) => {
2733
2734
  if (typeof bundle[f] === "undefined") {
2734
- const filename = join(config.root, f);
2735
+ let filename = join(config.root, f);
2736
+ if (!fs.existsSync(filename))
2737
+ filename = join(config.publicDir, f);
2738
+ if (!fs.existsSync(filename))
2739
+ throw new Error(`ENOENT: Could not load manifest asset "${f}".
2740
+ Manifest assets must exist in one of these directories:
2741
+ Project root: "${config.root}"
2742
+ Public dir: "${config.publicDir}"`);
2735
2743
  this.emitFile({
2736
2744
  type: "asset",
2737
2745
  fileName: f,
package/dist/index.mjs CHANGED
@@ -13,6 +13,7 @@ import { createLogger } from 'vite';
13
13
  import { createRequire } from 'module';
14
14
  import { load } from 'cheerio';
15
15
  import jsesc from 'jsesc';
16
+ import { existsSync } from 'fs';
16
17
  import injector from 'connect-injector';
17
18
 
18
19
  const _debug = (id) => debug$5("crx").extend(id);
@@ -2698,7 +2699,14 @@ const pluginManifest = (_manifest) => () => {
2698
2699
  const files = await manifestFiles(manifest2);
2699
2700
  await Promise.all(assetTypes.map((k) => files[k]).flat().map(async (f) => {
2700
2701
  if (typeof bundle[f] === "undefined") {
2701
- const filename = join(config.root, f);
2702
+ let filename = join(config.root, f);
2703
+ if (!existsSync(filename))
2704
+ filename = join(config.publicDir, f);
2705
+ if (!existsSync(filename))
2706
+ throw new Error(`ENOENT: Could not load manifest asset "${f}".
2707
+ Manifest assets must exist in one of these directories:
2708
+ Project root: "${config.root}"
2709
+ Public dir: "${config.publicDir}"`);
2702
2710
  this.emitFile({
2703
2711
  type: "asset",
2704
2712
  fileName: f,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crxjs/vite-plugin",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Build Chrome Extensions with this Vite plugin.",
5
5
  "keywords": [
6
6
  "rollup-plugin",