fix: module error (#1087)
* fix: module error refactor all suffix of bundled scripts with commonjs module from 'js' to cjs error: ReferenceError: exports is not defined in ES module scope This file is being treated as an ES module because it has a '.js' file extension and '.../rrweb/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension. * update jest config files
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
"rrdom-nodejs"
|
"rrdom-nodejs"
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/rrdom-nodejs.js",
|
"main": "lib/rrdom-nodejs.cjs",
|
||||||
"module": "es/rrdom-nodejs.js",
|
"module": "es/rrdom-nodejs.js",
|
||||||
"typings": "es",
|
"typings": "es",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||||
module.exports = {
|
export default {
|
||||||
preset: 'ts-jest',
|
preset: 'ts-jest',
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.1.7",
|
"version": "0.1.7",
|
||||||
"homepage": "https://github.com/rrweb-io/rrweb/tree/main/packages/rrdom#readme",
|
"homepage": "https://github.com/rrweb-io/rrweb/tree/main/packages/rrdom#readme",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/rrdom.js",
|
"main": "lib/rrdom.cjs",
|
||||||
"module": "es/rrdom.js",
|
"module": "es/rrdom.js",
|
||||||
"typings": "es",
|
"typings": "es",
|
||||||
"unpkg": "dist/rrdom.js",
|
"unpkg": "dist/rrdom.js",
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
"es",
|
"es",
|
||||||
"typings"
|
"typings"
|
||||||
],
|
],
|
||||||
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/rrweb-io/rrweb.git"
|
"url": "git+https://github.com/rrweb-io/rrweb.git"
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
"lint": "yarn eslint src/**/*.ts"
|
"lint": "yarn eslint src/**/*.ts"
|
||||||
},
|
},
|
||||||
"description": "rrweb's replayer UI",
|
"description": "rrweb's replayer UI",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.cjs",
|
||||||
"module": "dist/index.mjs",
|
"module": "dist/index.mjs",
|
||||||
"unpkg": "dist/index.js",
|
"unpkg": "dist/index.js",
|
||||||
"files": [
|
"files": [
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
"typings"
|
"typings"
|
||||||
],
|
],
|
||||||
"typings": "typings/index.d.ts",
|
"typings": "typings/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/rrweb-io/rrweb.git"
|
"url": "git+https://github.com/rrweb-io/rrweb.git"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||||
module.exports = {
|
export default {
|
||||||
preset: 'ts-jest',
|
preset: 'ts-jest',
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
testMatch: ['**/**.test.ts'],
|
testMatch: ['**/**.test.ts'],
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"prepublish": "npm run typings && npm run bundle",
|
"prepublish": "npm run typings && npm run bundle",
|
||||||
"lint": "yarn eslint src"
|
"lint": "yarn eslint src"
|
||||||
},
|
},
|
||||||
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/rrweb-io/rrweb.git"
|
"url": "git+https://github.com/rrweb-io/rrweb.git"
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
"snapshot",
|
"snapshot",
|
||||||
"DOM"
|
"DOM"
|
||||||
],
|
],
|
||||||
"main": "lib/rrweb-snapshot.js",
|
"main": "lib/rrweb-snapshot.cjs",
|
||||||
"module": "es/rrweb-snapshot.js",
|
"module": "es/rrweb-snapshot.js",
|
||||||
"unpkg": "dist/rrweb-snapshot.js",
|
"unpkg": "dist/rrweb-snapshot.js",
|
||||||
"typings": "typings/index.d.ts",
|
"typings": "typings/index.d.ts",
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"rrweb"
|
"rrweb"
|
||||||
],
|
],
|
||||||
"main": "lib/rrweb-all.js",
|
"main": "lib/rrweb-all.cjs",
|
||||||
"module": "es/rrweb/packages/rrweb/src/entries/all.js",
|
"module": "es/rrweb/packages/rrweb/src/entries/all.js",
|
||||||
"unpkg": "dist/rrweb.js",
|
"unpkg": "dist/rrweb.js",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ for (const c of baseConfigs) {
|
|||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
file: c.pathFn('lib/rrweb.js'),
|
file: c.pathFn('lib/rrweb.cjs'),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user