Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed build, cleaned up rollup config, bump rollup-plugin-typescript2 version to fix … #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Node.js CI
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"tabWidth": 4,
"useTabs": false,
"arrowParens": "always",
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"bracketSpacing": true,
"quoteProps": "as-needed"
Expand Down
4 changes: 2 additions & 2 deletions examples/js/traviso.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/js/traviso.min.js.map

Large diffs are not rendered by default.

8,975 changes: 4,840 additions & 4,135 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"isometric",
"pixijs"
],
"main": "dist/cjs/traviso.js",
"main": "./dist/cjs/traviso.js",
"module": "dist/es/traviso.js",
"iife": "dist/browser/traviso.js",
"types": "types/index.d.ts",
Expand Down Expand Up @@ -53,7 +53,6 @@
"test:package": "pkg-ok",
"preversion": "npm-run-all clean build test"
},
"dependencies": {},
"peerDependencies": {
"pixi.js": "^6.0.4"
},
Expand All @@ -66,20 +65,20 @@
"@types/chai": "^4.2.18",
"@types/mocha": "^8.2.2",
"chai": "^4.3.4",
"cpy-cli": "^3.1.1",
"mocha": "^8.4.0",
"cpy-cli": "^4.2.0",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"pixi.js": "^6.0.4",
"pkg-ok": "^2.3.1",
"pkg-ok": "^3.0.0",
"prettier": "^2.3.0",
"rimraf": "^3.0.2",
"rollup": "^2.47.0",
"rollup-plugin-jscc": "^2.0.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"rollup-plugin-typescript2": "^0.34.1",
"ts-node": "^9.1.1",
"typedoc": "^0.20.36",
"typedoc": "^0.23.25",
"typescript": "^4.2.4"
}
}
106 changes: 10 additions & 96 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,52 @@ import resolve from '@rollup/plugin-node-resolve';
import pkg from './package.json';
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
// import typescript from '@rollup/plugin-typescript';
import typescript from 'rollup-plugin-typescript2';
// import { uglify } from 'rollup-plugin-uglify';
import { terser } from 'rollup-plugin-terser';
import jscc from 'rollup-plugin-jscc';

/**
* Get the JSCC plugin for preprocessing code.
* @param {boolean} debug Build is for debugging
*/
function preprocessPlugin() {
return jscc({
values: {
// _DEBUG: debug,
// _PROD: !debug,
_VERSION: pkg.version,
},
});
}

const extensions = ['.ts', '.tsx'];

const globals = {
'pixi.js': 'PIXI',
};

const external = Object.keys(globals);

const plugins = [
preprocessPlugin(),
peerDepsExternal(),

resolve({
extensions,
preferBuiltins: false,
}),
// typescript({
// tsconfig: 'tsconfig.build.json'
// }),
// commonjs(),

typescript({
useTsconfigDeclarationDir: true,
tsconfigOverride: {
compilerOptions: {
// exclude: ['**/*.stories.*'],
noEmit: true,
declaration: true,
emitDeclarationOnly: false,
},
include: ['src'],
},
}),
// typescript({
// tsconfig: './tsconfig.json',
// declaration: false,
// noEmit: true,
// }),

commonjs({
exclude: 'node_modules',
ignoreGlobal: true,
}),

babel({
exclude: 'node_modules/**',
extensions,
Expand All @@ -69,18 +58,13 @@ const plugins = [
'@babel/preset-env',
// '@babel/preset-typescript'
],

minified: false,
}),
// uglify({
// sourcemap: {
// filename: "out.js",
// url: "out.js.map"
// }
// }),
// terser(),
];

const compiledDate = new Date().toUTCString().replace(/GMT/g, 'UTC');

const banner = [
`/*!`,
` * ${pkg.name} - v${pkg.version}`,
Expand All @@ -93,24 +77,15 @@ const banner = [
` * http://www.opensource.org/licenses/mit-license`,
` */`,
].join('\n');
// const comments = (node, comment) => {
// var text = comment.value;
// var type = comment.type;
// if (type == 'comment2') {
// // multiline comment
// return /@preserve|@license|@cc_on/i.test(text);
// }
// };

const comments = (node, comment) => comment.line === 1;

export default [
// iife, cjs, es
{
input: 'src/index.ts',
external,
output: [
{
// dir: 'dist',
file: pkg.iife,
format: 'iife',
globals,
Expand All @@ -126,16 +101,13 @@ export default [
banner,
},
{
// dir: 'dist',
file: pkg.module,
format: 'es',
globals,
sourcemap: true,
banner,
},
// minify/uglify phase
{
// dir: 'dist',
file: 'dist/browser/traviso.min.js',
format: 'iife',
globals,
Expand All @@ -153,62 +125,4 @@ export default [
],
plugins,
},
// // minify/uglify phase
// {
// input: 'src/index.ts',
// output: {
// file: 'dist/browser/traviso.min.js',
// format: 'iife',
// sourcemap: true,
// // globals,
// // banner,
// name: 'TRAVISO',
// },
// plugins: [
// peerDepsExternal(),
// resolve({
// extensions,
// preferBuiltins: false,
// }),
// terser({
// // // output: { comments },
// // // mangle: {
// // // reserved: ['TRAVISO'],
// // // toplevel: false,
// // // properties: {
// // // reserved: ['TRAVISO']
// // // },
// // // },
// // toplevel: true,
// // mangle: false,
// output: {
// comments: false,
// // beautify: true,
// },
// }),
// ],
// },
// // ts
// {
// input: 'src/index.ts',
// output: {
// dir: 'dist',
// // file: 'dist/index.js',
// // format: 'iife',
// sourcemap: false,
// },
// plugins: [
// typescript({
// useTsconfigDeclarationDir: true,
// tsconfigOverride: {
// compilerOptions: {
// // exclude: ['**/*.stories.*'],
// noEmit: true,
// declaration: true,
// emitDeclarationOnly: true,
// }
// },
// }),
// ],
// },
];
32 changes: 0 additions & 32 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,61 +1,29 @@
{
"compilerOptions": {
// This defines the version of JavaScript to compile the TypeScript code to.
// Setting "esnext" allows you to play with all the latest features, but if
// you need greater compatibility with older browsers, you can set this to another option.
"target": "es5",

// You should set this option to "commonjs" to make sure everybody can use your package,
// whether they’re using TypeScript or JavaScript, are targeting Node.js or the Web.
"module": "ES2015",

// Activate strict compiler checks.
"strict": true,

// Do not compile when there are unused variables or imports.
"noUnusedLocals": true,

"noImplicitAny": true,
"noUnusedParameters": false,
"noImplicitReturns": true,
"strictNullChecks": false,

// Let TypeScript transpile JSX. Setting this can save you from setting up Babel.
// You can read more at https://www.typescriptlang.org/docs/handbook/jsx.html#basic-usage
"jsx": "react",

// Allow TypeScript to import JSON files directly.
"resolveJsonModule": true,

"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"esModuleInterop": true,

// Remove comments from generated JavaScript code.
"removeComments": false,

// "outDir": "./dist",
// "rootDir": "./src",

// Generate a source map from JS to TS. Useful for debugging.
// Don't forget to blacklist ./dist/**/*.js.map in the "files" key of package.json
"sourceMap": true,

// Generate a .d.ts file, for TypeScript users.
"declaration": true,
"declarationMap": false,
"declarationDir": "types",

// Do not emit output files. Prevents us from accidentally building with this file
// instead of tsconfig.build.json.
"noEmit": true,

"baseUrl": "./",
"paths": {
"mini-signals": ["node_modules/resource-loader/typings/mini-signals.d.ts"]
}
},
// Include all TypeScript files, including those that shouldn't be built.
"include": ["src", "benchmark"],
"exclude": ["dist", "types", "docs", "**/node_modules", "**/rollup.config.js"],
"ts-node": {
Expand Down