dev-fast.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. const path = require('path');
  20. const {build} = require('esbuild');
  21. const commander = require('commander');
  22. const outFilePath = path.resolve(__dirname, '../dist/echarts.js');
  23. const umdWrapperHead = `(function (root, factory) {
  24. if (typeof define === 'function' && define.amd) {
  25. // AMD. Register as an anonymous module.
  26. define(['exports'], factory);
  27. } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
  28. // CommonJS
  29. factory(exports);
  30. } else {
  31. // Browser globals
  32. factory((root.echarts = {}));
  33. }
  34. }(typeof self !== 'undefined' ? self : this, function (exports, b) {
  35. `;
  36. const umdWrapperTail = `
  37. }));`;
  38. build({
  39. entryPoints: [path.resolve(__dirname, '../src/echarts.all.ts')],
  40. outfile: outFilePath,
  41. format: 'cjs',
  42. sourcemap: true,
  43. bundle: true,
  44. banner: umdWrapperHead,
  45. footer: umdWrapperTail,
  46. define: {
  47. 'process.env.NODE_ENV': '"development"',
  48. '__DEV__': 'true'
  49. },
  50. watch: {
  51. async onRebuild(error) {
  52. if (error) {
  53. console.error('watch build failed:', error)
  54. }
  55. else {
  56. console.log('Bundled with esbuild')
  57. }
  58. },
  59. },
  60. }).then(async () => {
  61. console.log('Bundled with esbuild')
  62. }).catch(e => console.error(e.toString()))