Have ideas to improve npm?Join in the discussion! »


    3.0.2 • Public • Published


    This project is meant to help assist you find resource files within parsed JavaScript. It currently has very limited support for syntactic structures where the resource files can be found. See the list below.

    It also allows some optional basic scanning of HTML for scripts, images, and stylesheets, and for CSS URLs.

    A main use case is to supply it to workbox-build so as to be able to build a service-worker which caches the files that your application fetches, etc.

    Presently supported AST for detection

    Because we wish to avoid grabbing strings which are not file resources, we need to whitelist the JavaScript structures where we can expect to find files (and we can't follow variables everywhere--literals are expected to be found at a predictable location).

    The intent is to expand this gradually as we find a need ourselves. PRs are welcome (with tests) for supporting other types of structures.

    You should just need to add a method to src/queries.js.

    • fetch (e.g., for polyglot usage, ala node-fetch) - Literals within an array directly supplied to a map call which returns the result of a fetch call:
    (async () => {
    await Promise.all([
    ].map((path) => {
      return fetch(path);


    npm i find-es-resources


    import {findESResources} from 'find-es-resources';
    (async () => {
    const arrayOfFileStrings = await findESResources({
      // File as a string path
      input: filePath,
      // See the `es-file-traverse` package:
      //  https://github.com/brettz9/es-file-traverse
      // Can be an empty object
      // Point to a CJS file exporting an object with string selectors as keys
      //   to functions which accept a node and return the string resources.
      queryOptions: {
        queryModule: moduleString
    // Module pointed to by `moduleString`:
    const queries = {
      'an > AST > Selector' (node) {
        return getResourceStringsOutOfNode(node);
      'another AST Selector' (node) {
        return getResourceStringsAlso(node);
    export default queries;

    CLI Usage


    See also


    The changelog can be found on CHANGES.md.

    Authors and license

    Brett Zamir and contributors.

    MIT License, see the included LICENSE-MIT.tx file.


    npm i find-es-resources

    DownloadsWeekly Downloads






    Unpacked Size

    28.3 kB

    Total Files


    Last publish


    • avatar