Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/6045-feat-directlinespeech-tsup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Changed

- Built `botframework-directlinespeech-sdk` with tsup only, replacing Babel and webpack, in PR [#6045](https://github.com/microsoft/BotFramework-WebChat/pull/6045), by [@OEvgeny](https://github.com/OEvgeny)

### Removed

- 💥 `botframework-directlinespeech-sdk` no longer ships Babel's `lib/` folder: deep imports from `lib/` stop working where `exports` is ignored (webpack 4), in PR [#6045](https://github.com/microsoft/BotFramework-WebChat/pull/6045), by [@OEvgeny](https://github.com/OEvgeny)
23 changes: 11 additions & 12 deletions docs/BUILD_SCRIPTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,19 @@ This section lists verification steps to validate the implementation against the
- No instrumentation code (smaller than test builds)
- Direct Line Speech SDK
- This is tested separately as Direct Line Speech SDK is designed not to live in our monorepo structure
- One `tsup` build produces every output in `dist/`
- `import` loads `botframework-directlinespeech-sdk.mjs`, `require()` loads `botframework-directlinespeech-sdk.js`, with types in `.d.mts` and `.d.ts`
- `<script>` loads `directlinespeech.development.js` or `directlinespeech.production.min.js`, which set `window.DirectLineSpeech`
- Development build
- Run `npm start` and wait until stabilized
- Verify only `dist/directlinespeech.development.js` is on disk and is about 4 MB in size
- Verify `dist/directlinespeech.development.js` is not minified and is about 1.3 MB in size
- Test build
- Set `node_env` to `test`
- Run `npm build` and wait until finished
- Verify `packages/directlinespeech/dist/directlinespeech.production.min.js` is built
- Minified
- Contains instrumentation code but no source maps
- Set `NODE_ENV` to `test`
- Run `npm run build` and wait until finished
- Verify `dist/directlinespeech.production.min.js` is minified and contains instrumentation code (about 580 KB)
- Run `npm test -- --ci --coverage false --maxWorkers=4 --no-watch`
- Verify code coverage is collected and correct (`directlinespeech.production.min.js` is about 500 KB)
- Verify code coverage is collected and correct
- Production build
- Set `node_env` to `production`
- Run `npm build` and wait until finished
- Verify both `dist/directlinespeech.development.js` and `dist/directlinespeech.production.min.js` are on disk
- `dist/directlinespeech.development.js` is about 3 MB
- `dist/directlinespeech.production.min.js` is about 400 KB
- Set `NODE_ENV` to `production`
- Run `npm run build` and wait until finished
- Verify `dist/directlinespeech.production.min.js` is minified and about 500 KB
39 changes: 3 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 9 additions & 18 deletions packages/directlinespeech/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"description": "Direct Line Speech SDK",
"files": [
"./dist/**/*",
"./lib/**/*",
"./src/**/*"
"./src/**/*",
"!dist/metafile-*.json",
"!src/**/*.spec.*",
"!src/**/__tests__/**"
],
"main": "./lib/index.js",
"main": "./dist/botframework-directlinespeech-sdk.js",
"types": "./dist/botframework-directlinespeech-sdk.d.ts",
"exports": {
".": {
Expand All @@ -17,7 +19,7 @@
},
"require": {
"types": "./dist/botframework-directlinespeech-sdk.d.ts",
"default": "./lib/index.js"
"default": "./dist/botframework-directlinespeech-sdk.js"
}
}
},
Expand All @@ -35,12 +37,7 @@
"build:pre": "npm run build:pre:local-dependencies && npm run build:pre:watch",
"build:pre:local-dependencies": "../../scripts/npm/build-local-dependencies.sh",
"build:pre:watch": "../../scripts/npm/build-watch.sh",
"build:run": "npm run build:run:tsup && npm run build:run:babel && npm run build:run:webpack",
"build:run:babel": "cross-env build_tool=babel module_format=commonjs babel src --ignore **/*.spec.js,**/*.test.js,__tests__/**/*.js --out-dir lib --verbose",
"build:run:tsup": "tsup",
"build:run:webpack": "npm run build:run:webpack:development && npm run build:run:webpack:production",
"build:run:webpack:development": "cross-env node_env=development webpack-cli",
"build:run:webpack:production": "cross-env node_env=production webpack-cli",
"build:run": "tsup",
"bump": "vg bump prod && vg bump dev && (npm audit fix || exit 0)",
"eslint": "npm run precommit",
"postversion": "../../scripts/npm/postversion.sh",
Expand Down Expand Up @@ -82,18 +79,17 @@
},
"localDependencies": {},
"devDependencies": {
"@babel/cli": "^7.29.7",
"@babel/core": "^7.29.7",
"@babel/plugin-transform-runtime": "^7.29.7",
"@babel/preset-env": "^7.29.7",
"@babel/runtime": "7.29.7",
"@testduet/given-when-then": "^0.1.0",
"@types/jest": "^29.5.14",
"@typescript-eslint/eslint-plugin": "^8.60.0",
"@typescript-eslint/parser": "^8.60.0",
"babel-jest": "^29.7.0",
"babel-plugin-istanbul": "^8.0.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"cross-env": "^10.1.0",
"dotenv": "^17.4.2",
"eslint": "^8.57.1",
"eslint-plugin-node": "^11.1.0",
Expand All @@ -104,14 +100,9 @@
"jest": "^29.7.0",
"prettier": "^3.8.3",
"simple-update-in": "^2.2.0",
"source-map-loader": "^5.0.0",
"tsd": "^0.33.0",
"webpack": "^5.107.2",
"webpack-cli": "^7.0.3",
"webpack-stats-plugin": "^1.1.3"
"tsd": "^0.33.0"
},
"dependencies": {
"@babel/runtime": "7.29.7",
"abort-controller": "3.0.0",
"base64-arraybuffer": "1.0.2",
"core-js": "3.49.0",
Expand Down
18 changes: 18 additions & 0 deletions packages/directlinespeech/src/__tests__/addMetaTag.iife.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @jest-environment @happy-dom/jest-environment */
/// <reference types="jest" />

beforeEach(() => {
delete window.DirectLineSpeech;
});

test.each([['directlinespeech.development.js'], ['directlinespeech.production.min.js']])(
'%s should set window.DirectLineSpeech with matching buildInfo',
filename => {
// Loaded as a module (inside a function), not as a classic <script>: only an explicit assignment reaches `window`.
jest.requireActual(`../../dist/${filename}`);

expect(Object.keys(window.DirectLineSpeech).sort()).toEqual(['buildInfo', 'createAdapters']);
expect(window.DirectLineSpeech.buildInfo).toHaveProperty('buildTool', 'tsup');
expect(window.DirectLineSpeech.buildInfo).toHaveProperty('moduleFormat', 'global');
}
);
4 changes: 4 additions & 0 deletions packages/directlinespeech/src/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Entry of the browser scripts: like the former webpack build (`libraryTarget: 'window'`), assigns `window.DirectLineSpeech`.
import * as DirectLineSpeech from './index';

window.DirectLineSpeech = DirectLineSpeech;
39 changes: 39 additions & 0 deletions packages/directlinespeech/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ const config = applyConfig(config => ({
noExternal: [...(config.noExternal ?? []), 'event-target-shim']
}));

// Browser scripts exposing `window.DirectLineSpeech`, with every dependency bundled.
const iifeConfig = {
...config,
dts: false,
format: 'iife',
outExtension() {
return { js: '.js' };
},
target: [...config.target, 'es2019']
} satisfies typeof config;

export default defineConfig([
{
...config,
Expand All @@ -39,5 +50,33 @@ export default defineConfig([
},
format: 'cjs',
target: [...config.target, 'es2019']
},
{
...iifeConfig,
entry: {
'directlinespeech.development': './src/bundle.js'
},
env: {
...iifeConfig.env,
module_format: 'global',
node_env: 'development',
NODE_ENV: 'development'
},
// Both browser scripts would write the same metafile-iife.json, keep the production one.
metafile: false,
minify: false
},
{
...iifeConfig,
entry: {
'directlinespeech.production.min': './src/bundle.js'
},
env: {
...iifeConfig.env,
module_format: 'global',
node_env: 'production',
NODE_ENV: 'production'
},
minify: true
}
]);
48 changes: 0 additions & 48 deletions packages/directlinespeech/webpack.config.js

This file was deleted.

Loading