Skip to content

Commit

Permalink
netteForms: restructured package, includes UMD and ESM (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 5, 2024
1 parent f19d9e6 commit 9bbbbb9
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 17 deletions.
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default [
{
ignores: [
'*/', '!src/', '!tests/',
'**/netteForms*.*',
'**/dist/',
],
},

Expand Down
41 changes: 34 additions & 7 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ function spaces2tabs() {


export default [
{
{ // TODO: consider the possibility of cutting off the UMD versions completely due to collision
input: 'src/assets/index.umd.ts',
output: [
{
format: 'umd',
name: 'Nette',
dir: 'src/assets',
entryFileNames: 'netteForms.js',
dir: 'src/assets/dist',
entryFileNames: 'nette-forms.umd.js',
generatedCode: 'es2015',
},
{
format: 'umd',
name: 'Nette',
dir: 'src/assets',
entryFileNames: 'netteForms.min.js',
dir: 'src/assets/dist',
entryFileNames: 'nette-forms.umd.min.js',
generatedCode: 'es2015',
plugins: [
terser(),
Expand All @@ -65,9 +65,36 @@ export default [
},

{
input: 'src/assets/index.umd.ts',
input: 'src/assets/index.esm.ts',
output: [
{
format: 'es',
dir: 'src/assets/dist',
entryFileNames: 'nette-forms.esm.js',
generatedCode: 'es2015',
},
{
format: 'es',
dir: 'src/assets/dist',
entryFileNames: 'nette-forms.esm.min.js',
generatedCode: 'es2015',
plugins: [
terser(),
],
},
],
plugins: [
json(),
nodeResolve(),
typescript(),
spaces2tabs(),
],
},

{
input: 'src/assets/index.esm.ts',
output: [{
file: 'src/assets/netteForms.d.ts',
file: 'src/assets/dist/nette-forms.d.ts',
format: 'es',
}],
plugins: [
Expand Down
12 changes: 5 additions & 7 deletions src/assets/package.json → src/assets/dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nette-forms",
"version": "3.5.0",
"version": "4.0.0",
"description": "Client side script for Nette Forms Component",
"keywords": [
"nette",
Expand All @@ -10,12 +10,10 @@
"homepage": "https://nette.org",
"author": "David Grudl (https://davidgrudl.com)",
"license": "BSD-3-Clause",
"main": "src/assets/netteForms.js",
"types": "src/assets/netteForms.d.ts",
"unpkg": "src/assets/netteForms.min.js",
"files": [
"src/assets"
],
"main": "nette-forms.umd.js",
"module": "nette-forms.esm.js",
"types": "nette-forms.d.ts",
"unpkg": "nette-forms.umd.min.js",
"repository": {
"type": "git",
"url": "git+https://github.com/nette/forms.git",
Expand Down
7 changes: 7 additions & 0 deletions src/assets/index.esm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { FormValidator } from './formValidator';

// TODO
export function initialize() {
}

export { FormValidator };
2 changes: 1 addition & 1 deletion src/assets/index.umd.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FormValidator } from './formValidator';
import { webalize } from './webalize';
import { version } from './package.json';
import { version } from './dist/package.json';

type NetteForms = FormValidator & { version: string; webalize: typeof webalize };
let nette = new FormValidator as NetteForms;
Expand Down
2 changes: 1 addition & 1 deletion tests/netteForms/karma.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function (config) {
frameworks: ['jasmine'],
browsers: ['ChromeHeadless'],
files: [
'../../src/assets/netteForms.js',
'../../src/assets/dist/nette-forms.umd.js',
'spec/*Spec.js',
],
autoWatch: false,
Expand Down

0 comments on commit 9bbbbb9

Please sign in to comment.