Skip to content

Commit

Permalink
fix: module error (#1087)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
YunFeng0817 authored Jan 10, 2023
1 parent 55cc1b3 commit fe69bd6
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/rrdom-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion packages/rrdom/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
export default {
preset: 'ts-jest',
testEnvironment: 'node',
};
3 changes: 2 additions & 1 deletion packages/rrdom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -13,6 +13,7 @@
"es",
"typings"
],
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/rrweb-io/rrweb.git"
Expand Down
3 changes: 2 additions & 1 deletion packages/rrweb-player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -46,6 +46,7 @@
"typings"
],
"typings": "typings/index.d.ts",
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/rrweb-io/rrweb.git"
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb-snapshot/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
export default {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/**.test.ts'],
Expand Down
3 changes: 2 additions & 1 deletion packages/rrweb-snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ for (const c of baseConfigs) {
output: [
{
format: 'cjs',
file: c.pathFn('lib/rrweb.js'),
file: c.pathFn('lib/rrweb.cjs'),
},
],
});
Expand Down

0 comments on commit fe69bd6

Please sign in to comment.