@metamask/snaps-rollup-plugin 0.36.0-flask.1 → 0.37.0-flask.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 +11 -1
- package/dist/cjs/plugin.js.map +1 -1
- package/dist/esm/plugin.js.map +1 -1
- package/dist/types/plugin.d.ts +2 -2
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.37.0-flask.1]
|
|
10
|
+
### Changed
|
|
11
|
+
- No changes this release.
|
|
12
|
+
|
|
13
|
+
## [0.36.1-flask.1]
|
|
14
|
+
### Changed
|
|
15
|
+
- No changes this release.
|
|
16
|
+
|
|
9
17
|
## [0.36.0-flask.1]
|
|
10
18
|
### Changed
|
|
11
19
|
- No changes this release.
|
|
@@ -168,7 +176,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
168
176
|
### Added
|
|
169
177
|
- Initial release ([#431](https://github.com/MetaMask/snaps-monorepo/pull/431))
|
|
170
178
|
|
|
171
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/v0.
|
|
179
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/v0.37.0-flask.1...HEAD
|
|
180
|
+
[0.37.0-flask.1]: https://github.com/MetaMask/snaps/compare/v0.36.1-flask.1...v0.37.0-flask.1
|
|
181
|
+
[0.36.1-flask.1]: https://github.com/MetaMask/snaps/compare/v0.36.0-flask.1...v0.36.1-flask.1
|
|
172
182
|
[0.36.0-flask.1]: https://github.com/MetaMask/snaps/compare/v0.35.2-flask.1...v0.36.0-flask.1
|
|
173
183
|
[0.35.2-flask.1]: https://github.com/MetaMask/snaps/compare/v0.35.1-flask.1...v0.35.2-flask.1
|
|
174
184
|
[0.35.1-flask.1]: https://github.com/MetaMask/snaps/compare/v0.35.0-flask.1...v0.35.1-flask.1
|
package/dist/cjs/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin.ts"],"sourcesContent":["import {\n checkManifest,\n evalBundle,\n postProcessBundle,\n
|
|
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":";;;;+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/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin.ts"],"sourcesContent":["import {\n checkManifest,\n evalBundle,\n postProcessBundle,\n
|
|
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,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"}
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PostProcessOptions } from '@metamask/snaps-utils';
|
|
2
|
-
import { Plugin } from 'rollup';
|
|
1
|
+
import type { PostProcessOptions } from '@metamask/snaps-utils';
|
|
2
|
+
import type { Plugin } from 'rollup';
|
|
3
3
|
declare type PluginOptions = {
|
|
4
4
|
eval?: boolean;
|
|
5
5
|
manifestPath?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-rollup-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0-flask.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"rollup",
|
|
6
6
|
"rollup-plugin"
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"lint:ci": "yarn lint"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@metamask/snaps-utils": "^0.
|
|
42
|
+
"@metamask/snaps-utils": "^0.37.0-flask.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@lavamoat/allow-scripts": "^2.3.1",
|
|
46
46
|
"@metamask/auto-changelog": "^3.1.0",
|
|
47
|
-
"@metamask/eslint-config": "^
|
|
48
|
-
"@metamask/eslint-config-jest": "^
|
|
49
|
-
"@metamask/eslint-config-nodejs": "^
|
|
50
|
-
"@metamask/eslint-config-typescript": "^
|
|
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",
|
|
51
51
|
"@rollup/plugin-virtual": "^2.1.0",
|
|
52
52
|
"@swc/cli": "^0.1.62",
|
|
53
53
|
"@swc/core": "^1.3.66",
|
|
@@ -61,8 +61,9 @@
|
|
|
61
61
|
"eslint-plugin-import": "^2.26.0",
|
|
62
62
|
"eslint-plugin-jest": "^27.1.5",
|
|
63
63
|
"eslint-plugin-jsdoc": "^39.6.2",
|
|
64
|
-
"eslint-plugin-
|
|
64
|
+
"eslint-plugin-n": "^15.7.0",
|
|
65
65
|
"eslint-plugin-prettier": "^4.2.1",
|
|
66
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
66
67
|
"jest": "^29.0.2",
|
|
67
68
|
"jest-it-up": "^2.0.0",
|
|
68
69
|
"memfs": "^3.4.13",
|