@metamask/snaps-rollup-plugin 0.35.0-flask.1 → 1.0.0-prerelease.1
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 +3 -25
- package/dist/__fixtures__/source-map.js +7 -0
- package/dist/__fixtures__/source-map.js.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/{esm/plugin.js → plugin.js} +21 -18
- package/dist/plugin.js.map +1 -0
- package/package.json +15 -53
- package/dist/cjs/index.js +0 -18
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/plugin.js +0 -79
- package/dist/cjs/plugin.js.map +0 -1
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/plugin.js.map +0 -1
- /package/dist/{types/__fixtures__ → __fixtures__}/source-map.d.ts +0 -0
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
- /package/dist/{types/plugin.d.ts → plugin.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,25 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
-
## [0.
|
|
10
|
-
### Changed
|
|
11
|
-
- **BREAKING:** Build packages as both CJS and ESM ([#1519](https://github.com/MetaMask/snaps/pull/1519), ([#1532](https://github.com/MetaMask/snaps/pull/1532)))
|
|
12
|
-
- This is breaking in the sense that imports to `dist/` will now require you to import either `dist/cjs` or `dist/esm`.
|
|
13
|
-
- Add `sideEffects: false` ([#1486](https://github.com/MetaMask/snaps/pull/1486))
|
|
14
|
-
|
|
15
|
-
## [0.34.1-flask.1]
|
|
16
|
-
### Changed
|
|
17
|
-
- No changes this release.
|
|
18
|
-
|
|
19
|
-
## [0.34.0-flask.1]
|
|
20
|
-
### Changed
|
|
21
|
-
- No changes this release.
|
|
22
|
-
|
|
23
|
-
## [0.33.1-flask.1]
|
|
24
|
-
### Changed
|
|
25
|
-
- No changes this release.
|
|
26
|
-
|
|
27
|
-
## [0.33.0-flask.1]
|
|
9
|
+
## [1.0.0-prerelease.1]
|
|
28
10
|
### Changed
|
|
29
11
|
- No changes this release.
|
|
30
12
|
|
|
@@ -156,12 +138,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
156
138
|
### Added
|
|
157
139
|
- Initial release ([#431](https://github.com/MetaMask/snaps-monorepo/pull/431))
|
|
158
140
|
|
|
159
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/
|
|
160
|
-
[0.
|
|
161
|
-
[0.34.1-flask.1]: https://github.com/MetaMask/snaps/compare/v0.34.0-flask.1...v0.34.1-flask.1
|
|
162
|
-
[0.34.0-flask.1]: https://github.com/MetaMask/snaps/compare/v0.33.1-flask.1...v0.34.0-flask.1
|
|
163
|
-
[0.33.1-flask.1]: https://github.com/MetaMask/snaps/compare/v0.33.0-flask.1...v0.33.1-flask.1
|
|
164
|
-
[0.33.0-flask.1]: https://github.com/MetaMask/snaps/compare/v0.32.2...v0.33.0-flask.1
|
|
141
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/v1.0.0-prerelease.1...HEAD
|
|
142
|
+
[1.0.0-prerelease.1]: https://github.com/MetaMask/snaps/compare/v0.32.2...v1.0.0-prerelease.1
|
|
165
143
|
[0.32.2]: https://github.com/MetaMask/snaps/compare/v0.32.1...v0.32.2
|
|
166
144
|
[0.32.1]: https://github.com/MetaMask/snaps/compare/v0.32.0...v0.32.1
|
|
167
145
|
[0.32.0]: https://github.com/MetaMask/snaps/compare/v0.31.0...v0.32.0
|
|
@@ -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,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
*/
|
|
22
|
+
*/
|
|
23
|
+
function snaps(options) {
|
|
18
24
|
const defaultOptions = {
|
|
19
25
|
eval: true,
|
|
20
|
-
manifestPath:
|
|
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
|
|
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
|
|
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(
|
|
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.
|
|
3
|
+
"version": "1.0.0-prerelease.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"rollup",
|
|
6
6
|
"rollup-plugin"
|
|
@@ -9,77 +9,38 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
11
11
|
},
|
|
12
|
-
"
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"import": "./dist/esm/index.js",
|
|
16
|
-
"require": "./dist/cjs/index.js",
|
|
17
|
-
"types": "./dist/types/index.d.ts"
|
|
18
|
-
},
|
|
19
|
-
"./dist/cjs/*": {
|
|
20
|
-
"require": "./dist/cjs/*.js",
|
|
21
|
-
"types": "./dist/types/*.d.ts"
|
|
22
|
-
},
|
|
23
|
-
"./dist/esm/*": {
|
|
24
|
-
"import": "./dist/esm/*.js",
|
|
25
|
-
"types": "./dist/types/*.d.ts"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"main": "./dist/cjs/index.js",
|
|
29
|
-
"module": "./dist/esm/index.js",
|
|
30
|
-
"types": "./dist/types/index.d.ts",
|
|
31
|
-
"typesVersions": {
|
|
32
|
-
"*": {
|
|
33
|
-
"*": [
|
|
34
|
-
"./dist/types/*"
|
|
35
|
-
],
|
|
36
|
-
"./dist/cjs/*": [
|
|
37
|
-
"./dist/types/*"
|
|
38
|
-
],
|
|
39
|
-
"./dist/esm/*": [
|
|
40
|
-
"./dist/types/*"
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
},
|
|
12
|
+
"main": "dist/index.js",
|
|
44
13
|
"files": [
|
|
45
|
-
"dist/
|
|
46
|
-
"dist/esm/**",
|
|
47
|
-
"dist/types/**"
|
|
14
|
+
"dist/"
|
|
48
15
|
],
|
|
49
16
|
"scripts": {
|
|
50
17
|
"test": "jest && yarn posttest",
|
|
51
18
|
"posttest": "jest-it-up",
|
|
52
19
|
"test:ci": "yarn test",
|
|
53
|
-
"lint:eslint": "eslint . --cache --ext js,ts
|
|
54
|
-
"lint:misc": "prettier
|
|
55
|
-
"lint": "yarn lint:eslint && yarn lint:misc --check
|
|
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",
|
|
56
23
|
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
|
|
57
24
|
"lint:changelog": "yarn auto-changelog validate",
|
|
58
|
-
"build": "
|
|
59
|
-
"build
|
|
60
|
-
"build:types": "tsc --project tsconfig.build.json",
|
|
61
|
-
"build:esm": "swc src --out-dir dist/esm --config-file ../../.swcrc.build.json --config module.type=es6",
|
|
62
|
-
"build:cjs": "swc src --out-dir dist/cjs --config-file ../../.swcrc.build.json --config module.type=commonjs",
|
|
25
|
+
"build:tsc": "tsc --project tsconfig.build.json",
|
|
26
|
+
"build": "yarn build:tsc",
|
|
63
27
|
"build:clean": "yarn clean && yarn build",
|
|
64
28
|
"clean": "rimraf '*.tsbuildinfo' 'dist/*'",
|
|
65
29
|
"prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
|
|
66
30
|
"publish:preview": "yarn npm publish --tag preview",
|
|
67
|
-
"
|
|
31
|
+
"publish:package": "../../scripts/publish-package.sh"
|
|
68
32
|
},
|
|
69
33
|
"dependencies": {
|
|
70
|
-
"@metamask/snaps-utils": "^0.
|
|
34
|
+
"@metamask/snaps-utils": "^1.0.0-prerelease.1"
|
|
71
35
|
},
|
|
72
36
|
"devDependencies": {
|
|
73
|
-
"@lavamoat/allow-scripts": "^2.3
|
|
37
|
+
"@lavamoat/allow-scripts": "^2.0.3",
|
|
74
38
|
"@metamask/auto-changelog": "^3.1.0",
|
|
75
39
|
"@metamask/eslint-config": "^11.0.0",
|
|
76
40
|
"@metamask/eslint-config-jest": "^11.0.0",
|
|
77
41
|
"@metamask/eslint-config-nodejs": "^11.0.1",
|
|
78
42
|
"@metamask/eslint-config-typescript": "^11.0.0",
|
|
79
43
|
"@rollup/plugin-virtual": "^2.1.0",
|
|
80
|
-
"@swc/cli": "^0.1.62",
|
|
81
|
-
"@swc/core": "^1.3.66",
|
|
82
|
-
"@swc/jest": "^0.2.26",
|
|
83
44
|
"@types/jest": "^27.5.1",
|
|
84
45
|
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
85
46
|
"@typescript-eslint/parser": "^5.42.1",
|
|
@@ -93,11 +54,12 @@
|
|
|
93
54
|
"eslint-plugin-prettier": "^4.2.1",
|
|
94
55
|
"jest": "^29.0.2",
|
|
95
56
|
"jest-it-up": "^2.0.0",
|
|
96
|
-
"memfs": "^3.4.
|
|
57
|
+
"memfs": "^3.4.7",
|
|
97
58
|
"prettier": "^2.7.1",
|
|
98
59
|
"prettier-plugin-packagejson": "^2.2.11",
|
|
99
|
-
"rimraf": "^
|
|
100
|
-
"rollup": "^2.
|
|
60
|
+
"rimraf": "^3.0.2",
|
|
61
|
+
"rollup": "^2.72.1",
|
|
62
|
+
"ts-jest": "^29.0.0",
|
|
101
63
|
"typescript": "~4.8.4"
|
|
102
64
|
},
|
|
103
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
|
package/dist/cjs/index.js.map
DELETED
|
@@ -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"}
|
package/dist/cjs/plugin.js
DELETED
|
@@ -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
|
package/dist/cjs/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin.ts"],"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"],"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":";;;;+BAoBA;;;;;;;;;;;;;CAaC,GACD;;;eAAwBA;;;4BA7BjB;oBACwB;6DACT;;;;;;AA2BP,SAASA,MAAMC,OAA0B;IACtD,MAAMC,iBAAiB;QACrBC,MAAM;QACNC,cAAcC,aAAS,CAACC,IAAI,CAACC,QAAQC,GAAG,IAAI;QAC5CC,eAAe;QACf,GAAGR,OAAO;IACZ;IAEA,OAAO;QACLS,MAAM;QAENC,aAAYC,IAAY;YACtB,yEAAyE;YACzE,6DAA6D;YAC7D,MAAMC,SAASC,IAAAA,6BAAiB,EAACF,MAAM;gBACrC,GAAGV,cAAc;gBACjBa,WAAW;YACb;YAEA,IAAIF,OAAOG,QAAQ,CAACC,MAAM,GAAG,GAAG;gBAC9B,IAAI,CAACC,IAAI,CACP,CAAC,wEAAwE,EAAEL,OAAOG,QAAQ,CAACV,IAAI,CAC7F,MACA,CAAC;YAEP;YAEA,OAAO;gBAAEM,MAAMC,OAAOD,IAAI;gBAAEO,KAAKN,OAAOE,SAAS;YAAC;QACpD;QAEA,MAAMK,aAAYC,MAAM;YACtB,IAAI,CAACA,OAAOC,IAAI,EAAE;gBAChB,IAAI,CAACJ,IAAI,CAAC;gBACV;YACF;YAEA,IAAIhB,eAAeC,IAAI,EAAE;gBACvB,MAAMoB,IAAAA,sBAAU,EAACF,OAAOC,IAAI,EAAEE,KAAK,CAAC,CAACC;oBACnC,IAAI,CAACA,KAAK,CAACA;gBACb;YACF;YAEA,IAAIvB,eAAeE,YAAY,EAAE;gBAC/B,MAAM,EAAEsB,MAAM,EAAEV,QAAQ,EAAE,GAAG,MAAMW,IAAAA,yBAAa,EAC9CtB,aAAS,CAACuB,OAAO,CAAC1B,eAAeE,YAAY,GAC7CF,eAAeO,aAAa,EAC5B,MAAMoB,YAAE,CAACC,QAAQ,CAACT,OAAOC,IAAI,EAAE;gBAGjC,IAAI,CAACpB,eAAeO,aAAa,IAAIiB,OAAOT,MAAM,GAAG,GAAG;oBACtD,IAAI,CAACQ,KAAK,CACR,CAAC,0CAA0C,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
package/dist/esm/index.js.map
DELETED
|
@@ -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"}
|
package/dist/esm/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin.ts"],"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"],"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":"AAAA,SACEA,aAAa,EACbC,UAAU,EACVC,iBAAiB,QAEZ,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,MAAM;QAENC,aAAYC,IAAY;YACtB,yEAAyE;YACzE,6DAA6D;YAC7D,MAAMC,SAAShB,kBAAkBe,MAAM;gBACrC,GAAGT,cAAc;gBACjBW,WAAW;YACb;YAEA,IAAID,OAAOE,QAAQ,CAACC,MAAM,GAAG,GAAG;gBAC9B,IAAI,CAACC,IAAI,CACP,CAAC,wEAAwE,EAAEJ,OAAOE,QAAQ,CAACT,IAAI,CAC7F,MACA,CAAC;YAEP;YAEA,OAAO;gBAAEM,MAAMC,OAAOD,IAAI;gBAAEM,KAAKL,OAAOC,SAAS;YAAC;QACpD;QAEA,MAAMK,aAAYC,MAAM;YACtB,IAAI,CAACA,OAAOC,IAAI,EAAE;gBAChB,IAAI,CAACJ,IAAI,CAAC;gBACV;YACF;YAEA,IAAId,eAAeC,IAAI,EAAE;gBACvB,MAAMR,WAAWwB,OAAOC,IAAI,EAAEC,KAAK,CAAC,CAACC;oBACnC,IAAI,CAACA,KAAK,CAACA;gBACb;YACF;YAEA,IAAIpB,eAAeE,YAAY,EAAE;gBAC/B,MAAM,EAAEmB,MAAM,EAAET,QAAQ,EAAE,GAAG,MAAMpB,cACjCK,UAAUyB,OAAO,CAACtB,eAAeE,YAAY,GAC7CF,eAAeM,aAAa,EAC5B,MAAMV,GAAG2B,QAAQ,CAACN,OAAOC,IAAI,EAAE;gBAGjC,IAAI,CAAClB,eAAeM,aAAa,IAAIe,OAAOR,MAAM,GAAG,GAAG;oBACtD,IAAI,CAACO,KAAK,CACR,CAAC,0CAA0C,EAAEC,OAAOlB,IAAI,CAAC,MAAM,CAAC;gBAEpE;gBAEA,IAAIS,SAASC,MAAM,GAAG,GAAG;oBACvB,IAAI,CAACC,IAAI,CACP,CAAC,6EAA6E,EAAEF,SAAST,IAAI,CAC3F,MACA,CAAC;gBAEP;YACF;QACF;IACF;AACF"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|