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"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/rrdom-nodejs.js",
|
||||
"main": "lib/rrdom-nodejs.cjs",
|
||||
"module": "es/rrdom-nodejs.js",
|
||||
"typings": "es",
|
||||
"files": [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||
module.exports = {
|
||||
export default {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "0.1.7",
|
||||
"homepage": "https://github.com/rrweb-io/rrweb/tree/main/packages/rrdom#readme",
|
||||
"license": "MIT",
|
||||
"main": "lib/rrdom.js",
|
||||
"main": "lib/rrdom.cjs",
|
||||
"module": "es/rrdom.js",
|
||||
"typings": "es",
|
||||
"unpkg": "dist/rrdom.js",
|
||||
@@ -13,6 +13,7 @@
|
||||
"es",
|
||||
"typings"
|
||||
],
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rrweb-io/rrweb.git"
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
"lint": "yarn eslint src/**/*.ts"
|
||||
},
|
||||
"description": "rrweb's replayer UI",
|
||||
"main": "lib/index.js",
|
||||
"main": "lib/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"unpkg": "dist/index.js",
|
||||
"files": [
|
||||
@@ -46,6 +46,7 @@
|
||||
"typings"
|
||||
],
|
||||
"typings": "typings/index.d.ts",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rrweb-io/rrweb.git"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||
module.exports = {
|
||||
export default {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/**.test.ts'],
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"prepublish": "npm run typings && npm run bundle",
|
||||
"lint": "yarn eslint src"
|
||||
},
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rrweb-io/rrweb.git"
|
||||
@@ -23,7 +24,7 @@
|
||||
"snapshot",
|
||||
"DOM"
|
||||
],
|
||||
"main": "lib/rrweb-snapshot.js",
|
||||
"main": "lib/rrweb-snapshot.cjs",
|
||||
"module": "es/rrweb-snapshot.js",
|
||||
"unpkg": "dist/rrweb-snapshot.js",
|
||||
"typings": "typings/index.d.ts",
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"keywords": [
|
||||
"rrweb"
|
||||
],
|
||||
"main": "lib/rrweb-all.js",
|
||||
"main": "lib/rrweb-all.cjs",
|
||||
"module": "es/rrweb/packages/rrweb/src/entries/all.js",
|
||||
"unpkg": "dist/rrweb.js",
|
||||
"sideEffects": false,
|
||||
|
||||
@@ -186,7 +186,7 @@ for (const c of baseConfigs) {
|
||||
output: [
|
||||
{
|
||||
format: 'cjs',
|
||||
file: c.pathFn('lib/rrweb.js'),
|
||||
file: c.pathFn('lib/rrweb.cjs'),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user