mirror of
https://github.com/konvajs/konva.git
synced 2025-05-05 13:47:47 +08:00
migrate back to commonjs
This commit is contained in:
parent
9fd79e8642
commit
8e955f9dd5
@ -84,7 +84,7 @@ gulp.task(
|
|||||||
'build',
|
'build',
|
||||||
gulp.parallel([
|
gulp.parallel([
|
||||||
'update-version-lib',
|
'update-version-lib',
|
||||||
'update-version-cmj',
|
// 'update-version-cmj',
|
||||||
// 'update-version-es-to-cmj-index',
|
// 'update-version-es-to-cmj-index',
|
||||||
// 'update-version-es-to-cmj-node',
|
// 'update-version-es-to-cmj-node',
|
||||||
'pre-build',
|
'pre-build',
|
||||||
|
2
konva.js
2
konva.js
@ -8,7 +8,7 @@
|
|||||||
* Konva JavaScript Framework v8.4.3
|
* Konva JavaScript Framework v8.4.3
|
||||||
* http://konvajs.org/
|
* http://konvajs.org/
|
||||||
* Licensed under the MIT
|
* Licensed under the MIT
|
||||||
* Date: Wed Apr 05 2023
|
* Date: Thu Apr 13 2023
|
||||||
*
|
*
|
||||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||||
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
||||||
|
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "commonjs",
|
|
||||||
"main": "./index-node.js",
|
|
||||||
"browser": "./index.js",
|
|
||||||
"typings": "./index-types.d.ts"
|
|
||||||
}
|
|
49
package.json
49
package.json
@ -9,41 +9,12 @@
|
|||||||
"lib",
|
"lib",
|
||||||
"cmj"
|
"cmj"
|
||||||
],
|
],
|
||||||
"main": "./cmj/index-node.js",
|
"main": "./lib/index-node.js",
|
||||||
"browser": "./lib/index.js",
|
"browser": "./lib/index.js",
|
||||||
"typings": "./lib/index-types.d.ts",
|
"typings": "./lib/index-types.d.ts",
|
||||||
"type": "module",
|
|
||||||
"__ignore_exports": {
|
|
||||||
".": {
|
|
||||||
"node": {
|
|
||||||
"require": "./cmj/index-node.js",
|
|
||||||
"import": "./lib/index-node.js",
|
|
||||||
"default": "./lib/index-node.js"
|
|
||||||
},
|
|
||||||
"require": "./cmj/index.js",
|
|
||||||
"import": "./lib/index.js",
|
|
||||||
"default": "./lib/index.js"
|
|
||||||
},
|
|
||||||
"./cmj": {
|
|
||||||
"import": "./cmj/index.js",
|
|
||||||
"require": "./cmj/index-node.js",
|
|
||||||
"node": "./cmj/index-node.js",
|
|
||||||
"default": "./cmj/index.js"
|
|
||||||
},
|
|
||||||
"./cmj/*": {
|
|
||||||
"import": "./cmj/*.js",
|
|
||||||
"require": "./cmj/*.js",
|
|
||||||
"default": "./cmj/*.js"
|
|
||||||
},
|
|
||||||
"./lib/*": {
|
|
||||||
"import": "./cmj/*.js",
|
|
||||||
"require": "./cmj/*.js",
|
|
||||||
"default": "./cmj/*.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run test:watch",
|
"start": "npm run test:watch",
|
||||||
"compile": "npm run clean && npm run tsc && cp ./src/index-types.d.ts ./lib/index-types.d.ts && npm run rollup && cp ./package-cmj.json ./cmj/package.json && cp ./src/index-types.d.ts ./cmj/index-types.d.ts",
|
"compile": "npm run clean && npm run tsc && cp ./src/index-types.d.ts ./lib/index-types.d.ts && npm run rollup",
|
||||||
"build": "npm run compile && cp ./src/index-types.d.ts ./lib && gulp build && node ./rename-imports.mjs",
|
"build": "npm run compile && cp ./src/index-types.d.ts ./lib && gulp build && node ./rename-imports.mjs",
|
||||||
"test:import": "npm run build && node ./test/import-test.cjs &&node ./test/import-test.mjs",
|
"test:import": "npm run build && node ./test/import-test.cjs &&node ./test/import-test.mjs",
|
||||||
"test": "npm run test:browser && npm run test:node",
|
"test": "npm run test:browser && npm run test:node",
|
||||||
@ -51,7 +22,7 @@
|
|||||||
"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security",
|
"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security",
|
||||||
"test:node": "ts-mocha -p ./test/tsconfig.json test/unit/**/*.ts --exit && npm run test:import",
|
"test:node": "ts-mocha -p ./test/tsconfig.json test/unit/**/*.ts --exit && npm run test:import",
|
||||||
"test:watch": "rm -rf ./parcel-cache && parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html",
|
"test:watch": "rm -rf ./parcel-cache && parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html",
|
||||||
"tsc": "tsc --removeComments && tsc --build ./tsconfig-cmj.json",
|
"tsc": "tsc --removeComments",
|
||||||
"rollup": "rollup -c --bundleConfigAsCjs",
|
"rollup": "rollup -c --bundleConfigAsCjs",
|
||||||
"clean": "rm -rf ./lib && rm -rf ./types && rm -rf ./cmj && rm -rf ./test-build",
|
"clean": "rm -rf ./lib && rm -rf ./types && rm -rf ./cmj && rm -rf ./test-build",
|
||||||
"watch": "rollup -c -w",
|
"watch": "rollup -c -w",
|
||||||
@ -88,8 +59,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@parcel/transformer-image": "2.8.2",
|
"@parcel/transformer-image": "2.8.3",
|
||||||
"@size-limit/preset-big-lib": "^8.1.0",
|
"@size-limit/preset-big-lib": "^8.2.4",
|
||||||
"@types/mocha": "^10.0.1",
|
"@types/mocha": "^10.0.1",
|
||||||
"canvas": "^2.11.2",
|
"canvas": "^2.11.2",
|
||||||
"chai": "4.3.7",
|
"chai": "4.3.7",
|
||||||
@ -100,24 +71,24 @@
|
|||||||
"gulp-exec": "^5.0.0",
|
"gulp-exec": "^5.0.0",
|
||||||
"gulp-jsdoc3": "^3.0.0",
|
"gulp-jsdoc3": "^3.0.0",
|
||||||
"gulp-rename": "^2.0.0",
|
"gulp-rename": "^2.0.0",
|
||||||
"gulp-replace": "^1.1.3",
|
"gulp-replace": "^1.1.4",
|
||||||
"gulp-typescript": "^5.0.1",
|
"gulp-typescript": "^5.0.1",
|
||||||
"gulp-uglify": "^3.0.2",
|
"gulp-uglify": "^3.0.2",
|
||||||
"gulp-uglify-es": "^3.0.0",
|
"gulp-uglify-es": "^3.0.0",
|
||||||
"gulp-util": "^3.0.8",
|
"gulp-util": "^3.0.8",
|
||||||
"mocha": "10.2.0",
|
"mocha": "10.2.0",
|
||||||
"mocha-headless-chrome": "^4.0.0",
|
"mocha-headless-chrome": "^4.0.0",
|
||||||
"parcel": "2.8.2",
|
"parcel": "2.8.3",
|
||||||
"process": "^0.11.10",
|
"process": "^0.11.10",
|
||||||
"rollup": "^3.7.5",
|
"rollup": "^3.20.2",
|
||||||
"rollup-plugin-commonjs": "^10.1.0",
|
"rollup-plugin-commonjs": "^10.1.0",
|
||||||
"rollup-plugin-node-resolve": "^5.2.0",
|
"rollup-plugin-node-resolve": "^5.2.0",
|
||||||
"rollup-plugin-sourcemaps": "^0.6.3",
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||||
"rollup-plugin-typescript2": "^0.34.1",
|
"rollup-plugin-typescript2": "^0.34.1",
|
||||||
"size-limit": "^8.1.0",
|
"size-limit": "^8.2.4",
|
||||||
"ts-mocha": "^10.0.0",
|
"ts-mocha": "^10.0.0",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^4.9.4"
|
"typescript": "^5.0.4"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"canvas",
|
"canvas",
|
||||||
|
@ -33,3 +33,15 @@ files.then((filePaths) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const indexFiles = ['lib/index.js', 'lib/index-node.js', 'lib/Core.js'];
|
||||||
|
indexFiles.forEach((filepath) => {
|
||||||
|
fs.readFile(filepath, 'utf8', (err, text) => {
|
||||||
|
text = text.replace('exports.default =', 'module.exports =');
|
||||||
|
fs.writeFile(filepath, text, function (err) {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// import resolve from 'rollup-plugin-node-resolve';
|
// import resolve from 'rollup-plugin-node-resolve';
|
||||||
// import commonjs from 'rollup-plugin-commonjs';
|
import commonjs from 'rollup-plugin-commonjs';
|
||||||
import typescript from 'rollup-plugin-typescript2';
|
import typescript from 'rollup-plugin-typescript2';
|
||||||
|
|
||||||
const pkg = require('./package.json');
|
const pkg = require('./package.json');
|
||||||
@ -29,6 +29,11 @@ export default {
|
|||||||
useTsconfigDeclarationDir: true,
|
useTsconfigDeclarationDir: true,
|
||||||
abortOnError: false,
|
abortOnError: false,
|
||||||
removeComments: false,
|
removeComments: false,
|
||||||
|
tsconfigOverride: {
|
||||||
|
compilerOptions: {
|
||||||
|
module: 'ES2020',
|
||||||
|
},
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
// // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
|
// // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
|
||||||
// commonjs(),
|
// commonjs(),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// try to import only core
|
// try to import only core
|
||||||
const Konva = require('../cmj').default;
|
const Konva = require('../');
|
||||||
|
|
||||||
// just do a simple action
|
// just do a simple action
|
||||||
const stage = new Konva.Stage();
|
const stage = new Konva.Stage();
|
||||||
|
@ -5,23 +5,14 @@ function equal(val1, val2, message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try to import only core
|
// try to import only core
|
||||||
// import Konva from '../';
|
import Konva from '../lib/Core.js';
|
||||||
|
import { Rect } from '../lib/shapes/Rect.js';
|
||||||
|
import '../lib/index-node.js';
|
||||||
|
|
||||||
// // no external shapes
|
equal(Rect !== undefined, true, 'Rect is defined');
|
||||||
// // equal(Konva.Rect, undefined, 'no external shapes');
|
|
||||||
|
|
||||||
// import { Rect } from '../lib/shapes/Rect';
|
equal(Konva.Rect, Rect, 'Rect is injected');
|
||||||
|
|
||||||
// equal(Rect !== undefined, true, 'Rect is defined');
|
|
||||||
|
|
||||||
// equal(Konva.Rect, Rect, 'Rect is injected');
|
|
||||||
|
|
||||||
// import Konva2 from '../';
|
|
||||||
|
|
||||||
// equal(Konva2.Rect, Rect, 'Rect is injected');
|
|
||||||
|
|
||||||
// equal(Konva2, Konva, 'Same Konva');
|
|
||||||
|
|
||||||
// // just do a simple action
|
// // just do a simple action
|
||||||
// const stage = new Konva.Stage();
|
const stage = new Konva.Stage();
|
||||||
// stage.toDataURL();
|
stage.toDataURL();
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "cmj",
|
|
||||||
"module": "CommonJS",
|
|
||||||
"target": "ES2015",
|
|
||||||
"noEmitOnError": true,
|
|
||||||
"lib": ["ES2015", "dom"],
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"declaration": true,
|
|
||||||
"removeComments": true
|
|
||||||
},
|
|
||||||
"include": ["./src/**/*.ts"],
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"module": "ES2015",
|
"module": "CommonJS",
|
||||||
"target": "ES2015",
|
"target": "ES2015",
|
||||||
// "sourceMap": true,
|
// "sourceMap": true,
|
||||||
"noEmitOnError": true,
|
"noEmitOnError": true,
|
||||||
@ -9,8 +9,6 @@
|
|||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"removeComments": false
|
"removeComments": false
|
||||||
// "noImplicitAny": true,
|
|
||||||
// "strict": true
|
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*.ts"]
|
"include": ["./src/**/*.ts"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user