1
0
mirror of synced 2024-11-21 21:06:04 +03:00

chore: Build config fixes, modules paths correction

This commit is contained in:
Zaytsev Kirill 2020-10-11 11:41:32 +03:00
parent 45f29ff27a
commit 713a2bab51
15 changed files with 84 additions and 56 deletions

View File

@ -1,34 +1,35 @@
import commonjs from '@rollup/plugin-commonjs' // Convert CommonJS modules to ES6
import buble from '@rollup/plugin-buble' // Transpile/polyfill with reasonable browser support
import autoExternal from 'rollup-plugin-auto-external' import autoExternal from 'rollup-plugin-auto-external'
import vue from 'rollup-plugin-vue' // Handle .vue SFC files import buble from '@rollup/plugin-buble' // Transpile/polyfill with reasonable browser support
import commonjs from '@rollup/plugin-commonjs' // Convert CommonJS modules to ES6
import { terser } from 'rollup-plugin-terser' import { terser } from 'rollup-plugin-terser'
import typescript from '@rollup/plugin-typescript'
import vue from 'rollup-plugin-vue'
// noinspection JSUnusedGlobalSymbols
export default { export default {
input: 'src/Formulario.js', // Path relative to package.json input: 'src/index.ts',
output: [ output: [{
{ name: 'Formulario',
name: 'Formulario', exports: 'default',
exports: 'default', globals: {
globals: { 'is-plain-object': 'isPlainObject',
'is-plain-object': 'isPlainObject', 'is-url': 'isUrl',
'nanoid/non-secure': 'nanoid', 'nanoid/non-secure': 'nanoid',
'is-url': 'isUrl', },
}, sourcemap: false,
sourcemap: false }],
}
],
external: ['nanoid/non-secure'], external: ['nanoid/non-secure'],
plugins: [ plugins: [
commonjs(), commonjs(),
autoExternal(), autoExternal(),
typescript({ sourceMap: false }),
vue({ vue({
css: true, // Dynamically inject css as a <style> tag css: true, // Dynamically inject css as a <style> tag
compileTemplate: true // Explicitly convert template to render function compileTemplate: true // Explicitly convert template to render function
}), }),
buble({ buble({
objectAssign: 'Object.assign' objectAssign: 'Object.assign',
}), // Transpile to ES5, }), // Transpile to ES5,
terser() terser(),
] ]
} }

View File

@ -1,36 +1,39 @@
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs' // Convert CommonJS modules to ES6 import commonjs from '@rollup/plugin-commonjs' // Convert CommonJS modules to ES6
import buble from '@rollup/plugin-buble' // Transpile/polyfill with reasonable browser support import buble from '@rollup/plugin-buble' // Transpile/polyfill with reasonable browser support
import vue from 'rollup-plugin-vue' // Handle .vue SFC files
import internal from 'rollup-plugin-internal' import internal from 'rollup-plugin-internal'
import resolve from '@rollup/plugin-node-resolve'
import { terser } from 'rollup-plugin-terser' import { terser } from 'rollup-plugin-terser'
import typescript from '@rollup/plugin-typescript'
import vue from 'rollup-plugin-vue' // Handle .vue SFC files
// noinspection JSUnusedGlobalSymbols
export default { export default {
input: 'src/Formulario.js', // Path relative to package.json input: 'src/index.ts', // Path relative to package.json
output: { output: {
name: 'VueFormulario', name: 'VueFormulario',
exports: 'default', exports: 'default',
format: 'iife', format: 'iife',
globals: { globals: {
'is-plain-object': 'isPlainObject', 'is-plain-object': 'isPlainObject',
'nanoid/non-secure': 'nanoid',
'is-url': 'isUrl', 'is-url': 'isUrl',
} 'nanoid/non-secure': 'nanoid',
},
}, },
plugins: [ plugins: [
resolve({ resolve({
browser: true, browser: true,
preferBuiltins: false preferBuiltins: false,
}), }),
commonjs(), commonjs(),
internal(['is-plain-object', 'nanoid/non-secure', 'is-url']), internal(['is-plain-object', 'nanoid/non-secure', 'is-url']),
typescript({ sourceMap: false }),
vue({ vue({
css: true, // Dynamically inject css as a <style> tag css: true, // Dynamically inject css as a <style> tag
compileTemplate: true // Explicitly convert template to render function compileTemplate: true // Explicitly convert template to render function
}), }),
buble({ buble({
objectAssign: 'Object.assign' objectAssign: 'Object.assign',
}), // Transpile to ES5, }), // Transpile to ES5,
terser() terser(),
] ]
} }

View File

@ -1,5 +1,5 @@
import Vue from 'vue' import Vue from 'vue'
import VueFormulario from '../src/Formulario' import VueFormulario from '@/index.ts'
import FormulateSpecimens from './FormulateSpecimens.vue' import FormulateSpecimens from './FormulateSpecimens.vue'
Vue.config.productionTip = false Vue.config.productionTip = false

View File

@ -16,7 +16,7 @@
"main": "dist/formulario.umd.js", "main": "dist/formulario.umd.js",
"module": "dist/formulario.esm.js", "module": "dist/formulario.esm.js",
"browser": { "browser": {
"./sfc": "src/Formulario.js" "./sfc": "src/index.ts"
}, },
"unpkg": "dist/formulario.min.js", "unpkg": "dist/formulario.min.js",
"dependencies": { "dependencies": {
@ -31,9 +31,11 @@
"@babel/core": "^7.9.6", "@babel/core": "^7.9.6",
"@babel/plugin-transform-modules-commonjs": "^7.9.6", "@babel/plugin-transform-modules-commonjs": "^7.9.6",
"@babel/preset-env": "^7.9.6", "@babel/preset-env": "^7.9.6",
"@rollup/plugin-alias": "^3.1.1",
"@rollup/plugin-buble": "^0.21.3", "@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-commonjs": "^11.1.0", "@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3", "@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-typescript": "^6.0.0",
"@types/is-url": "^1.2.28", "@types/is-url": "^1.2.28",
"@types/jest": "^26.0.14", "@types/jest": "^26.0.14",
"@types/nanoid": "^2.1.0", "@types/nanoid": "^2.1.0",

View File

@ -1,17 +1,17 @@
import { VueConstructor } from 'vue' import { VueConstructor } from 'vue'
import library from './libs/library'
import rules from './validation/rules'
import mimes from './libs/mimes'
import FileUpload from './FileUpload'
import RuleValidationMessages from './RuleValidationMessages'
import { arrayify, has } from './libs/utils'
import isPlainObject from 'is-plain-object' import isPlainObject from 'is-plain-object'
import fauxUploader from './libs/faux-uploader'
import library from '@/libs/library'
import rules from '@/validation/rules'
import mimes from '@/libs/mimes'
import FileUpload from '@/FileUpload'
import RuleValidationMessages from '@/RuleValidationMessages'
import { arrayify, has } from '@/libs/utils'
import fauxUploader from '@/libs/faux-uploader'
import FormularioForm from '@/FormularioForm.vue' import FormularioForm from '@/FormularioForm.vue'
import FormularioInput from '@/FormularioInput.vue' import FormularioInput from '@/FormularioInput.vue'
import FormularioGrouping from './FormularioGrouping.vue' import FormularioGrouping from '@/FormularioGrouping.vue'
import { ObjectType } from '@/common.types' import { ObjectType } from '@/common.types'
import { ValidationContext } from '@/validation/types' import { ValidationContext } from '@/validation/types'
@ -39,7 +39,7 @@ interface FormularioOptions {
/** /**
* The base formulario library. * The base formulario library.
*/ */
class Formulario { export default class Formulario {
public options: FormularioOptions public options: FormularioOptions
public defaults: FormularioOptions public defaults: FormularioOptions
public registry: Map<string, FormularioForm> public registry: Map<string, FormularioForm>
@ -299,7 +299,3 @@ class Formulario {
return new FileUpload(data, context, this.options) return new FileUpload(data, context, this.options)
} }
} }
export { Formulario }
export default new Formulario()

View File

@ -1,4 +1,4 @@
import { Formulario } from '@/Formulario' import Formulario from '@/Formulario'
import FormularioInput from '@/FormularioInput.vue' import FormularioInput from '@/FormularioInput.vue'
import { ValidationContext } from '@/validation/types' import { ValidationContext } from '@/validation/types'

View File

@ -1,2 +1 @@
export type ArrayType = [any]
export type ObjectType = { [key: string]: any } export type ObjectType = { [key: string]: any }

3
src/index.ts Normal file
View File

@ -0,0 +1,3 @@
import Formulario from '@/Formulario.ts'
export default new Formulario()

3
src/shims-ext.d.ts vendored
View File

@ -1,5 +1,4 @@
import Vue from 'vue' import Formulario from '@/Formulario'
import { Formulario } from '@/Formulario'
declare module 'vue/types/vue' { declare module 'vue/types/vue' {
interface VueRoute { interface VueRoute {

View File

@ -1,4 +1,4 @@
import Formulario from '@/Formulario.ts' import Formulario from '@/index.ts'
describe('Formulario', () => { describe('Formulario', () => {
it('can merge simple object', () => { it('can merge simple object', () => {

View File

@ -2,7 +2,7 @@ import Vue from 'vue'
import { mount } from '@vue/test-utils' import { mount } from '@vue/test-utils'
import flushPromises from 'flush-promises' import flushPromises from 'flush-promises'
import FormSubmission from '@/FormSubmission.ts' import FormSubmission from '@/FormSubmission.ts'
import Formulario from '@/Formulario.ts' import Formulario from '@/index.ts'
import FormularioForm from '@/FormularioForm.vue' import FormularioForm from '@/FormularioForm.vue'
function validationMessages (instance) { function validationMessages (instance) {

View File

@ -1,7 +1,7 @@
import Vue from 'vue' import Vue from 'vue'
import { mount } from '@vue/test-utils' import { mount } from '@vue/test-utils'
import flushPromises from 'flush-promises' import flushPromises from 'flush-promises'
import Formulario from '@/Formulario.ts' import Formulario from '@/index.ts'
import FormularioForm from '@/FormularioForm.vue' import FormularioForm from '@/FormularioForm.vue'
import FormularioGrouping from '@/FormularioGrouping.vue' import FormularioGrouping from '@/FormularioGrouping.vue'

View File

@ -2,7 +2,7 @@ import Vue from 'vue'
import flushPromises from 'flush-promises' import flushPromises from 'flush-promises'
import { mount } from '@vue/test-utils' import { mount } from '@vue/test-utils'
import Formulario from '@/Formulario.ts' import Formulario from '@/index.ts'
import FormularioForm from '@/FormularioForm.vue' import FormularioForm from '@/FormularioForm.vue'
import FormularioInput from '@/FormularioInput.vue' import FormularioInput from '@/FormularioInput.vue'

View File

@ -1,7 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2019", "target": "es2015",
"module": "commonjs", "module": "es2015",
"strict": true, "strict": true,
"jsx": "preserve", "jsx": "preserve",
"importHelpers": true, "importHelpers": true,
@ -28,6 +28,7 @@
] ]
}, },
"include": [ "include": [
"src/**/*.js",
"src/**/*.ts", "src/**/*.ts",
"src/**/*.tsx", "src/**/*.tsx",
"src/**/*.vue", "src/**/*.vue",

View File

@ -1228,6 +1228,13 @@
"@nodelib/fs.scandir" "2.1.3" "@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0" fastq "^1.6.0"
"@rollup/plugin-alias@^3.1.1":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-3.1.1.tgz#bb96cf37fefeb0a953a6566c284855c7d1cd290c"
integrity sha512-hNcQY4bpBUIvxekd26DBPgF7BT4mKVNDF5tBG4Zi+3IgwLxGYRY0itHs9D0oLVwXM5pvJDWJlBQro+au8WaUWw==
dependencies:
slash "^3.0.0"
"@rollup/plugin-buble@^0.21.3": "@rollup/plugin-buble@^0.21.3":
version "0.21.3" version "0.21.3"
resolved "https://registry.yarnpkg.com/@rollup/plugin-buble/-/plugin-buble-0.21.3.tgz#1649a915b1d051a4f430d40e7734a7f67a69b33e" resolved "https://registry.yarnpkg.com/@rollup/plugin-buble/-/plugin-buble-0.21.3.tgz#1649a915b1d051a4f430d40e7734a7f67a69b33e"
@ -1261,6 +1268,14 @@
is-module "^1.0.0" is-module "^1.0.0"
resolve "^1.14.2" resolve "^1.14.2"
"@rollup/plugin-typescript@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-6.0.0.tgz#08635d9d04dc3a099ef0150c289ba5735200bc63"
integrity sha512-Y5U2L4eaF3wUSgCZRMdvNmuzWkKMyN3OwvhAdbzAi5sUqedaBk/XbzO4T7RlViDJ78MOPhwAIv2FtId/jhMtbg==
dependencies:
"@rollup/pluginutils" "^3.1.0"
resolve "^1.17.0"
"@rollup/pluginutils@^3.0.8": "@rollup/pluginutils@^3.0.8":
version "3.0.10" version "3.0.10"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.0.10.tgz#a659b9025920378494cd8f8c59fbf9b3a50d5f12" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.0.10.tgz#a659b9025920378494cd8f8c59fbf9b3a50d5f12"
@ -1270,6 +1285,15 @@
estree-walker "^1.0.1" estree-walker "^1.0.1"
picomatch "^2.2.2" picomatch "^2.2.2"
"@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
dependencies:
"@types/estree" "0.0.39"
estree-walker "^1.0.1"
picomatch "^2.2.2"
"@sinonjs/commons@^1.7.0": "@sinonjs/commons@^1.7.0":
version "1.8.1" version "1.8.1"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.1.tgz#e7df00f98a203324f6dc7cc606cad9d4a8ab2217" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.1.tgz#e7df00f98a203324f6dc7cc606cad9d4a8ab2217"
@ -6573,11 +6597,11 @@ is-promise@^2.0.0:
integrity sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ== integrity sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==
is-reference@^1.1.2: is-reference@^1.1.2:
version "1.1.4" version "1.2.1"
resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.1.4.tgz#3f95849886ddb70256a3e6d062b1a68c13c51427" resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7"
integrity sha512-uJA/CDPO3Tao3GTrxYn6AwkM4nUPJiGGYu5+cB8qbC7WGFlrKZbiRo7SFKxUAEpFUfiHofWCXBUNhvYJMh+6zw== integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==
dependencies: dependencies:
"@types/estree" "0.0.39" "@types/estree" "*"
is-regex@^1.0.3, is-regex@^1.0.4, is-regex@^1.0.5: is-regex@^1.0.3, is-regex@^1.0.4, is-regex@^1.0.5:
version "1.0.5" version "1.0.5"