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
5 changes: 0 additions & 5 deletions .changeset/flat-hats-flow.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/young-seals-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/test-environment": minor
---

Switch to ESM package format by setting `"type": "module"`.
27 changes: 18 additions & 9 deletions packages/testing-library/test-environment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,31 @@
"name": "Yiming Li",
"email": "yimingli.cs@gmail.com"
},
"type": "module",
"exports": {
".": {
"default": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
},
"./env/vitest": {
"default": "./dist/env/vitest/index.mjs",
"types": "./dist/env/vitest/index.d.ts",
"import": "./dist/env/vitest/index.mjs",
"require": "./dist/env/vitest/index.js"
"import": "./dist/env/vitest/index.js",
"require": "./dist/env/vitest/index.cjs",
"default": "./dist/env/vitest/index.js"
}
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"env/vitest": [
"./dist/env/vitest/index.d.ts"
]
}
},
"files": [
"dist"
],
Expand All @@ -44,6 +52,7 @@
},
"devDependencies": {
"@testing-library/jest-dom": "^6.6.3",
"@types/jsdom": "^21.1.7"
"@types/jsdom": "^21.1.7",
"rsbuild-plugin-publint": "0.3.1"
}
}
4 changes: 4 additions & 0 deletions packages/testing-library/test-environment/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from '@rslib/core';
import { pluginPublint } from 'rsbuild-plugin-publint';

export default defineConfig({
source: {
Expand All @@ -22,4 +23,7 @@ export default defineConfig({
syntax: 'es2021',
},
],
plugins: [
pluginPublint(),
],
});
10 changes: 5 additions & 5 deletions packages/testing-library/test-environment/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import EventEmitter from 'events';
import { JSDOM } from 'jsdom';
import { createGlobalThis, LynxGlobalThis } from './lynx/GlobalThis';
import { initElementTree } from './lynx/ElementPAPI';
export { initElementTree } from './lynx/ElementPAPI';
export type { LynxElement } from './lynx/ElementPAPI';
export type { LynxGlobalThis } from './lynx/GlobalThis';
import { createGlobalThis, LynxGlobalThis } from './lynx/GlobalThis.js';
import { initElementTree } from './lynx/ElementPAPI.js';
export { initElementTree } from './lynx/ElementPAPI.js';
export type { LynxElement } from './lynx/ElementPAPI.js';
export type { LynxGlobalThis } from './lynx/GlobalThis.js';
/**
* @public
* The lynx element tree
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { define } from '../util';
import { define } from '../util.js';

function installOwnProperties(globalThis: any) {
define(globalThis, {
Expand Down
6 changes: 6 additions & 0 deletions packages/testing-library/test-environment/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"cache": false
},
"build": {
"dependsOn": [],
"inputs": [
"src/**",
"!src/**/__tests__/**",
"rslib.config.ts"
],
"outputs": ["dist/**"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import { RuntimeGlobals as LynxRuntimeGlobals } from '@lynx-js/webpack-runtime-g

import { createChunkLoadingRuntimeModule } from './ChunkLoadingRuntimeModule.js';
import { createCssChunkLoadingRuntimeModule } from './CssChunkLoadingRuntimeModule.js';
import { StartupChunkDependenciesPlugin } from './StartupChunkDependenciesPlugin.js';

import type { ChunkLoadingWebpackPluginOptions } from './index.js';

export class ChunkLoadingWebpackPluginImpl {
name = 'ChunkLoadingWebpackPlugin';
_asyncChunkLoading = true;

static chunkLoadingValue = 'lynx';

Expand All @@ -36,11 +34,6 @@ export class ChunkLoadingWebpackPluginImpl {
return;
}

new StartupChunkDependenciesPlugin({
chunkLoading: ChunkLoadingWebpackPluginImpl.chunkLoadingValue,
asyncChunkLoading: this._asyncChunkLoading,
}).apply(compiler);

// javascript chunk loading
compiler.hooks.thisCompilation.tap(this.name, (compilation) => {
const ChunkLoadingRuntimeModule = createChunkLoadingRuntimeModule(
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,3 @@ it('should work with chunk loading require', async function() {
expect(lynx.requireModuleAsync).toBeCalled();
});
});

it('should contain startup chunk dependencies code', async () => {
const bundlePath = path.join(
__dirname,
'rspack.bundle.js',
);
const content = await fs.promises.readFile(bundlePath, 'utf-8');
// why appears twice:
// 1. Injected by StartupChunkDependenciesPlugin
// 2. Existing in test case's own bundle
expect((content.match(/Lynx startup chunk dependencies/g) || []).length).toBe(
2,
);
});
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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