Skip to content

Commit

Permalink
working!
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Jan 31, 2023
1 parent a1534c4 commit 46eb9fd
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 64 deletions.
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import './src/env/browser';

export * as default from './fabric';
export * from './fabric';
2 changes: 1 addition & 1 deletion node.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import './src/env/node';

export * as default from './fabric';
export * from './fabric';
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"engines": {
"node": ">=14.0.0"
},
"module": "./dist/fabric.js",
"main": "./dist/fabric.umd.js",
"module": "./dist/fabric.mjs",
"main": "./dist/fabric.cjs",
"types": "./dist/fabric.d.ts"
}
87 changes: 36 additions & 51 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,77 @@ import json from '@rollup/plugin-json';
import terser from '@rollup/plugin-terser';
import ts from '@rollup/plugin-typescript';
import { babel } from '@rollup/plugin-babel';
import path from 'path';
// import dts from "rollup-plugin-dts";

const splitter = /\n|\s|,/g;

const outputFilePath = process.env.BUILD_OUTPUT || './dist/fabric.js';

const dirname = path.dirname(outputFilePath);
const basename = path.basename(outputFilePath, '.js');

const plugins = [
json(),
ts({
noForceEmit: true,
tsconfig: './tsconfig.json',
}),
babel({
extensions: ['.ts', '.js'],
babelHelpers: 'bundled',
}),
];

// https://rollupjs.org/guide/en/#configuration-files
export default [
{
input: process.env.BUILD_INPUT?.split(splitter) || ['./index.ts'],
output: [
{
file: process.env.BUILD_OUTPUT || './dist/fabric.umd.js',
file: path.resolve(dirname, `${basename}.mjs`),
name: 'fabric',
format: 'es',
sourcemap: true,
},
{
file: path.resolve(dirname, `${basename}.cjs`),
name: 'fabric',
format: 'umd',
sourcemap: true,
},
Number(process.env.MINIFY)
? {
file: process.env.BUILD_MIN_OUTPUT || './dist/fabric.umd.min.js',
file: path.resolve(dirname, `${basename}.min.js`),
name: 'fabric',
format: 'umd',
plugins: [terser()],
}
: null,
],
plugins: [
json(),
ts({
noForceEmit: true,
tsconfig: './tsconfig.json',
}),
babel({
extensions: ['.ts', '.js'],
babelHelpers: 'bundled',
}),
],
plugins,
},
{
input: process.env.BUILD_INPUT?.split(splitter) || ['./fabric.ts'],
input: ['./node.ts'],
output: [
{
file: process.env.BUILD_OUTPUT || './dist/fabric.js',
file: path.resolve(dirname, `${basename}.node.mjs`),
name: 'fabric',
format: 'es',
sourcemap: true,
},
],
plugins: [
json(),
ts({
noForceEmit: true,
tsconfig: './tsconfig.json',
}),
babel({
extensions: ['.ts', '.js'],
babelHelpers: 'bundled',
}),
],
},
{
input: ['./node.ts'],
output: [
{
file: './dist/fabric.node.js',
file: path.resolve(dirname, `${basename}.node.cjs`),
name: 'fabric',
format: 'umd',
format: 'cjs',
sourcemap: true,
},
Number(process.env.MINIFY)
? {
file: './dist/fabric.node.min.js',
name: 'fabric',
format: 'umd',
plugins: [terser()],
}
: null,
],
plugins: [
json(),
ts({
noForceEmit: true,
tsconfig: './tsconfig.json',
}),
babel({
extensions: ['.ts', '.js'],
babelHelpers: 'bundled',
}),
plugins,
external: [
'jsdom',
'jsdom/lib/jsdom/living/generated/utils',
'jsdom/lib/jsdom/utils',
],
},
];
7 changes: 0 additions & 7 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ export function build({ watch, fast, input, output, stats = false } = {}) {
MINIFY: Number(!fast),
BUILD_INPUT: Array.isArray(input) ? input.join(' ') : input,
BUILD_OUTPUT: output,
BUILD_MIN_OUTPUT:
output && !fast
? path.resolve(
path.dirname(output),
`${path.basename(output, '.js')}.min.js`
)
: undefined,
BUILD_STATS: Number(stats),
},
};
Expand Down
2 changes: 1 addition & 1 deletion test/node_test_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ QUnit.recreateVisualRefs = Number(process.env.QUNIT_RECREATE_VISUAL_REFS);
QUnit.config.filter = process.env.QUNIT_FILTER;


global.fabric = require('../dist/fabric.node');
global.fabric = require('../dist/fabric.node.cjs');
global.pixelmatch = require('pixelmatch');
global.fs = require('fs');
global.visualCallback = {
Expand Down
2 changes: 1 addition & 1 deletion test/testem.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module.exports = {
framework: 'qunit',
serve_files: [
'dist/fabric.umd.js',
'dist/fabric.cjs',
'test/lib/assert.js'
],
styles: [
Expand Down

0 comments on commit 46eb9fd

Please sign in to comment.