@fxjs/handbag
Advanced tools
@@ -35,2 +35,3 @@ /// <reference types="fibjs" /> | ||
compilerOptions: CompilerOptionsTypeCommon | ||
env: string | ||
} | ||
@@ -44,2 +45,3 @@ | ||
compilerOptions?: CompilerOptionsType | ||
env?: string | ||
@@ -46,0 +48,0 @@ [key: string]: any |
v0.2.6 / 2019-01-20 | ||
v0.2.7 / 2019-02-25 | ||
================== | ||
* upgrade dependencies, adapt fib-rollup v0.4.0(due to its dependency on rollup v1 rather v0.66.x) | ||
* robust. | ||
* little fix. | ||
* code, doc clean. | ||
* support react register. | ||
* migrate LICENSE to MIT | ||
v0.2.6 / 2019-01-20 | ||
=================== | ||
* Release v0.2.6 | ||
* specify uglify-js as dependency and adjust it. | ||
@@ -6,0 +17,0 @@ |
@@ -11,2 +11,3 @@ /// <reference types="fibjs" /> | ||
registerOptions.emitter = registerOptions.emitter || getCommonEmitter(registerOptions.hooks); | ||
registerOptions.env = registerOptions.env || 'development'; | ||
return registerOptions; | ||
@@ -13,0 +14,0 @@ } |
@@ -20,3 +20,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.vue = vue; | ||
const react = require("./react"); | ||
exports.react = react; | ||
const riot = require("./riot"); | ||
exports.riot = riot; |
@@ -20,3 +20,4 @@ /// <reference path="../../@types/index.d.ts" /> | ||
] }, rollupConfig.bundleConfig)); | ||
const { code: rollupedJs } = util.sync(bundle.generate, true)(Object.assign({}, rollupConfig.writeConfig, { output: Object.assign({ format: 'umd', name: rollupConfig.onGenerateUmdName(buf, info) }, rollupConfig.writeConfig.output) })); | ||
const { output } = util.sync(bundle.generate, true)(Object.assign({}, rollupConfig.writeConfig, { output: Object.assign({ format: 'umd', name: rollupConfig.onGenerateUmdName(buf, info) }, rollupConfig.writeConfig.output) })); | ||
const { code: rollupedJs } = output[0]; | ||
return asPlainScript ? vbox_1.wrapAsString(rollupedJs) : rollupedJs; | ||
@@ -23,0 +24,0 @@ }, |
@@ -10,7 +10,2 @@ /// <reference path="../../@types/index.d.ts" /> | ||
exports.SUFFIX = ['.vue']; | ||
const DEFAULT_ROLLUP_PLUGIN_VUE_OPTS = { | ||
template: { | ||
isProduction: true | ||
} | ||
}; | ||
function _register(asModule) { | ||
@@ -21,8 +16,13 @@ const default_transpileLib = asModule === true ? false : 'babel'; | ||
const { default: rollup } = require('fib-rollup'); | ||
const { burnout_timeout = 0, suffix = exports.SUFFIX, emitter = null } = _utils_1.parseCommonOptions(options) || {}; | ||
const { rollupPluginVueOptions = DEFAULT_ROLLUP_PLUGIN_VUE_OPTS, tranpileLib = undefined, /* for historical mistake */ transpileLib = tranpileLib || default_transpileLib, } = options || {}; | ||
const { burnout_timeout = 0, suffix = exports.SUFFIX, emitter = null, env = '' } = _utils_1.parseCommonOptions(options) || {}; | ||
const { rollupPluginVueOptions = {}, tranpileLib = undefined, /* for historical mistake */ transpileLib = tranpileLib || default_transpileLib, } = options || {}; | ||
if (rollupPluginVueOptions) { | ||
rollupPluginVueOptions.template = rollupPluginVueOptions.template || {}; | ||
rollupPluginVueOptions.template.optimizeSSR = !!asModule; | ||
rollupPluginVueOptions.template.isProduction = utils_1.isProduction(env); | ||
} | ||
const rollupConfig = _utils_2.getRollupOptionsFromRegisterOptions(options); | ||
rollupConfig.bundleConfig = rollupConfig.bundleConfig || {}; | ||
rollupConfig.bundleConfig.plugins = rollupConfig.bundleConfig.plugins || getDefaultPlugins(rollupPluginVueOptions, transpileLib); | ||
if (utils_1.isProduction()) | ||
if (utils_1.isProduction(env)) | ||
rollupConfig.bundleConfig.plugins.push(fibRollup.plugins['rollup-plugin-uglify-js']()); | ||
@@ -33,3 +33,4 @@ vbox_1.setCompilerForVbox(vbox, { | ||
const bundle = util.sync(rollup.rollup, true)(Object.assign({ input: info.filename, external: moduleList }, rollupConfig.bundleConfig)); | ||
const { code: rollupedJs } = util.sync(bundle.generate, true)(Object.assign({}, rollupConfig.writeConfig, { output: Object.assign({ format: 'umd', name: rollupConfig.onGenerateUmdName(buf, info) }, rollupConfig.writeConfig.output) })); | ||
const { output } = util.sync(bundle.generate, true)(Object.assign({}, rollupConfig.writeConfig, { output: Object.assign({ format: 'umd', name: rollupConfig.onGenerateUmdName(buf, info) }, rollupConfig.writeConfig.output) })); | ||
const { code: rollupedJs } = output[0]; | ||
return !asModule ? vbox_1.wrapAsString(rollupedJs) : rollupedJs; | ||
@@ -54,3 +55,3 @@ }, | ||
const rollupPluginRequireVbox = getRequireVBox(); | ||
return rollupPluginRequireVbox.require('rollup-plugin-vue', __dirname).default; | ||
return rollupPluginRequireVbox.require('rollup-plugin-vue', __dirname); | ||
} | ||
@@ -88,5 +89,2 @@ exports.getRollupPluginVue = getRollupPluginVue; | ||
]; | ||
if (utils_1.isProduction()) { | ||
defaultPlugins.push(fibRollup.plugins['rollup-plugin-uglify-js']()); | ||
} | ||
return defaultPlugins; | ||
@@ -93,0 +91,0 @@ } |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function isProduction() { | ||
return process.env.FX_HANDBAG_ENV === 'production' || process.env.NODE_ENV === 'production'; | ||
function isProduction(env = process.env.FX_HANDBAG_ENV || process.env.NODE_ENV) { | ||
return env === 'production'; | ||
} | ||
exports.isProduction = isProduction; |
{ | ||
"name": "@fxjs/handbag", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "require resources directly 👝", | ||
@@ -10,3 +10,3 @@ "types": "@types/index.d.ts", | ||
"test": "fibjs test/index.js", | ||
"ci": "npm run build && npm run test", | ||
"ci": "npm run build && cross-env NO_BO_TEST=1 npm run test", | ||
"prepublishOnly": "npm run build" | ||
@@ -23,3 +23,3 @@ }, | ||
"author": "richardo2016@gmail.com", | ||
"license": "GPL-3.0", | ||
"license": "MIT", | ||
"bugs": { | ||
@@ -30,8 +30,8 @@ "url": "https://github.com/fxjs-modules/handbag/issues" | ||
"dependencies": { | ||
"@babel/standalone": "^7.1.0", | ||
"@babel/standalone": "^7.3.3", | ||
"@fibjs/builtin-modules": "^0.1.0", | ||
"fib-pug": "0.0.3", | ||
"fib-rollup": "^0.3.0", | ||
"fib-typify": "^0.5.0", | ||
"riot-compiler": "^3.5.2", | ||
"fib-rollup": "^0.4.0", | ||
"fib-typify": "^0.5.2", | ||
"riot-compiler": "^3.5.3", | ||
"stylus": "^0.54.5", | ||
@@ -46,13 +46,16 @@ "uglify-js": "^3.4.9" | ||
"cheerio": "^1.0.0-rc.2", | ||
"graphql": "^14.0.2", | ||
"graphql-tag": "^2.10.0", | ||
"cross-env": "^5.2.0", | ||
"graphql": "^14.1.1", | ||
"graphql-tag": "^2.10.1", | ||
"jstransformer-stylus": "^1.5.0", | ||
"jstransformer-typescript": "^1.1.0", | ||
"rollup-plugin-buble": "^0.19.4", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"react": "^16.8.3", | ||
"react-dom": "^16.8.3", | ||
"rollup-plugin-buble": "^0.19.6", | ||
"rollup-plugin-commonjs": "^9.2.1", | ||
"rollup-plugin-typescript": "^1.0.0", | ||
"rollup-plugin-vue": "^4.3.2", | ||
"rollup-plugin-vue": "^4.7.2", | ||
"tslib": "^1.9.3", | ||
"typescript": "^3.1.6", | ||
"vue-template-compiler": "^2.5.17" | ||
"typescript": "^3.3.3333", | ||
"vue-template-compiler": "^2.6.7" | ||
}, | ||
@@ -59,0 +62,0 @@ "ci": { |
@@ -70,4 +70,3 @@ # 👝 @fxjs/handbag | ||
`setCompilerForVbox(vbox: Class_SandBox, options: SetCompilerForVBoxOptions)` | ||
--- | ||
**setCompilerForVbox(vbox: Class_SandBox, options: SetCompilerForVBoxOptions)** | ||
@@ -101,4 +100,5 @@ set one `compiler` function for `vbox`, the `compiler` is used for [`vbox.setModuleCompiler`]. | ||
#### Register: Plain | ||
`plain.registerAsPlain(vbox, options)` | ||
--- | ||
- options.suffix: default `['.txt']` | ||
@@ -108,4 +108,5 @@ | ||
#### Register: Pug | ||
`pug.registerPugAsRender(vbox, options)` | ||
--- | ||
- options.suffix: default `['.pug', '.jade']` | ||
@@ -116,3 +117,2 @@ | ||
`pug.registerPugAsHtml(vbox, options)` | ||
--- | ||
- options.suffix: default `['.pug', '.jade']` | ||
@@ -124,5 +124,5 @@ | ||
#### Register: Stylus | ||
`stylus.registerStylusAsCss(vbox, options)` | ||
--- | ||
- options.suffix: default `['.styl', '.stylus']` | ||
@@ -133,6 +133,8 @@ | ||
#### Register: Typescript | ||
##### required dependencies | ||
- [typescript] | ||
`typescript.registerTypescriptAsModule(vbox, options)` | ||
--- | ||
- options.suffix: default `['.ts']` | ||
@@ -143,3 +145,2 @@ | ||
`typescript.registerTypescriptAsPlainJavascript(vbox, options)` | ||
--- | ||
- options.suffix: default `['.ts']` | ||
@@ -150,10 +151,10 @@ | ||
#### Package Register: Rollup | ||
`rollup.registerAsModule(vbox, options)` | ||
--- | ||
- options.suffix: default `['.ts', '.tsx']` | ||
- options.rollup | ||
register compiler to require typescript file as module. | ||
register compiler to specified js-preprocessor file as module. | ||
@@ -166,7 +167,6 @@ **extra dependencies** | ||
`rollup.registerAsPlainJavascript(vbox, options)` | ||
--- | ||
- options.suffix: default `['.ts', '.tsx']` | ||
- options.rollup | ||
register compiler to require typescript file as **rolluped** plain javascript string. | ||
register compiler to specified js-preprocessor file as **rolluped** plain javascript string. | ||
@@ -177,5 +177,5 @@ **extra dependencies** | ||
#### Register: Vue | ||
`vue.registerVueAsRollupedJavascript(vbox, options)` | ||
--- | ||
- options.suffix: default `['.vue']` | ||
@@ -189,3 +189,3 @@ - options.rollup | ||
register compiler to require typescript file as **rolluped** plain javascript string | ||
register compiler to require vue file as **rolluped** plain javascript string | ||
@@ -207,5 +207,32 @@ **NOTICE** it's not recommend use `async/await` in vue component, if you do so, the transpiled vue component's size would be large. | ||
#### Register: React | ||
`react.registerReactAsRollupedJavascript(vbox, options)` | ||
**started from `0.2.7`** | ||
- options.suffix: default `['.ts', '.jsx', '.tsx']` | ||
- options.rollup | ||
- options.transpileLib: default `'babel'` | ||
- any value equals to `false`: no transpile | ||
- 'babel': transpile component with babel | ||
- 'buble': transpile component with buble | ||
register compiler to require react file as **rolluped** plain javascript string | ||
**NOTICE** it's not recommend use `async/await` in react component, if you do so, the transpiled vue component's size would be large. | ||
**extra dependencies** | ||
- [fib-rollup] | ||
- [rollup-plugin-commonjs] | ||
- [rollup-plugin-buble] (if use options.transpileLib="buble") | ||
- [rollup-plugin-typescript] (if support suffix `.ts`, `.tsx`) | ||
- `tslib` | ||
- `typescript` | ||
#### Register: Riot | ||
`riot.registerRiotAsJs(vbox, options)` | ||
--- | ||
**started from `0.2.3`** | ||
@@ -219,6 +246,6 @@ | ||
#### Register: Image | ||
`image.registerImageAsBase64(vbox, options)` | ||
--- | ||
- options.suffix: default `['.png', '.jpg', '.jpeg', '.gif', '.bmp']` | ||
@@ -229,6 +256,6 @@ | ||
#### Register: GraphQL | ||
`graphql.registerGraphQLParser(vbox, options)` | ||
`graphql.registerGraphQLParser(vbox, options)` | ||
--- | ||
**started from `0.2.4`** | ||
@@ -245,6 +272,4 @@ | ||
`graphql.registerGraphQLAsQueryBuilder(vbox, options)` | ||
`graphql.registerGraphQLAsQueryBuilder(vbox, options)` | ||
--- | ||
**started from `0.2.4`** | ||
@@ -296,6 +321,6 @@ | ||
- `before_transpile` | ||
- `payload.raw`: original content's buffer | ||
- `payload.info`: file information | ||
- param `payload.raw`: original content's buffer | ||
- param `payload.info`: file information | ||
- `generated`: payload: {result} | ||
- `payload.result`: transpiled content | ||
- param `payload.result`: transpiled content | ||
@@ -305,8 +330,8 @@ ### `registerOptions.rollup` | ||
- options.rollup.bundleConfig: default `{}`, config passed to | ||
- `options.rollup.bundleConfig`: default `{}`, config passed to | ||
- `const bundle = rollup.rollup({...})` | ||
- options.rollup.writeConfig: default `{}`, config passed to | ||
- `options.rollup.writeConfig`: default `{}`, config passed to | ||
- `bundle.write({...})` | ||
- `bundle.generate({...})` | ||
- options.rollup.onGenerateUmdName: default `(buf, info) => 's'`. generate name for rollup's `umd`/`iife` mode | ||
- `options.rollup.onGenerateUmdName`: default `(buf, info) => 's'`. generate name for rollup's `umd`/`iife` mode | ||
@@ -351,3 +376,3 @@ ### `registerOptions.burnout_timeout` | ||
[GPL-3.0](https://opensource.org/licenses/GPL-3.0) | ||
[MIT](https://opensource.org/licenses/MIT) | ||
@@ -365,2 +390,3 @@ Copyright (c) 2018-present, Richard | ||
[graphql]:https://github.com/graphql/graphql-js | ||
[graphql-tag]:https://github.com/apollographql/graphql-tag | ||
[graphql-tag]:https://github.com/apollographql/graphql-tag | ||
[typescript]:https://www.npmjs.com/package/typescript |
Sorry, the diff of this file is not supported yet
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
27
3.85%0
-100%100
42.86%851
9.52%373
7.49%50755
-36.43%19
18.75%