{"_id":"@10xjs/polyfill-analyzer","_rev":"1-1cc364cb9b006e091c3cdbce186f7690","name":"@10xjs/polyfill-analyzer","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@10xjs/polyfill-analyzer","version":"0.1.0","description":"Analyze a javascript file to determine which polyfills are necessary to run it. Designed for use with financial-times/polyfill-library.","author":{"name":"Neal Granger","email":"neal@nealg.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/10xjs/polyfill-analyzer.git"},"bugs":{"url":"https://github.com/10xjs/polyfill-analyzer/issues"},"homepage":"https://github.com/10xjs/polyfill-analyzer#readme","main":"dist/analyze","types":"dist/analyze.d.ts","scripts":{"build":"tsc -p build.tsconfig.json","generate":"node -e \"require('polyfill-library').listAllPolyfills().then((list)=>fs.writeFileSync('./src/polyfills.ts','// GENERATED FILE. DO NOT EDIT.\\n// Exported from polyfill-library@'+require('polyfill-library/package.json').version+'\\nexport default '+JSON.stringify(list,0,2)+';'))\"","test:lint":"npx eslint . --ext ts","test:spec":"npx jest --runInBand --coverage=${SPEC_COVERAGE:-$CI}","test":"npm run test:lint --silent&& npm run test:spec --silent","prepublishOnly":"npm test && npm run build"},"devDependencies":{"@types/jest":"^25.1.4 ","@types/node":"^13.9.0","@typescript-eslint/eslint-plugin":"^2.22.0","@typescript-eslint/parser":"^2.22.0","eslint":"^6.8.0","eslint-plugin-prettier":"^3.1.2","jest":"^25.1.0","jest-circus":"^25.1.0","prettier":"^1.19.1","ts-jest":"^25.2.1"},"dependencies":{"ts-morph":"^7.0.0","typescript":"^3.8.3"},"jest":{"moduleNameMapper":{"^(/.*)$":"<rootDir>/src$1"},"testURL":"http://localhost/","testMatch":["<rootDir>/src/**/?(*.)test.ts"],"transform":{"^.+\\.tsx?$":"ts-jest"},"globals":{"ts-jest":{"diagnostics":false}}},"gitHead":"e12ad4a377c0d90f2f617974c03ce1297f0f9e51","_id":"@10xjs/polyfill-analyzer@0.1.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-YXat4YGDaC6gRjPv4lwQlwlPMptjb1CEpLmh7depqtW1gd716HCQ/2BsD/2f4u/IVh48JFzMPB5fUV2WeucUKA==","shasum":"4434412aa3d29acdbbe118917a27426a4f83030b","tarball":"https://registry.npmjs.org/@10xjs/polyfill-analyzer/-/polyfill-analyzer-0.1.0.tgz","fileCount":14,"unpackedSize":90918,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZruYCRA9TVsSAnZWagAAI5YP/RUC5+ZzK26UzciM1aGq\naWNT9ocG5jbu0YaXabHBY9GyOIQP+vdxYG8wBjM13Xte3S85fFKgDeKZGw2I\nK1s/2N1CpI7zMWkfpPMssEVVjnUaMpOFOcEZl5x8aPYk03vgzWY6ZKfwyEAC\nGAX5emwtgUFH0biKYN27ymLsl6l7PvB0YHvQwHR9bDCG1wMD5JrJNQsHpLFN\nQoarSYwiQwDK1p7uPmZOUJSDzDfsMypWSU/eTSRj9KkYYyc7p+eenc2Ya6al\nxBn+tPWcpxw0tuavGnvcXPWj6gnKYSBhNztj+FoICS+ogTfbYpNgfVhq1Nit\nWf6B+tYHrhBcoOid/d96Dg/VVXp7exXHR2XEZFpT0EnIVJxKMPUTDWV3ZNaK\nF+ZE7P10CbxyOq+2hl1g/j7cTlFqZUzaUQx3Hbeg10L17qNVzn32g/V5vFh2\njRkbvAd4vQgmlJIpjpJzkcfX/pXpk7sAUzn55b36WDHxKMkLYX3Cos1S2ZcD\ndMIxBIgepcec0RtTGXAMcebrWMIhVTuHE+8jlWovvLwLhK8bFX6+rp/c8vad\nCA3hNdDXjTRIkS0NN7L7Y/oD8XfW2uAI7kjedA7tVyM0iknV/qzoiw/j1b3i\newJvctMucAd/C4AkFv7WQXd5AV3c6VzvlsYrb0Z8NN5cOtr6G4zgVQkaxW9B\nTKah\r\n=Ir2i\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEz0UU9gHhSkg+1EhTVQBdPLzBrjyoMA9oTUdBSxDf3RAiAGcNWGmrmr9CeFeYCsxKFzBPzFcTTJj90WckYE1pfV6w=="}]},"maintainers":[{"name":"10xjs","email":"neal@nealg.com"}],"_npmUser":{"name":"10xjs","email":"neal@nealg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/polyfill-analyzer_0.1.0_1583790999674_0.5225331184294701"},"_hasShrinkwrap":false}},"time":{"created":"2020-03-09T21:56:39.441Z","0.1.0":"2020-03-09T21:56:39.797Z","modified":"2022-04-04T10:30:36.478Z"},"maintainers":[{"name":"10xjs","email":"neal@nealg.com"}],"description":"Analyze a javascript file to determine which polyfills are necessary to run it. Designed for use with financial-times/polyfill-library.","homepage":"https://github.com/10xjs/polyfill-analyzer#readme","repository":{"type":"git","url":"git+https://github.com/10xjs/polyfill-analyzer.git"},"author":{"name":"Neal Granger","email":"neal@nealg.com"},"bugs":{"url":"https://github.com/10xjs/polyfill-analyzer/issues"},"license":"MIT","readme":"# @10xjs/polyfill-analyzer\n\n> Analyze a javascript file to determine which polyfills are necessary to run it. Designed for use with [`polyfill-library`](https://github.com/Financial-Times/polyfill-library).\n\n## Usage\n\nPolyfill analyzer statically analyzes a string of javascript and returns an array of polyfill feature names compatible with with [`polyfill-library`](https://github.com/Financial-Times/polyfill-library).\n\n```js\nimport fs from 'fs';\nimport {analyze} from '@10xjs/polyfill-analyzer';\n\nconst features = analyze({\n  source: s.readFileSync('./bundle.js', 'utf-8'),\n  // `include` is a list of feature names to detect. Without a value provided,\n  // `analyze` will default to detecting all possible features (using\n  // `polyfillLibrary.listAllPolyfills()`). If you know your browser support \n  // target, `include` should be provided as the list of only the polyfills\n  // possibly needed for the targeted browsers.\n  include: [\n    'Symbol',\n    'Symbol.toStringTag',\n    'Symbol.iterator',\n    'Array.from',\n    'Object.entries',\n    'Array.prototype.findIndex',\n    'Object.keys',\n    'Object.getOwnPropertyDescriptor',\n    'Object.getOwnPropertyDescriptors',\n  ],\n  // Configure the behavior when an an entry in the `include` array is not a\n  // detectable polyfill. (Not all features listed by\n  // polyfillLibrary.listAllPolyfills()` can be detected.)\n  // Allowed values are \"ignore\", \"warn\", and \"error\";\n  unsupportedPolyfill: 'ignore',\n});\n\n// Returns an array of feature names which can be used to generate a custom\n// polyfill bundle using `polyfillLibrary.getPolyfillString()`.\n\n// [\n//   'Symbol',\n//   'Symbol.toStringTag',\n//   'Array.from',\n//   'Object.keys',\n//   'Object.getOwnPropertyDescriptor',\n//   'Object.getOwnPropertyDescriptors',\n// ]\n```\n\n## API\n\n### `analyze(options)`\nGet a list of polyfills necessary for running a string of javascript.\n\n- `@param {string} [options.source]` Javascript source code.\n- `@param {string[]} [options.include]` List of polyfills (from polyfill-library) to detect. Defaults to all detectable polyfills.\n- `@param {string[]} [options.exclude=[]]` List of polyfills to ignore. The exclude list has precedence over the include list.\n- `@param {\"ignore\"|\"warn\"|\"error\"} [options.unsupportedPolyfill=\"error\"]` Specify the behavior when an included unsupported polyfill is encountered in the `options.include` list.\n ","readmeFilename":"README.md"}