@metamask/snaps-rollup-plugin 0.37.2-flask.1 → 1.0.0

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
@@ -6,11 +6,173 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- ## [0.37.2-flask.1]
9
+ ## [1.0.0]
10
10
  ### Changed
11
- - Release package independently ([#1600](https://github.com/MetaMask/snaps/pull/1600))
12
- - The version of the package no longer needs to match the version of all other
13
- MetaMask Snaps packages.
11
+ - No changes this release.
14
12
 
15
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rollup-plugin@0.37.2-flask.1...HEAD
16
- [0.37.2-flask.1]: https://github.com/MetaMask/snaps/releases/tag/@metamask/snaps-rollup-plugin@0.37.2-flask.1
13
+ ## [1.0.0-prerelease.1]
14
+ ### Changed
15
+ - No changes this release.
16
+
17
+ ## [0.32.2]
18
+ ### Changed
19
+ - No changes this release.
20
+
21
+ ## [0.32.1]
22
+ ### Changed
23
+ - No changes this release.
24
+
25
+ ## [0.32.0]
26
+ ### Changed
27
+ - No changes this release.
28
+
29
+ ## [0.31.0]
30
+ ### Changed
31
+ - **BREAKING:** Target `ES2020` ([#1247](https://github.com/MetaMask/snaps-monorepo/pull/1247))
32
+
33
+ ## [0.30.0]
34
+ ### Changed
35
+ - No changes this release.
36
+
37
+ ## [0.29.0]
38
+ ### Changed
39
+ - No changes this release.
40
+
41
+ ## [0.28.0]
42
+ ### Changed
43
+ - No changes this release.
44
+
45
+ ## [0.27.1]
46
+ ### Changed
47
+ - No changes this release.
48
+
49
+ ## [0.27.0]
50
+ ### Changed
51
+ - No changes this release.
52
+
53
+ ## [0.26.2]
54
+ ### Changed
55
+ - No changes this release.
56
+
57
+ ## [0.26.1]
58
+ ### Changed
59
+ - No changes this release.
60
+
61
+ ## [0.26.0]
62
+ ### Changed
63
+ - No changes this release.
64
+
65
+ ## [0.25.0]
66
+ ### Changed
67
+ - No changes this release.
68
+
69
+ ## [0.24.1]
70
+ ### Changed
71
+ - No changes this release.
72
+
73
+ ## [0.24.0]
74
+ ### Added
75
+ - Add compile-time warning when using `Math.random` ([#950](https://github.com/MetaMask/snaps-monorepo/pull/950))
76
+
77
+ ### Changed
78
+ - **BREAKING:** Rename package to start with `snaps-` ([#937](https://github.com/MetaMask/snaps-monorepo/pull/937))
79
+
80
+ ## [0.23.0]
81
+ ### Changed
82
+ - No changes this release.
83
+
84
+ ## [0.22.3]
85
+ ### Changed
86
+ - No changes this release.
87
+
88
+ ## [0.22.2]
89
+ ### Changed
90
+ - No changes this release.
91
+
92
+ ## [0.22.1]
93
+ ### Changed
94
+ - No changes this release.
95
+
96
+ ## [0.22.0]
97
+ ### Changed
98
+ - No changes this release.
99
+
100
+ ## [0.21.0]
101
+ ### Added
102
+ - Run eval and fix manifest in bundler plugins ([#731](https://github.com/MetaMask/snaps-monorepo/pull/731))
103
+
104
+ ## [0.20.0]
105
+ ### Changed
106
+ - No changes this release.
107
+
108
+ ## [0.19.1]
109
+ ### Added
110
+ - Generate source maps from modified code ([#615](https://github.com/MetaMask/snaps-monorepo/pull/615))
111
+
112
+ ## [0.19.0]
113
+ ### Changed
114
+ - No changes this release.
115
+
116
+ ## [0.18.1]
117
+ ### Changed
118
+ - No changes this release.
119
+
120
+ ## [0.18.0]
121
+ ### Changed
122
+ - Reduce TypeScript compilation target to ES2017 ([#628](https://github.com/MetaMask/snaps-monorepo/pull/628))
123
+
124
+ ## [0.17.0]
125
+ ### Changed
126
+ - **BREAKING:** Bump minimum Node version to 16 ([#601](https://github.com/MetaMask/snaps-monorepo/pull/601))
127
+
128
+ ## [0.16.0]
129
+ ### Changed
130
+ - No changes this release.
131
+
132
+ ## [0.15.0]
133
+ ### Changed
134
+ - No changes this release.
135
+
136
+ ## [0.14.0]
137
+ ### Fixed
138
+ - Actually publish package contents ([#449](https://github.com/MetaMask/snaps-monorepo/pull/449))
139
+ - Package contents were omitted from the previous version due to a build failure.
140
+
141
+ ## [0.13.0]
142
+ ### Added
143
+ - Initial release ([#431](https://github.com/MetaMask/snaps-monorepo/pull/431))
144
+
145
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/v1.0.0...HEAD
146
+ [1.0.0]: https://github.com/MetaMask/snaps/compare/v1.0.0-prerelease.1...v1.0.0
147
+ [1.0.0-prerelease.1]: https://github.com/MetaMask/snaps/compare/v0.32.2...v1.0.0-prerelease.1
148
+ [0.32.2]: https://github.com/MetaMask/snaps/compare/v0.32.1...v0.32.2
149
+ [0.32.1]: https://github.com/MetaMask/snaps/compare/v0.32.0...v0.32.1
150
+ [0.32.0]: https://github.com/MetaMask/snaps/compare/v0.31.0...v0.32.0
151
+ [0.31.0]: https://github.com/MetaMask/snaps/compare/v0.30.0...v0.31.0
152
+ [0.30.0]: https://github.com/MetaMask/snaps/compare/v0.29.0...v0.30.0
153
+ [0.29.0]: https://github.com/MetaMask/snaps/compare/v0.28.0...v0.29.0
154
+ [0.28.0]: https://github.com/MetaMask/snaps/compare/v0.27.1...v0.28.0
155
+ [0.27.1]: https://github.com/MetaMask/snaps/compare/v0.27.0...v0.27.1
156
+ [0.27.0]: https://github.com/MetaMask/snaps/compare/v0.26.2...v0.27.0
157
+ [0.26.2]: https://github.com/MetaMask/snaps/compare/v0.26.1...v0.26.2
158
+ [0.26.1]: https://github.com/MetaMask/snaps/compare/v0.26.0...v0.26.1
159
+ [0.26.0]: https://github.com/MetaMask/snaps/compare/v0.25.0...v0.26.0
160
+ [0.25.0]: https://github.com/MetaMask/snaps/compare/v0.24.1...v0.25.0
161
+ [0.24.1]: https://github.com/MetaMask/snaps/compare/v0.24.0...v0.24.1
162
+ [0.24.0]: https://github.com/MetaMask/snaps/compare/v0.23.0...v0.24.0
163
+ [0.23.0]: https://github.com/MetaMask/snaps/compare/v0.22.3...v0.23.0
164
+ [0.22.3]: https://github.com/MetaMask/snaps/compare/v0.22.2...v0.22.3
165
+ [0.22.2]: https://github.com/MetaMask/snaps/compare/v0.22.1...v0.22.2
166
+ [0.22.1]: https://github.com/MetaMask/snaps/compare/v0.22.0...v0.22.1
167
+ [0.22.0]: https://github.com/MetaMask/snaps/compare/v0.21.0...v0.22.0
168
+ [0.21.0]: https://github.com/MetaMask/snaps/compare/v0.20.0...v0.21.0
169
+ [0.20.0]: https://github.com/MetaMask/snaps/compare/v0.19.1...v0.20.0
170
+ [0.19.1]: https://github.com/MetaMask/snaps/compare/v0.19.0...v0.19.1
171
+ [0.19.0]: https://github.com/MetaMask/snaps/compare/v0.18.1...v0.19.0
172
+ [0.18.1]: https://github.com/MetaMask/snaps/compare/v0.18.0...v0.18.1
173
+ [0.18.0]: https://github.com/MetaMask/snaps/compare/v0.17.0...v0.18.0
174
+ [0.17.0]: https://github.com/MetaMask/snaps/compare/v0.16.0...v0.17.0
175
+ [0.16.0]: https://github.com/MetaMask/snaps/compare/v0.15.0...v0.16.0
176
+ [0.15.0]: https://github.com/MetaMask/snaps/compare/v0.14.0...v0.15.0
177
+ [0.14.0]: https://github.com/MetaMask/snaps/compare/v0.13.0...v0.14.0
178
+ [0.13.0]: https://github.com/MetaMask/snaps/releases/tag/v0.13.0
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ // This file is only used for testing source map generation.
3
+ // eslint-disable-next-line import/unambiguous
4
+ const foo = 'bar';
5
+ // eslint-disable-next-line no-console
6
+ console.log(foo);
7
+ //# sourceMappingURL=source-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-map.js","sourceRoot":"","sources":["../../src/__fixtures__/source-map.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAE5D,8CAA8C;AAC9C,MAAM,GAAG,GAAG,KAAK,CAAC;AAClB,sCAAsC;AACtC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC","sourcesContent":["// This file is only used for testing source map generation.\n\n// eslint-disable-next-line import/unambiguous\nconst foo = 'bar';\n// eslint-disable-next-line no-console\nconsole.log(foo);\n"]}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = void 0;
7
+ var plugin_1 = require("./plugin");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(plugin_1).default; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAmC;AAA1B,kHAAA,OAAO,OAAA","sourcesContent":["export { default } from './plugin';\nexport type { Options } from './plugin';\n"]}
@@ -1,5 +1,5 @@
1
- import type { PostProcessOptions } from '@metamask/snaps-utils';
2
- import type { Plugin } from 'rollup';
1
+ import { PostProcessOptions } from '@metamask/snaps-utils';
2
+ import { Plugin } from 'rollup';
3
3
  declare type PluginOptions = {
4
4
  eval?: boolean;
5
5
  manifestPath?: string;
@@ -1,6 +1,11 @@
1
- import { checkManifest, evalBundle, postProcessBundle } from '@metamask/snaps-utils';
2
- import { promises as fs } from 'fs';
3
- import pathUtils from 'path';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const snaps_utils_1 = require("@metamask/snaps-utils");
7
+ const fs_1 = require("fs");
8
+ const path_1 = __importDefault(require("path"));
4
9
  /**
5
10
  * Creates a Snaps Rollup plugin instance.
6
11
  *
@@ -14,42 +19,40 @@ import pathUtils from 'path';
14
19
  * @param options.writeManifest - Whether to fix the manifest. Defaults to
15
20
  * `true`.
16
21
  * @returns The Rollup plugin object.
17
- */ export default function snaps(options) {
22
+ */
23
+ function snaps(options) {
18
24
  const defaultOptions = {
19
25
  eval: true,
20
- manifestPath: pathUtils.join(process.cwd(), 'snap.manifest.json'),
26
+ manifestPath: path_1.default.join(process.cwd(), 'snap.manifest.json'),
21
27
  writeManifest: true,
22
- ...options
28
+ ...options,
23
29
  };
24
30
  return {
25
31
  name: '@metamask/snaps-rollup-plugin',
26
- renderChunk (code) {
32
+ renderChunk(code) {
27
33
  // Rollup internally merges the new source map with the old one, so there
28
34
  // is no need to pass the current source map to the function.
29
- const result = postProcessBundle(code, {
35
+ const result = (0, snaps_utils_1.postProcessBundle)(code, {
30
36
  ...defaultOptions,
31
- sourceMap: true
37
+ sourceMap: true,
32
38
  });
33
39
  if (result.warnings.length > 0) {
34
40
  this.warn(`Bundle Warning: Processing of the Snap bundle completed with warnings.\n${result.warnings.join('\n')}`);
35
41
  }
36
- return {
37
- code: result.code,
38
- map: result.sourceMap
39
- };
42
+ return { code: result.code, map: result.sourceMap };
40
43
  },
41
- async writeBundle (output) {
44
+ async writeBundle(output) {
42
45
  if (!output.file) {
43
46
  this.warn('No output file specified, skipping bundle validation.');
44
47
  return;
45
48
  }
46
49
  if (defaultOptions.eval) {
47
- await evalBundle(output.file).catch((error)=>{
50
+ await (0, snaps_utils_1.evalBundle)(output.file).catch((error) => {
48
51
  this.error(error);
49
52
  });
50
53
  }
51
54
  if (defaultOptions.manifestPath) {
52
- const { errors, warnings } = await checkManifest(pathUtils.dirname(defaultOptions.manifestPath), defaultOptions.writeManifest, await fs.readFile(output.file, 'utf8'));
55
+ const { errors, warnings } = await (0, snaps_utils_1.checkManifest)(path_1.default.dirname(defaultOptions.manifestPath), defaultOptions.writeManifest, await fs_1.promises.readFile(output.file, 'utf8'));
53
56
  if (!defaultOptions.writeManifest && errors.length > 0) {
54
57
  this.error(`Manifest Error: The manifest is invalid.\n${errors.join('\n')}`);
55
58
  }
@@ -57,8 +60,8 @@ import pathUtils from 'path';
57
60
  this.warn(`Manifest Warning: Validation of snap.manifest.json completed with warnings.\n${warnings.join('\n')}`);
58
61
  }
59
62
  }
60
- }
63
+ },
61
64
  };
62
65
  }
63
-
66
+ exports.default = snaps;
64
67
  //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;AAAA,uDAK+B;AAC/B,2BAAoC;AACpC,gDAA6B;AAa7B;;;;;;;;;;;;;GAaG;AACH,SAAwB,KAAK,CAAC,OAA0B;IACtD,MAAM,cAAc,GAAG;QACrB,IAAI,EAAE,IAAI;QACV,YAAY,EAAE,cAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC;QACjE,aAAa,EAAE,IAAI;QACnB,GAAG,OAAO;KACX,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,+BAA+B;QAErC,WAAW,CAAC,IAAY;YACtB,yEAAyE;YACzE,6DAA6D;YAC7D,MAAM,MAAM,GAAG,IAAA,+BAAiB,EAAC,IAAI,EAAE;gBACrC,GAAG,cAAc;gBACjB,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YAEH,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC9B,IAAI,CAAC,IAAI,CACP,2EAA2E,MAAM,CAAC,QAAQ,CAAC,IAAI,CAC7F,IAAI,CACL,EAAE,CACJ,CAAC;aACH;YAED,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;QACtD,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,MAAM;YACtB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;gBAChB,IAAI,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;gBACnE,OAAO;aACR;YAED,IAAI,cAAc,CAAC,IAAI,EAAE;gBACvB,MAAM,IAAA,wBAAU,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC5C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACpB,CAAC,CAAC,CAAC;aACJ;YAED,IAAI,cAAc,CAAC,YAAY,EAAE;gBAC/B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,2BAAa,EAC9C,cAAS,CAAC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,EAC9C,cAAc,CAAC,aAAa,EAC5B,MAAM,aAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CACvC,CAAC;gBAEF,IAAI,CAAC,cAAc,CAAC,aAAa,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;oBACtD,IAAI,CAAC,KAAK,CACR,6CAA6C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACjE,CAAC;iBACH;gBAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;oBACvB,IAAI,CAAC,IAAI,CACP,gFAAgF,QAAQ,CAAC,IAAI,CAC3F,IAAI,CACL,EAAE,CACJ,CAAC;iBACH;aACF;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAjED,wBAiEC","sourcesContent":["import {\n checkManifest,\n evalBundle,\n postProcessBundle,\n PostProcessOptions,\n} from '@metamask/snaps-utils';\nimport { promises as fs } from 'fs';\nimport pathUtils from 'path';\n// eslint-disable-next-line @typescript-eslint/no-shadow\nimport { Plugin, SourceMapInput } from 'rollup';\n\ntype PluginOptions = {\n eval?: boolean;\n manifestPath?: string;\n writeManifest?: boolean;\n};\n\nexport type Options = PluginOptions &\n Omit<PostProcessOptions, 'sourceMap' | 'inputSourceMap'>;\n\n/**\n * Creates a Snaps Rollup plugin instance.\n *\n * @param options - The plugin options.\n * @param options.stripComments - Whether to strip comments. Defaults to `true`.\n * @param options.eval - Whether to evaluate the bundle to test SES\n * compatibility. Defaults to `true`.\n * @param options.manifestPath - The path to the manifest file. If provided,\n * the manifest will be validated. Defaults to\n * `process.cwd() + '/snap.manifest.json'`.\n * @param options.writeManifest - Whether to fix the manifest. Defaults to\n * `true`.\n * @returns The Rollup plugin object.\n */\nexport default function snaps(options?: Partial<Options>): Plugin {\n const defaultOptions = {\n eval: true,\n manifestPath: pathUtils.join(process.cwd(), 'snap.manifest.json'),\n writeManifest: true,\n ...options,\n };\n\n return {\n name: '@metamask/snaps-rollup-plugin',\n\n renderChunk(code: string): { code: string; map?: SourceMapInput } | null {\n // Rollup internally merges the new source map with the old one, so there\n // is no need to pass the current source map to the function.\n const result = postProcessBundle(code, {\n ...defaultOptions,\n sourceMap: true,\n });\n\n if (result.warnings.length > 0) {\n this.warn(\n `Bundle Warning: Processing of the Snap bundle completed with warnings.\\n${result.warnings.join(\n '\\n',\n )}`,\n );\n }\n\n return { code: result.code, map: result.sourceMap };\n },\n\n async writeBundle(output): Promise<void> {\n if (!output.file) {\n this.warn('No output file specified, skipping bundle validation.');\n return;\n }\n\n if (defaultOptions.eval) {\n await evalBundle(output.file).catch((error) => {\n this.error(error);\n });\n }\n\n if (defaultOptions.manifestPath) {\n const { errors, warnings } = await checkManifest(\n pathUtils.dirname(defaultOptions.manifestPath),\n defaultOptions.writeManifest,\n await fs.readFile(output.file, 'utf8'),\n );\n\n if (!defaultOptions.writeManifest && errors.length > 0) {\n this.error(\n `Manifest Error: The manifest is invalid.\\n${errors.join('\\n')}`,\n );\n }\n\n if (warnings.length > 0) {\n this.warn(\n `Manifest Warning: Validation of snap.manifest.json completed with warnings.\\n${warnings.join(\n '\\n',\n )}`,\n );\n }\n }\n },\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-rollup-plugin",
3
- "version": "0.37.2-flask.1",
3
+ "version": "1.0.0",
4
4
  "keywords": [
5
5
  "rollup",
6
6
  "rollup-plugin"
@@ -9,49 +9,38 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/MetaMask/snaps.git"
11
11
  },
12
- "sideEffects": false,
13
- "main": "./dist/cjs/index.js",
14
- "module": "./dist/esm/index.js",
15
- "types": "./dist/types/index.d.ts",
12
+ "main": "dist/index.js",
16
13
  "files": [
17
- "dist/cjs/**",
18
- "dist/esm/**",
19
- "dist/types/**"
14
+ "dist/"
20
15
  ],
21
16
  "scripts": {
22
17
  "test": "jest && yarn posttest",
23
18
  "posttest": "jest-it-up",
24
19
  "test:ci": "yarn test",
25
- "lint:eslint": "eslint . --cache --ext js,ts,jsx,tsx",
26
- "lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" --ignore-path ../../.gitignore",
27
- "lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog",
20
+ "lint:eslint": "eslint . --cache --ext js,ts",
21
+ "lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",
22
+ "lint": "yarn lint:eslint && yarn lint:misc --check",
28
23
  "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
29
- "lint:changelog": "../../scripts/validate-changelog.sh @metamask/snaps-rollup-plugin",
30
- "build": "yarn build:source && yarn build:types",
31
- "build:source": "yarn build:esm && yarn build:cjs",
32
- "build:types": "tsc --project tsconfig.build.json",
33
- "build:esm": "swc src --out-dir dist/esm --config-file ../../.swcrc.build.json --config module.type=es6",
34
- "build:cjs": "swc src --out-dir dist/cjs --config-file ../../.swcrc.build.json --config module.type=commonjs",
24
+ "lint:changelog": "yarn auto-changelog validate",
25
+ "build:tsc": "tsc --project tsconfig.build.json",
26
+ "build": "yarn build:tsc",
35
27
  "build:clean": "yarn clean && yarn build",
36
- "clean": "rimraf '*.tsbuildinfo' 'dist'",
28
+ "clean": "rimraf '*.tsbuildinfo' 'dist/*'",
37
29
  "prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
38
30
  "publish:preview": "yarn npm publish --tag preview",
39
- "lint:ci": "yarn lint"
31
+ "publish:package": "../../scripts/publish-package.sh"
40
32
  },
41
33
  "dependencies": {
42
- "@metamask/snaps-utils": "^0.37.2-flask.1"
34
+ "@metamask/snaps-utils": "^1.0.0"
43
35
  },
44
36
  "devDependencies": {
45
- "@lavamoat/allow-scripts": "^2.3.1",
37
+ "@lavamoat/allow-scripts": "^2.0.3",
46
38
  "@metamask/auto-changelog": "^3.1.0",
47
- "@metamask/eslint-config": "^12.1.0",
48
- "@metamask/eslint-config-jest": "^12.1.0",
49
- "@metamask/eslint-config-nodejs": "^12.1.0",
50
- "@metamask/eslint-config-typescript": "^12.1.0",
39
+ "@metamask/eslint-config": "^11.0.0",
40
+ "@metamask/eslint-config-jest": "^11.0.0",
41
+ "@metamask/eslint-config-nodejs": "^11.0.1",
42
+ "@metamask/eslint-config-typescript": "^11.0.0",
51
43
  "@rollup/plugin-virtual": "^2.1.0",
52
- "@swc/cli": "^0.1.62",
53
- "@swc/core": "^1.3.66",
54
- "@swc/jest": "^0.2.26",
55
44
  "@types/jest": "^27.5.1",
56
45
  "@typescript-eslint/eslint-plugin": "^5.42.1",
57
46
  "@typescript-eslint/parser": "^5.42.1",
@@ -61,16 +50,16 @@
61
50
  "eslint-plugin-import": "^2.26.0",
62
51
  "eslint-plugin-jest": "^27.1.5",
63
52
  "eslint-plugin-jsdoc": "^39.6.2",
64
- "eslint-plugin-n": "^15.7.0",
53
+ "eslint-plugin-node": "^11.1.0",
65
54
  "eslint-plugin-prettier": "^4.2.1",
66
- "eslint-plugin-promise": "^6.1.1",
67
55
  "jest": "^29.0.2",
68
56
  "jest-it-up": "^2.0.0",
69
- "memfs": "^3.4.13",
57
+ "memfs": "^3.4.7",
70
58
  "prettier": "^2.7.1",
71
59
  "prettier-plugin-packagejson": "^2.2.11",
72
- "rimraf": "^4.1.2",
73
- "rollup": "^2.73.0",
60
+ "rimraf": "^3.0.2",
61
+ "rollup": "^2.72.1",
62
+ "ts-jest": "^29.0.0",
74
63
  "typescript": "~4.8.4"
75
64
  },
76
65
  "engines": {
package/dist/cjs/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return _plugin.default;
9
- }
10
- });
11
- const _plugin = /*#__PURE__*/ _interop_require_default(require("./plugin"));
12
- function _interop_require_default(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
15
- };
16
- }
17
-
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { default } from './plugin';\nexport type { Options } from './plugin';\n"],"names":["default"],"mappings":";;;;+BAASA;;;eAAAA,eAAO;;;+DAAQ"}
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, /**
6
- * Creates a Snaps Rollup plugin instance.
7
- *
8
- * @param options - The plugin options.
9
- * @param options.stripComments - Whether to strip comments. Defaults to `true`.
10
- * @param options.eval - Whether to evaluate the bundle to test SES
11
- * compatibility. Defaults to `true`.
12
- * @param options.manifestPath - The path to the manifest file. If provided,
13
- * the manifest will be validated. Defaults to
14
- * `process.cwd() + '/snap.manifest.json'`.
15
- * @param options.writeManifest - Whether to fix the manifest. Defaults to
16
- * `true`.
17
- * @returns The Rollup plugin object.
18
- */ "default", {
19
- enumerable: true,
20
- get: function() {
21
- return snaps;
22
- }
23
- });
24
- const _snapsutils = require("@metamask/snaps-utils");
25
- const _fs = require("fs");
26
- const _path = /*#__PURE__*/ _interop_require_default(require("path"));
27
- function _interop_require_default(obj) {
28
- return obj && obj.__esModule ? obj : {
29
- default: obj
30
- };
31
- }
32
- function snaps(options) {
33
- const defaultOptions = {
34
- eval: true,
35
- manifestPath: _path.default.join(process.cwd(), 'snap.manifest.json'),
36
- writeManifest: true,
37
- ...options
38
- };
39
- return {
40
- name: '@metamask/snaps-rollup-plugin',
41
- renderChunk (code) {
42
- // Rollup internally merges the new source map with the old one, so there
43
- // is no need to pass the current source map to the function.
44
- const result = (0, _snapsutils.postProcessBundle)(code, {
45
- ...defaultOptions,
46
- sourceMap: true
47
- });
48
- if (result.warnings.length > 0) {
49
- this.warn(`Bundle Warning: Processing of the Snap bundle completed with warnings.\n${result.warnings.join('\n')}`);
50
- }
51
- return {
52
- code: result.code,
53
- map: result.sourceMap
54
- };
55
- },
56
- async writeBundle (output) {
57
- if (!output.file) {
58
- this.warn('No output file specified, skipping bundle validation.');
59
- return;
60
- }
61
- if (defaultOptions.eval) {
62
- await (0, _snapsutils.evalBundle)(output.file).catch((error)=>{
63
- this.error(error);
64
- });
65
- }
66
- if (defaultOptions.manifestPath) {
67
- const { errors, warnings } = await (0, _snapsutils.checkManifest)(_path.default.dirname(defaultOptions.manifestPath), defaultOptions.writeManifest, await _fs.promises.readFile(output.file, 'utf8'));
68
- if (!defaultOptions.writeManifest && errors.length > 0) {
69
- this.error(`Manifest Error: The manifest is invalid.\n${errors.join('\n')}`);
70
- }
71
- if (warnings.length > 0) {
72
- this.warn(`Manifest Warning: Validation of snap.manifest.json completed with warnings.\n${warnings.join('\n')}`);
73
- }
74
- }
75
- }
76
- };
77
- }
78
-
79
- //# sourceMappingURL=plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/plugin.ts"],"sourcesContent":["import type { PostProcessOptions } from '@metamask/snaps-utils';\nimport {\n checkManifest,\n evalBundle,\n postProcessBundle,\n} from '@metamask/snaps-utils';\nimport { promises as fs } from 'fs';\nimport pathUtils from 'path';\n// eslint-disable-next-line @typescript-eslint/no-shadow\nimport type { Plugin, SourceMapInput } from 'rollup';\n\ntype PluginOptions = {\n eval?: boolean;\n manifestPath?: string;\n writeManifest?: boolean;\n};\n\nexport type Options = PluginOptions &\n Omit<PostProcessOptions, 'sourceMap' | 'inputSourceMap'>;\n\n/**\n * Creates a Snaps Rollup plugin instance.\n *\n * @param options - The plugin options.\n * @param options.stripComments - Whether to strip comments. Defaults to `true`.\n * @param options.eval - Whether to evaluate the bundle to test SES\n * compatibility. Defaults to `true`.\n * @param options.manifestPath - The path to the manifest file. If provided,\n * the manifest will be validated. Defaults to\n * `process.cwd() + '/snap.manifest.json'`.\n * @param options.writeManifest - Whether to fix the manifest. Defaults to\n * `true`.\n * @returns The Rollup plugin object.\n */\nexport default function snaps(options?: Partial<Options>): Plugin {\n const defaultOptions = {\n eval: true,\n manifestPath: pathUtils.join(process.cwd(), 'snap.manifest.json'),\n writeManifest: true,\n ...options,\n };\n\n return {\n name: '@metamask/snaps-rollup-plugin',\n\n renderChunk(code: string): { code: string; map?: SourceMapInput } | null {\n // Rollup internally merges the new source map with the old one, so there\n // is no need to pass the current source map to the function.\n const result = postProcessBundle(code, {\n ...defaultOptions,\n sourceMap: true,\n });\n\n if (result.warnings.length > 0) {\n this.warn(\n `Bundle Warning: Processing of the Snap bundle completed with warnings.\\n${result.warnings.join(\n '\\n',\n )}`,\n );\n }\n\n return { code: result.code, map: result.sourceMap };\n },\n\n async writeBundle(output): Promise<void> {\n if (!output.file) {\n this.warn('No output file specified, skipping bundle validation.');\n return;\n }\n\n if (defaultOptions.eval) {\n await evalBundle(output.file).catch((error) => {\n this.error(error);\n });\n }\n\n if (defaultOptions.manifestPath) {\n const { errors, warnings } = await checkManifest(\n pathUtils.dirname(defaultOptions.manifestPath),\n defaultOptions.writeManifest,\n await fs.readFile(output.file, 'utf8'),\n );\n\n if (!defaultOptions.writeManifest && errors.length > 0) {\n this.error(\n `Manifest Error: The manifest is invalid.\\n${errors.join('\\n')}`,\n );\n }\n\n if (warnings.length > 0) {\n this.warn(\n `Manifest Warning: Validation of snap.manifest.json completed with warnings.\\n${warnings.join(\n '\\n',\n )}`,\n );\n }\n }\n },\n };\n}\n"],"names":["snaps","options","defaultOptions","eval","manifestPath","pathUtils","join","process","cwd","writeManifest","name","renderChunk","code","result","postProcessBundle","sourceMap","warnings","length","warn","map","writeBundle","output","file","evalBundle","catch","error","errors","checkManifest","dirname","fs","readFile"],"mappings":";;;;+BAoB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CAA0C,EAAEC,OAAOpB,IAAI,CAAC,MAAM,CAAC;gBAEpE;gBAEA,IAAIU,SAASC,MAAM,GAAG,GAAG;oBACvB,IAAI,CAACC,IAAI,CACP,CAAC,6EAA6E,EAAEF,SAASV,IAAI,CAC3F,MACA,CAAC;gBAEP;YACF;QACF;IACF;AACF"}
package/dist/esm/index.js DELETED
@@ -1,3 +0,0 @@
1
- export { default } from './plugin';
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { default } from './plugin';\nexport type { Options } from './plugin';\n"],"names":["default"],"mappings":"AAAA,SAASA,OAAO,QAAQ,WAAW"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/plugin.ts"],"sourcesContent":["import type { PostProcessOptions } from '@metamask/snaps-utils';\nimport {\n checkManifest,\n evalBundle,\n postProcessBundle,\n} from '@metamask/snaps-utils';\nimport { promises as fs } from 'fs';\nimport pathUtils from 'path';\n// eslint-disable-next-line @typescript-eslint/no-shadow\nimport type { Plugin, SourceMapInput } from 'rollup';\n\ntype PluginOptions = {\n eval?: boolean;\n manifestPath?: string;\n writeManifest?: boolean;\n};\n\nexport type Options = PluginOptions &\n Omit<PostProcessOptions, 'sourceMap' | 'inputSourceMap'>;\n\n/**\n * Creates a Snaps Rollup plugin instance.\n *\n * @param options - The plugin options.\n * @param options.stripComments - Whether to strip comments. Defaults to `true`.\n * @param options.eval - Whether to evaluate the bundle to test SES\n * compatibility. Defaults to `true`.\n * @param options.manifestPath - The path to the manifest file. If provided,\n * the manifest will be validated. Defaults to\n * `process.cwd() + '/snap.manifest.json'`.\n * @param options.writeManifest - Whether to fix the manifest. Defaults to\n * `true`.\n * @returns The Rollup plugin object.\n */\nexport default function snaps(options?: Partial<Options>): Plugin {\n const defaultOptions = {\n eval: true,\n manifestPath: pathUtils.join(process.cwd(), 'snap.manifest.json'),\n writeManifest: true,\n ...options,\n };\n\n return {\n name: '@metamask/snaps-rollup-plugin',\n\n renderChunk(code: string): { code: string; map?: SourceMapInput } | null {\n // Rollup internally merges the new source map with the old one, so there\n // is no need to pass the current source map to the function.\n const result = postProcessBundle(code, {\n ...defaultOptions,\n sourceMap: true,\n });\n\n if (result.warnings.length > 0) {\n this.warn(\n `Bundle Warning: Processing of the Snap bundle completed with warnings.\\n${result.warnings.join(\n '\\n',\n )}`,\n );\n }\n\n return { code: result.code, map: result.sourceMap };\n },\n\n async writeBundle(output): Promise<void> {\n if (!output.file) {\n this.warn('No output file specified, skipping bundle validation.');\n return;\n }\n\n if (defaultOptions.eval) {\n await evalBundle(output.file).catch((error) => {\n this.error(error);\n });\n }\n\n if (defaultOptions.manifestPath) {\n const { errors, warnings } = await checkManifest(\n pathUtils.dirname(defaultOptions.manifestPath),\n defaultOptions.writeManifest,\n await fs.readFile(output.file, 'utf8'),\n );\n\n if (!defaultOptions.writeManifest && errors.length > 0) {\n this.error(\n `Manifest Error: The manifest is invalid.\\n${errors.join('\\n')}`,\n );\n }\n\n if (warnings.length > 0) {\n this.warn(\n `Manifest Warning: Validation of snap.manifest.json completed with warnings.\\n${warnings.join(\n '\\n',\n )}`,\n );\n }\n }\n },\n };\n}\n"],"names":["checkManifest","evalBundle","postProcessBundle","promises","fs","pathUtils","snaps","options","defaultOptions","eval","manifestPath","join","process","cwd","writeManifest","name","renderChunk","code","result","sourceMap","warnings","length","warn","map","writeBundle","output","file","catch","error","errors","dirname","readFile"],"mappings":"AACA,SACEA,aAAa,EACbC,UAAU,EACVC,iBAAiB,QACZ,wBAAwB;AAC/B,SAASC,YAAYC,EAAE,QAAQ,KAAK;AACpC,OAAOC,eAAe,OAAO;AAa7B;;;;;;;;;;;;;CAaC,GACD,eAAe,SAASC,MAAMC,OAA0B;IACtD,MAAMC,iBAAiB;QACrBC,MAAM;QACNC,cAAcL,UAAUM,IAAI,CAACC,QAAQC,GAAG,IAAI;QAC5CC,eAAe;QACf,GAAGP,OAAO;IACZ;IAEA,OAAO;QACLQ,M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