Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@jsenv/file-size-impact

jsenv585MIT14.3.15

Add files size impact into pull requests

readme

File size impact

npm package

@jsenv/file-size-impact analyses a pull request impact on specific files size. This analysis is posted in a comment of the pull request on GitHub.

  • Helps you to catch size impacts before merging pull requests
  • Can be configured to track compressed file size
  • Create group of files to create meaningful reports
  • Can be added to any automated process (GitHub workflow, Jenkins, ...)

Pull request comment

Screenshot + explanation on pull request comment.

legend of pull request comment

Text How to read it
"remaining files (+4.71%)" There is a group of files named "remaining files" and pull request has an overall impact of +4.71% on these files.
"21.6 kB (+4.11 kB / +23.55%)" The size after merge is 21.6 kB. Pull request adds 4.11 kB representing an increase of 23.55% of the size before merge.
"Unmodified (4)" Sum of files in that group that are not impacted by the pull request.
Total (5) Sum of files in that group.

Installation

The first thing you need is a script capable to generate a file size report.

npm install --save-dev @jsenv/file-size-impact

filesize.mjs_

import { generateFileSizeReport } from "@jsenv/file-size-impact";

export const fileSizeReport = await generateFileSizeReport({
  log: process.argv.includes("--log"),
  rootDirectoryUrl: new URL("./", import.meta.url),
  trackingConfig: {
    dist: {
      "./dist/**/*": true,
      "./dist/**/*.map": false,
    },
  },
});

At this stage, you could generate a file size report on your machine with the following command.

node ./file_size.mjs --log

Now it's time to configure a workflow to compare file size reports before and after merging a pull request.

GitHub workflow

.github/workflows/filesize_impact.yml_

# This is a GitHub workflow YAML file
# see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
#
# For every push on a pull request, it
# - starts a machine on ubuntu
# - clone the git repository
# - install node, install npm deps
# - Executes report_file_size_impact.mjs

name: file size impact

on: pull_request

jobs:
  file_size_impact:
    runs-on: ubuntu-latest
    name: file size impact
    steps:
      - name: Setup git
        uses: actions/checkout@v3
      - name: Setup node
        uses: actions/setup-node@v3
        with:
          node-version: "18.3.0"
      - name: Setup npm
        run: npm install
      - name: Report file size impact
        run: node ./report_file_size_impact.mjs
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

reportfile_size_impact.mjs_

/*
 * This file is executed by file_size_impact.yml GitHub workflow.
 * - it generates file size report before and after merging a pull request
 * - Then, it creates or updates a comment in the pull request
 * See https://github.com/jsenv/workflow/tree/main/packages/file-size-impact#how-it-works
 */

import {
  reportFileSizeImpactInGitHubPullRequest,
  readGitHubWorkflowEnv,
} from "@jsenv/file-size-impact";

await reportFileSizeImpactInGitHubPullRequest({
  ...readGitHubWorkflowEnv(),
  buildCommand: "npm run dist",
  fileSizeReportUrl: new URL("./file_size.mjs#fileSizeReport", import.meta.url),
});

Notes:

  • "#fileSizeReport" is the name of the export from filesize.mjs_.

Other tools

If you want to use an other tool than GitHub worflow to run the pull request comparison, like Jenkins, there is a few things to do:

  1. Replicate filesize_impact.yml_
  2. Adjust reportfile_size_impact.mjs_
  3. Create a GitHub token (required to post comment on GitHub)

1. Replicate filesize_impact.yml_

Your workflow must reproduce the state where your git repository has been cloned and you are currently on the pull request branch. Something like the commands below.

git init
git remote add origin $GITHUB_REPOSITORY_URL
git fetch --no-tags --prune origin $PULL_REQUEST_HEAD_REF
git checkout origin/$PULL_REQUEST_HEAD_REF
npm install
node ./report_file_size_impact.mjs

2. Adjust reportfile_size_impact.mjs_

When outside a GitHub workflow, you cannot use readGitHubWorkflowEnv(). It means you must pass several parameters to reportFileSizeImpactInGitHubPullRequest. The example below assume code is executed by Travis.

- import { reportFileSizeImpactInGitHubPullRequest, readGitHubWorkflowEnv } from "@jsenv/file-size-impact"
+ import { reportFileSizeImpactInGitHubPullRequest } from "@jsenv/file-size-impact"

reportFileSizeImpactInGitHubPullRequest({
- ...readGitHubWorkflowEnv(),
+ rootDirectoryUrl: process.env.TRAVIS_BUILD_DIR,
+ repositoryOwner: process.env.TRAVIS_REPO_SLUG.split("/")[0],
+ repositoryName: process.env.TRAVIS_REPO_SLUG.split("/")[1],
+ pullRequestNumber: process.env.TRAVIS_PULL_REQUEST,
+ githubToken: process.env.GITHUB_TOKEN, // see next step
  buildCommand: "npm run dist",
})

3. Create a GitHub token

The GitHub token is required to be able to post a commment in the pull request. You need to create a GitHub token with repo scope at https://github.com/settings/tokens/new. Finally you need to setup this environment variable. The exact way to do this is specific to the tools your are using.

How it works

In order to analyse the impact of a pull request on file size the following steps are executed:

  1. Checkout pull request base branch
  2. Execute an install command (npm install by default)
  3. Run a build command (nom build by default)
  4. Get a file size report (dynamic import of a js module exporting generateFileSizeReport)
  5. Merge pull request into its base
  6. Execute command to generate files again
  7. Get a second file size report
  8. Analyse differences between the two file size reports
  9. Post or update comment in the pull request

generateFileSizeReport

generateFileSizeReport is an async function scanning filesystem to compute a list of file sizes and return these infos into an object.

import { generateFileSizeReport, raw, gzip } from "@jsenv/file-size-impact";

const fileSizeReport = await generateFileSizeReport({
  rootDirectoryUrl: new URL("./", import.meta.url),
  trackingConfig: {
    dist: {
      "./dist/**/*.js": true,
    },
  },
  transformations: { raw, gzip },
});

trackingConfig

trackingConfig parameter is an object used to configure group of files you want to track. This parameter is optional with a default value exported in src/jsenv_tracking_config.js

trackingConfig keys are group names that will appear in the generated comment. trackingConfig values are objects associating a pattern to a value.

For example you can create two groups named "critical files" and "remaining files" like this:

import { generateFileSizeReport } from "@jsenv/file-size-impact";

await generateFileSizeReport({
  trackingConfig: {
    "critical files": {
      "./dist/main.js": true,
      "./dist/main.css": true,
    },
    "remaining files": {
      "./dist/**/*.js": true,
      "./dist/**/*.css": true,
      "./dist/main.js": false,
      "./dist/main.css": false,
    },
  },
});

screenshot of pull request comment where groups are highlighted

transformations

transformations parameter is an object used to transform files content before computing their size. This parameter is optional with a default tracking file size without transformation called raw.

You can use this parameter to track file size after gzip compression.

import {
  generateFileSizeReport,
  raw,
  gzip,
  brotli,
} from "@jsenv/file-size-impact";

await generateFileSizeReport({
  transformations: { raw, gzip, brotli },
});

screenshot of pull request comment with gzip and brotli

raw, gzip and brotli compression can be enabled this way.

It's also possible to control compression level.

import { generateFileSizeReport, raw, gzip } from "@jsenv/file-size-impact";

await generateFileSizeReport({
  transformations: {
    raw,
    gzip7: (buffer) => gzip(buffer, { level: 7 }),
    gzip9: (buffer) => gzip(buffer, { level: 9 }),
  },
});

Finally transformations can be used to add custom transformations.

import {
  generateFileSizeReport,
  raw,
  gzip,
  brotli,
} from "@jsenv/file-size-impact";

await generateFileSizeReport({
  transformations: {
    raw,
    trim: (buffer) => String(buffer).trim(),
  },
});

manifestConfig

manifestConfig parameter is an object used to configure the location of an optional manifest file. It is used to compare files with dynamic names. This parameter is optional with a default considering "dist/**/manifest.json" as manifest files.

This parameter reuses the shape of trackingConfig (associating pattern + value).

import { reportFileSizeImpactInGitHubPullRequest } from "@jsenv/file-size-impact";

await reportFileSizeImpactInGitHubPullRequest({
  manifestConfig: {
    "./dist/**/manifest.json": true,
  },
});

You can disable manifest files handling by passing null.

import { reportFileSizeImpactInGitHubPullRequest } from "@jsenv/file-size-impact";

await reportFileSizeImpactInGitHubPullRequest({
  manifestConfig: {
    "./dist/**/manifest.json": null,
  },
});

In that case manifest.json will be handled as a regular file.

reportFileSizeImpactInGitHubPullRequest

reportFileSizeImpactInGitHubPullRequest is an async function that will analyse a pull request file size impact and post a comment with the result of this analysis.

import {
  reportFileSizeImpactInGitHubPullRequest,
  raw,
} from "@jsenv/file-size-impact";

await reportFileSizeImpactInGitHubPullRequest({
  logLevel: "info",

  rootDirectoryUrl: "file:///directory",
  githubToken: "xxx",
  repositoryOwner: "jsenv",
  repositoryName: "file-size-impact",
  pullRequestNumber: 10,

  installCommand: "npm install",
  buildCommand: "npm run build",
  fileSizeReportUrl: new URL("./file_size.mjs#fileSizeReport", import.meta.url),
  filesOrdering: "size_impact",
});

logLevel

logLevel parameter controls verbosity of logs during the function execution. This parameter is optional with a default value of "info".

You likely don't need to modify this parameter except to get verbose logs using "debug". The list of available values for logLevel can be found on @jsenv/logger documentation.

rootDirectoryUrl

rootDirectoryUrl parameter is a string leading to your project root directory. This parameter is required.

installCommand

installCommand parameter is a string representing the command to run in order to install things just after a switching to a git branch. This parameter is optional with a default value of "npm install". You can pass null if you don't need to run an install command to run your project.

buildCommand

buildCommand parameter is a string representing the command to run in order to generate files. This parameter is optional with a default value of "npm run-script build". You can pass null if you don't need to run a build command before computing file sizes.

fileSizeReportUrl

fileSizeReportUrl is a string or an url parameter representing an url leading a module file. This file must export a fileSizeReport produced by generateFileSizeReport.

filesOrdering

filesOrdering parameter is a string used to decide the order of the files displayed in the comment. This parameter is optional with a default value of "size_impact".

filesOrdering Description
"size_impact" Files are ordered by size impact
"filesystem" Files are ordered as they appear on the filesystem

runLink parameter allow to put a link to the workflow run in the generated comment body. It is used to indicates where file size impact was runned.

screenshot of pull request comment where runlink is highlighted

This parameter is returned by readGitHubWorkflowEnv meaning it comes for free inside a GitHub workflow.

Inside an other workflow, you can pass your own runLink. As in the example below where it is assumed that script is runned by jenkins.

import { reportFileSizeImpactInGitHubPullRequest } from "@jsenv/file-size-impact";

await reportFileSizeImpactInGitHubPullRequest({
  runLink: {
    url: process.env.BUILD_URL,
    text: `${process.env.JOB_NAME}#${process.env.BUILD_ID}`,
  },
});

commitInGeneratedByInfo

commitInGeneratedByInfo parameter is a boolean controlling if a link to the commit where size impact was performed appears in the comment. This parameter is optional and enabled by default.

screenshot of pull request comment where link to commit is highlighted

readGitHubWorkflowEnv

readGitHubWorkflowEnv is a function meant to be runned inside a GitHub workflow. It returns an object meant to be forwarded to reportFileSizeImpactInGitHubPullRequest.

import {
  reportFileSizeImpactInGitHubPullRequest,
  readGitHubWorkflowEnv,
} from "@jsenv/file-size-impact";

const gitHubWorkflowEnv = readGitHubWorkflowEnv();

await reportFileSizeImpactInGitHubPullRequest({
  ...gitHubWorkflowEnv,
});

gitHubWorkflowEnv object looks like this:

const gitHubWorkflowEnv = {
  rootDirectoryUrl: "/home/runner/work/repository-name",
  githubToken: "xxx",
  repositoryOwner: "jsenv",
  repositoryName: "repository-name",
  pullRequestNumber: 10,
  runLink: {
    url: "https://github.com/jsenv/repository-name/actions/runs/34",
    text: "workflow-name#34",
  },
};

File with dynamic names

Manifest file allows to compare file with dynamic names. The content of a manifest file looks like this:

{
  "dist/file.js": "dist/file.4798774987w97er984798.js"
}

These files are generated by build tools. For example by webpack-manifest-plugin or rollup-plugin-output-manifest.

Read more in manifestConfig parameter

See also

Note about GitHub workflow paths

It would be more efficient to enable size impact workflow only if certain file changes (the one that could impact dist/ files). It could be done with on condition in a workflow.yml.

on:
  pull_request:
    paths:
      - "index.js"
      - "src/**"

But in practice humans will wonder why the workflow did not run and think something is wrong.

changelog

39.0.0

  • Move to import attributes, import assertions no longer supported

38.3.0

  • [fix] ensure updating importmap (inline or inside a file trigger autoreload)
  • [fix] ensure dev server ribbon script is properly injected after any importmap script
  • [fix] ensure importmap is properly applies for code inlined inside <script type="module">
  • [feat] ensure import.meta.hot.decline() results in a full page reload

38.2.1

  • Update dependencies

38.0.0

  • bundling and minification enabled by default during build
  • Improve and fix autoreload on inline content (like css in js)
  • Fix several cases where js module fallback was missing or superflous
  • Correct output for code shared between main document and worker(s)
  • Prevent double injection of side effect files into worker entry points

37.1.0

  • Fix autoreload during dev
  • Add urlInfo.contentLength

37.0.0

  • Update plugins API
    • context argument is dead (all hooks now called with a single argument)
    • context can be accessed either with urlInfo.context or reference.ownerUrlInfo.context
    • reference.parentUrl becomes reference.ownerUrlInfo.url
    • Add reference.urlInfo
    • All context.referenceUtils moved to urlInfo.dependencies
    • Add methods on urlInfo .cook, .cookDependencies, .getWithoutSearchParam, .isUsed
    • Add methods on reference .remove, .inline
    • Add reference.astInfo
    • Add urlInfo.referenceToOthersSet
    • Add urlInfo.referenceFromOthersSet
    • Add urlInfo.firstReference
    • Add urlInfo.contentFinalized
    • Add urlInfo.graph
    • Add graph.rootUrlInfo
    • Add lazy getters on urlInfo.contentAst and urlInfo.contentEtag
    • urlInfo.url now readonly and frozen
    • reference.url now readonly and frozen
    • reference.prev and reference.next always set early to be accessible inside resolveReference and redirectReference hooks
    • inlining always create a dedicated urlInfo
  • Update versioning during build
    • now done using placeholders (no need to recook to inject versions)
  • Ensure side effect file are properly injected into relevant entry points and only once
  • Rename param used to hot reload ?hot (was ?hmr)
  • Ensure assert keyword is entirely removed when import assertions are not supported
  • Fix sourcemaps generation during build
  • Properly update file written in outDirectoryUrl when url info content is modified after being cooked
  • Improve code injection for side effect file, versioning and service worker
  • Code injected into HTML files respects indentation to be readable

36.3.1

  • Introduce side effect files Side effect files are deduped in entry points when possible
  • Use side effect files to inject s.js, regeneratorRuntime and document.adoptedStylesheet
  • Introduce urlInfo.contentAst and urlInfo.originalContentAst
  • memoize context.isSupportedOnCurrentClients
  • More logs during build
  • Ensure version mappings injection do not break when injected in js module with static imports
  • Update deps

36.2.0

  • Change internal packages structure
  • Ensure document.adoptedStyleSheets, globalThis and regeneratorRuntime polyfill injection in js classic

36.1.2

  • Introduce @jsenv/js-module-fallback to remove direct dependency between @jsenv/core and @jsenv/plugin-as-js-classic

36.1.1

  • Better error traces when error happens in sourceMainFilePath

36.1.0

  • Introduce ignore param to build and startDevServer

36.0.2

  • Fix code preventing node esm resolution to be disabled
  • remove webResolution param, it's useless
  • preserve references sarting with #
  • Properly handle reference starting with ignore:

36.0.1

  • Remove jsenv internal position attributes from HTML during dev

36.0.0

  • Move dev server explorer to @jsenv/plugin-explorer
  • Rename several plugin hook like resolveUrl -> resolveReference
  • Rename urlAnalysis param into referenceAnalysis
  • Split urlResolution param into nodeEsmResolution and webResolution

35.0.4

  • Restore semicolons

35.0.3

  • Ensure explorer and sourceMainFilePath work as documented

35.0.1

  • Update dependencies

35.0.0

  • Introduce @jsenv/test and update how runtimes are configured

version 34.0

import { executeTestPlan, chromium } from "@jsenv/core";

await executeTestPlan({
  testPlan: {
    "**/*.test.html": {
      runtime: chromium,
      runtimeParams: { headful: true },
    },
  },
});

version 35.0

import { executeTestPlan, chromium } from "@jsenv/test";

await executeTestPlan({
  testPlan: {
    "**/*.test.html": {
      runtime: chromium({ headful: true }),
    },
  },
});

34.3.0

  • Add ability to inline file with "?inline" It can also be used to obtain js classic from js module with "?as_js_classic&inline"
  • Add importMap to Node.js runtimeParams (both child process and worker thread) Allow to redirect import to other files during tests (mocking)
  • Muliple --require= and --experimental-loader= passed to commandLineOptions are now preserved (Before the last one wins)
  • Prevent generating trailing comma on dynamic import during import assertion transpilation
  • Better indentation in html generated during dev and build
  • Internal dev experience improvements on file/directory snapshots

34.2.2

  • Update deps

34.2.0

  • "?as_js_classic" renamed "?js_module_fallback"
  • Introduce @jsenv/plugin-as-js-classic
    • Remove dependency between @jsenv/core and @jsenv/plugin-bundling

34.1.4

  • Fix resource hint warning when transpiling to systemjs

34.1.3

  • Fix error 500 when url not in url graph is modified

34.1.0

  • Update coverage behaviour
    • Instrument only _.js, _.jsx, _.ts, _.tsx
    • Move istanbul instrumentation from jsenv dev server to a playwright middleware
    • Make fallback on istanbul for coverage more explicit in the code
  • Remove first line break from logs during test execution

34.0.2

  • Update deps

34.0.0

  • Test execution becomes compatible with any web server
    • Remove devServerOrigin, devServerModuleUrl
    • Introduce webServer: { origin, rootDirectoryUrl, moduleUrl }
  • Exclude some files from test plan by default
    • File inside node modules
    • File inside directory starting with a dot (like ".git/")
  • Update test execution logs
    • Less line breaks when completedExecutionAbbreviation is enabled
    • Pad execution number with 0 like "execution 01 of 10" instead of "execution 1 of 10"
  • Add edge and firefox version supporting import.meta.resolve
  • Add safari version supporting import maps
  • Change how server are stopped after test plan is done

33.0.0

  • testDirectoryUrl -> rootDirectoryUrl

32.2.3

  • Ensure web worker urls type is correct during dev
    • This fix ensure node resolution also on self.importScripts
  • Give a better name to jsenv dist file ("jsenv.js" instead of "main.js")

32.2.0

  • Enable node esm resolution by default on self.importScripts

32.1.0

  • Allow filesystem magic resolution only while resolving js imports
  • outDirectoryUrl becomes optional
  • directoryReferenceAllowed param can now be a function
  • Improve error when directory is referenced
  • Fix error logged while handling existing sourcemap

32.0.0

  • Dev server is now designed to run on a directory containing only source files It's still possible to start dev server in a directory containing files that are not meant to be executed in the browser but this is no longer the recommended way to use it
  • Update startDevServer params
    • rootDirectoryUrl -> sourceDirectoryUrl
    • clientMainFileUrl -> sourceMainFilePath
  • Update build params
    • rootDirectoryUrl -> sourceDirectoryUrl
  • Update startBuildServer params
    • buildIndexPath -> buildMainFilePath
  • Update executeTestPlan params
    • rootDirectoryUrl -> testDirectoryUrl
    • Introduce devServerModuleUrl
  • executeTestPlan is now able to start dev server
  • executeTestPlan enforce testDirectoryUrl to be inside the sourceDirectoryUrl passed to dev server when tests are executed on browsers
  • Use node 19

31.2.0

  • Ensure webmanifest url is coherent during dev/build

31.1.2

  • Code can use __DEV__ and __BUILD__ to know if code is executed during dev or after build This is complementary to import.meta.dev/build for js_classic and workers
  • Fix urls not versioned when minification + vendors chunk is used
  • Fix crash on failed test execution
  • Params check on startBuildServer

31.0.0

  • Major update on dependencies
  • Update how to start dev server in https
  • More validation on public function params (type errors thrown on unexpected params)
  • "errored" execution status becomes "failed"

30.4.0

  • @jsenv/core
    • Dev server properly invalidate cache of files that are not watched
    • browser version now read from playwright after first run
    • Rename globals injected into service worker during build from serviceWorkerUrls to resourcesFromJsenvBuild
    • Fix dev server crach during url inference on circular dependency
    • Add cacheControl param to dev server (can be used to disable cache control headers on dev server)
  • @jsenv/pwa
    • Move into this monorepo
    • Split @jsenv/pwa into @jsenv/pwa + @jsenv/service-worker
    • Write automated tests around service worker and build
    • @jsenv/pwa full revamp of service worker part
  • @jsenv/eslint-import-resolver
    • improve logs when resolution fails
  • @jsenv/sigi
    • add this new package in the monorepo

30.3.9

  • Ensure build produce "\n" line breaks on windows by default

30.3.8

  • Prevent file path influence on variable names generated for systemjs during build. This issue was mitigate by minification but now it won't be a problem anymore, even with minification disabled.

30.3.7

  • Gracefully handle css syntax error inside <style>. Thanks to this dev server properly autoreload even when there is a syntax error in css within html.

30.3.6

  • Ensure inline content static analysis works in a corner case (transpilation to systemjs + minification without bundling)

30.3.3

  • Update deps

30.3.2

  • Preserve conditions in CSS imports
  • Update @jsenv/ast

30.3.0

30.2.0

  • Use lightningcss insteaf of postcss to bundle css

30.1.0

  • Replace "parcel/css" with "lightningcss"

30.0.7

  • Update dependencies

30.0.5

  • Update all dependencies

30.0.3

  • Properly handle file and directory containing url special characters (such as spaces)

30.0.0

  • Bundling moves to a plugin

    bundling param is gone, a plugin must be used instead as shown in code below.

    import { build} from "@jsenv/core"
    + import { jsenvPluginBundling } from "@jsenv/plugin-bundling"
    
    build({
    -  bundling: { js_module: true }
    +  plugins: [jsenvPluginBundling({ js_module: true })]
    })

    Bundling becomes opt-in enabling more modularity per project and ability to test other bundlers than rollup in the future.

  • Minification moves to a plugin

    minification param is gone, a plugin must be used instead as shown in code below.

    import { build} from "@jsenv/core"
    + import { jsenvPluginMinification } from "@jsenv/plugin-minification"
    
    build({
    -  minification: { js_module: true }
    +  plugins: [jsenvPluginMinification({ js_module: true })]
    })

    Minification becomes opt-in enabling more modularity per project and ability to test other minifiers in the future.

  • Small changes on buildFileContents and buildInlineContents returned by build

    • Keys are sorted
    • ?as_js_classic is removed from values when used

29.9.2

  • Update NPM dependencies

29.9.0

  • Add ability to resolve symlinks with urlResolution.node_esm
    startDevServer({
      urlResolution: {
        node_esm: {
          preservesSymlink: false,
        },
      },
    });
  • Preserve symlinks by default during node esm resolution
  • Ensure css and js is bundled when referenced by html itself referenced by js
  • Prepare things for @jsenv/plugin-toolbar

29.8.6

  • Update deps

29.8.5

  • Update deps

29.8.4

  • Update playwright (and ESLint)

29.8.3

  • Ensure ?js_classic applies on import.meta.resolve

29.8.2

  • Preserve search params during node esm resolution

29.8.1

  • Update deps

29.8.0

  • Support import.meta.resolve during dev and build
  • Add "?as_js_module" to be able to import js using top level this
  • Ignore plugin when plugin.init returns false

29.7.0

  • Export jsenvPluginPlaceholders

29.6.1

  • Fix error introduced in 29.6.0 on dev server

29.6.0

  • Propagate resource hint on files injected during build

29.5.0

  • build.baseUrl becomes build.base
  • introduce build.assetsDirectory
  • build.buildDirectoryClean renamed directoryToClean
  • fix new URL() usage for ?as_js_classic_library
  • enable ribbon by default during dev

29.4.4

  • fix url versioning during build

29.4.3

  • preserve crossorigin on preload links during build

29.4.2

  • Prevent versioning during dev on symlinked node modules

29.4.1

  • Ensure system.import always return a promise

29.4.0

  • build server sends "/index.html" when requested at "/" if file exists. This is configurable with buildIndexPath. When the file at buildIndexPath do not exists build server returns directory content.

29.3.2

  • Fix error when building multiple js classic library files

29.3.0

  • Add ribbon param to startDevServer

29.2.1

  • Update deps

29.2.0

  • Update rollup to 3.1.0

29.1.18

  • Do not throw when source code use new Blob() without argument

29.1.17

  • Pass (urlInfo, context) to jsenvPluginGlobals

29.1.16

  • Add "findDependent(urlInfo, callback)" to context.urlGraph

29.1.15

  • Update s.js to fix a bug on concurrent async execution

29.1.14

  • Same as previous on cache-control:no-cache

29.1.13

  • Do not send eTag when a plugin set cache-control:no-store

29.1.12

  • Fix a bug when node imports subpath resolution is involved

29.1.11

  • Gracefully handle syntax error occuring inside "as_js_classic_library"
  • Better handling of 404 inside "as_js_classic_library"

29.1.10

  • Prevent duplicate files when file referenced by new URL() + dynamic import

29.1.9

  • Fix new URL() update during js classic conversion
  • Properly handle unicode character during file url matching and logging

29.1.8

  • Fix dev server crashing when file is renamed
  • Fix s.js.map not found during dev
  • Ensure new URL() on js is updated too during js classic conversion
  • Preserve resource hints targeting js imported dynamically
  • Prefer injecting script after resource hints when possible

29.1.7

  • update playwright and other deps

29.1.5

  • fix parse error crashing dev server
  • fix node_esm applied for script type module in html

29.1.2

  • fix preact-debug injection
  • fix sourcemap resolution inside js modules

29.1.1

  • allow plugins to set error.asResponse to control server response for that error

29.1.0

  • log only one url for dev server when hostname is passed
  • urlResolution now applies on url type not reference type (js urls have node esm by default too)

29.0.1

  • update @jsenv/server to give more info on ERR_INVALID_CHAR

29.0.0

28.6.0

  • add clientMainFileUrl to startDevServer, can be used to send a custom html file instead of jsenv explorer.html
  • fix dev server crashing on some parsing errors
  • explorer.html is now cooked (goes through plugins pipe) like everything else

28.5.1

  • fix error when css contains @import

28.5.0

  • s.js is now injected inline in html

28.4.3

  • prevent error from supervisor when error.stack is undefined

28.4.2

  • prevent facade file during build by default, add bundling.js_modules.strictExports to configure that

28.4.1

  • fix 28.4.0 not updating @jsenv/ast

28.4.0

  • handle window.location in new URL() second arg

28.3.6

  • update dependencies

28.3.5

  • fix hotreload on preact/react when dev server is not in https (http)
  • reload and invalidate once for import assertions

28.3.4

  • fix autoreload when inline script changes in an html file using search params

28.3.3

  • updating files update all urls using search params too

28.3.2

  • ensure inline script are properly updated on reload
  • fix a warning logger by server on 304
  • fix a bug keeping sourcemap when marked as broken by preact/react refresh

28.3.1

  • prevent error when sourcemap is returned by a plugin for an html file
  • ensure content-length is overrided when plugin set custom response headers

28.3.0

  • Export "replacePlaceHolders"

28.2.3

  • Fix dist/s.js sourcemap comment

28.2.2

  • Fix as_js_classic_library build error when babel helpers are used

28.2.1

  • fix build using "?as_js_classic_library" in entry points
  • auto update "create-jsenv" when "@jsenv/core" version is updated

28.2.0

  • add "?as_js_classic_library" to consume js modules with a regular script tag
  • it is now possible to use the following query params in source files:
    • "?as_js_classic"
    • "?as_json_module"
    • "?as_css_module"
    • "?as_text_module"
    • "?as_js_classic_library"
  • Create a relationship with source file when a file is referenced with a query params from the list above (means hot reload and cache invalidation work as expect)
  • preserve preload links when css becomes js
  • update @jsenv/log to add logger.level
  • improve build debug logs
  • auto removal of preload link is now a "info" log instead of "warning" when it happens because file is bundled
  • use same transpilation levels between main thread and workers in case some code is shared
  • fix sourcemap source ENOENT on chrome
  • reference.searchParams is now available during "redirectUrl" hook
  • rework "as js classic" set of plugins to split how and when the query params are handled and the conversion is done

28.1.3

  • fix error handling when runtine.run throw

28.1.2

  • update how script execution is awaited by document supervisor

28.1.1

  • fix script execution order in html

28.1.0

  • htmlSupervisor renamed supervisor
  • allow multiple errors during execution
    • update how error are logged during tests
  • display error overlay on unhandled rejection
  • add logRefresh to executeTestPlan
  • add more stories in dev errors
  • update @jsenv/assert output
  • fix worker type module on firefox during dev
  • fix data url handling during dev
  • fix collectFiles in @jsenv/filesystem when path contains special chars
  • stop generating coverage for this repository (I am not using this anymore it's a waste of ressources to compute it)

28.0.2

  • prefer "ws.js" over "wrapper.js" when generating build files

28.0.1

  • prefer "resource" over "ressource" in names

28.0.0

  • tests now executed on the dev server
    • dev server must be started before executing tests
    • add new public export: "pingServer"
    • update test scripts in jsenv demos
  • rename "host" into "hostname" for startDevServer

27.8.1

  • fix websocket connection on https

27.8.0

  • update plugin.appliesDuring and context.scenarios
    • when appliesDuring is "dev" plugin applies during dev+test
    • when appliesDuring is {dev: true, test: false} plugins applies only during dev

27.7.0

  • use websocket to communicate between jsenv dev server and clients
  • update playwright

27.6.1

  • code frame show source code frame also in firefox/webkit for runtime errors
  • use sourcemap-js instead of source-map

27.6.0

  • add code frame in error overlay for fetch/parse/execute errors
  • generate error overlay screenshots for firefox and webkit too
  • fix cannot fetch file: on sourcemap in Firefox and webkit

27.5.3

  • use a more resilient logic to choose between browser and server error

27.5.2

  • display correct url:line:column for inline scripts
  • use snapshot to test dev server errors + screenshots
  • add code frame for runtime errors and syntax errors (error reported by browser)

27.5.1

  • add host to startDevServer

27.5.0

  • add htmlSupervisor.errorOverlay parameters
  • add "reported by browser/server ..." at the bottom of error overlay
  • close error overlay on hot reload
  • prevent server errors from displaying overlay on unrelated pages or once execution is done
  • fix hot reload for script using hot-accept attribute
  • handle type="text/jsx" and type="module/jsx" on script tags (same for ts)
  • add warnings when plugin contains unexpected properties
  • fix server host resolution for node 18+
  • add htmlSupervisor.openInEditor
  • css import assertion + hot reload works in firefox
  • fix infinite reloading when code using import assertion is executed at the same time in firefox and chrome
  • rename explorerGroups into explorer.groups (gives ability to disable explorer)
  • allow any preact/react version in peerDependencies
  • update dependencies

27.4.0

  • feature: click on error overlay now open in editor
  • feature: improve error trace for inline scripts and syntax errors
  • fix: use custom elements to render error overlay (prevent conflicts)
  • fix: ignore "file:///" when used as second argument in new URL

27.3.4

  • fix: invalidate HTML inline contents when it changes
  • fix: remove redundant abort error from test plan logs

27.3.3

  • coverageMethodForNodeJs default value becomes "Profiler"

27.3.2

  • Use "localhost" only if their is a mapping to 127.0.0.1 on the OS
  • Consume stdout before terminating node worker thread

27.3.0

27.2.0

  • Rename nodeProcess to nodeChildProcess
  • Add nodeWorkerThread
  • Rename executeTestPlan.coverage to executeTestPlan.coverageEnabled
  • When coverage is enabled, process.env.NODE_V8_COVERAGE must be set otherwise a warning is logged

27.1.0

27.0.3

  • Disable sourcemap for preact-refresh and react-refresh

27.0.0

Add CHANGELOG.md