Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump dependencies #351

Merged
merged 8 commits into from Jul 29, 2021
Merged

Bump dependencies #351

merged 8 commits into from Jul 29, 2021

Conversation

compulim
Copy link
Collaborator

@compulim compulim commented Jul 28, 2021

Fixes #349.

Changelog

Changed

Notably changes

  • Production code change
  • Non-production code change
    • Updated to jest@27
      • Jest is using Node.js test environment by default, instead of JSDOM, need to explicitly say the target environment
        • Node.js test environment means, no window object
        • Jest updated to jsdom@16
      • jsdom doesn't support Web Crypto
        • Tests that touch uuid will fail because lack of Web Crypto
        • We wrote a simple polyfill for jsdom in __tests__/setup/setupCrypto.js
      • When running under jsdom, pre-flighted CORS (i.e. OPTIONS + GET/POST) will continue to need Access-Control-Allow-Origin on the GET/POST, even though it has it in the OPTIONS response
      • Updated jest.config.js to transform packages that explicitly use ESM
        • Jest doesn't support ESM, but some packages (e.g. p-defer) explicitly enforce ESM thru { "type": "module" } in their package.json
      • Jest console log too much and Travis CI is killing Jest because of huge log size
        • Added --silent option to suppress console log when running npm test
    • Moved from .babelrc.js to babel.config.json for modernization
    • Updated to webpack@5
      • Moved from webpack-visualizer-plugin to webpack-stats-plugin
      • process.env.VERSION is never used in production code, removing it from DefinePlugin

Tested environment

  • Unit tests via npm test
  • Integration tests via directline.js (bundle)
    • Direct Line Web Socket
      • Edge
      • IE11
    • Direct Line App Service Extension
      • Edge
      • IE11
  • Integration tests via tarball or npm link to Web Chat
    • Direct Line Web Socket
      • Edge
      • IE11
    • Direct Line App Service Extension
      • Edge
      • IE11

Integration tests consists of:

For other browsers, we rely on Web Chat to test them.

Additional context

Jest doesn't like ESM

When running Jest with ESM-enforcing packages, such as p-defer, default Jest configuration will fail because it tries to import as ESM while running as CommonJS.

In addition to userland code, we also need to transpile /node_modules/p-defer while Jest is running Babel on-the-fly. Thus, transformIgnorePatterns is updated to include p-defer, which is used in test code.

    Details:

    /home/compulim/repos/BotFramework-DirectLineJS/node_modules/p-defer/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export default function pDefer() {
                                                                                      ^^^^^^

    SyntaxError: Unexpected token 'export'

      2 |
      3 | import { createServer } from 'restify';
    > 4 | import createDeferred from 'p-defer';
        | ^
      5 | import getPort from 'get-port';
      6 |
      7 | export type PlaybackWithDeferred = {

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1479:14)
      at Object.<anonymous> (__tests__/setup/createServer.ts:4:1)

Transpiling on-the-fly

Both botframework-streaming and buffer package requires us to use babel-loader while bundling thru Webpack:

  • botframework-streaming
    • It bundled itself (i.e. package.json/browser point to a monolithic bundle)
    • The bundle contains uuid and is not ES5-friendly, due to the use of default argument
  • buffer
    • It contains code that is not ES5-friendly, due to the use of default argument

@compulim compulim marked this pull request as ready for review July 29, 2021 00:24
@compulim compulim merged commit 98e4586 into microsoft:master Jul 29, 2021
@compulim compulim deleted the bump-webpack branch July 29, 2021 17:46
@compulim compulim mentioned this pull request Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update cross-fetch dependency to remove vulnerabilities.
2 participants