Commit bfc3b458 authored by 邓晓峰's avatar 邓晓峰

fix: 修复esm编译

parent 71455426
Pipeline #48575 skipped with stages
...@@ -5,7 +5,7 @@ PROXY=/Cityinterface:http://192.168.12.116:8015;/PandaOMS:http://192.168.12.116: ...@@ -5,7 +5,7 @@ PROXY=/Cityinterface:http://192.168.12.116:8015;/PandaOMS:http://192.168.12.116:
# PROXY2 = test : http://localhost:8006/ # PROXY2 = test : http://localhost:8006/
# 本地应用启动的host域名 # 本地应用启动的host域名
HOST = 192.168.12.192 HOST = 127.0.0.1
# 本地应用启动的端口 # 本地应用启动的端口
PORT = 3001 PORT = 3001
...@@ -3,16 +3,39 @@ module.exports = { ...@@ -3,16 +3,39 @@ module.exports = {
[ [
'@babel/preset-env', '@babel/preset-env',
{ {
modules: false, 'exclude': [
'transform-typeof-symbol',
'transform-unicode-regex',
'transform-sticky-regex',
'transform-new-target',
'transform-modules-umd',
'transform-modules-systemjs',
'transform-modules-amd',
'transform-literals',
],
'modules': false,
}, },
], ],
'@babel/preset-react', ['@babel/preset-typescript'],
['@babel/preset-react'],
], ],
plugins: [ plugins: [
'styled-components', 'styled-components',
'@babel/plugin-proposal-class-properties', ['@babel/plugin-proposal-optional-chaining', { 'loose': false }],
['@babel/plugin-proposal-nullish-coalescing-operator', { 'loose': false }],
'@babel/plugin-syntax-top-level-await',
['@babel/plugin-transform-destructuring', { 'loose': false }],
['@babel/plugin-proposal-decorators', { 'legacy': true }],
['@babel/plugin-proposal-class-properties', { 'loose': true }],
'@babel/plugin-proposal-export-default-from',
['@babel/plugin-proposal-pipeline-operator', { 'proposal': 'minimal' }],
'@babel/plugin-proposal-do-expressions',
'@babel/plugin-proposal-function-bind',
'@babel/plugin-proposal-logical-assignment-operators',
'@babel/plugin-syntax-dynamic-import', '@babel/plugin-syntax-dynamic-import',
['import', { libraryName: 'antd', style: true }], ['babel-plugin-transform-react-remove-prop-types', { 'removeImport': true }],
['babel-plugin-react-require'],
['babel-plugin-import', { 'libraryName': 'antd', 'libraryDirectory': 'es', 'style': true }, 'antd'],
], ],
env: { env: {
production: { production: {
...@@ -21,14 +44,14 @@ module.exports = { ...@@ -21,14 +44,14 @@ module.exports = {
'lodash', 'lodash',
'transform-react-remove-prop-types', 'transform-react-remove-prop-types',
'@babel/plugin-transform-react-inline-elements', '@babel/plugin-transform-react-inline-elements',
'@babel/plugin-transform-react-constant-elements', '@babel/plugin-transform-react-constant-elements'
], ],
}, },
development: {
plugins: ['react-refresh/babel']
},
test: { test: {
plugins: [ plugins: ['@babel/plugin-transform-modules-commonjs', 'dynamic-import-node']
'@babel/plugin-transform-modules-commonjs',
'dynamic-import-node',
],
}, },
}, },
}; };
...@@ -3,6 +3,8 @@ const webpack = require('webpack'); ...@@ -3,6 +3,8 @@ const webpack = require('webpack');
const slash = require('slash2'); const slash = require('slash2');
const CopyPlugin = require('copy-webpack-plugin'); const CopyPlugin = require('copy-webpack-plugin');
const cesiumSource = './node_modules/cesium/Build/Cesium'; const cesiumSource = './node_modules/cesium/Build/Cesium';
const FastRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const nodeLibs = require('node-libs-browser');
console.log(); console.log();
module.exports = options => ({ module.exports = options => ({
mode: options.mode, mode: options.mode,
...@@ -22,10 +24,6 @@ module.exports = options => ({ ...@@ -22,10 +24,6 @@ module.exports = options => ({
// 允许Cesium兼容 webpack的require方式 // 允许Cesium兼容 webpack的require方式
toUrlUndefined: true, toUrlUndefined: true,
}, },
node: {
// 解决fs模块的问题(Resolve node module use of fs)
fs: 'empty',
},
module: { module: {
rules: [ rules: [
{ {
...@@ -33,11 +31,11 @@ module.exports = options => ({ ...@@ -33,11 +31,11 @@ module.exports = options => ({
exclude: /node_modules/, exclude: /node_modules/,
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
// options: options.babelQuery, options: options.babelQuery,
options: { // options: {
presets: ['@babel/preset-typescript'], // presets: ['@babel/preset-typescript'],
plugins: ['@babel/plugin-proposal-optional-chaining'], // plugins: ['@babel/plugin-proposal-optional-chaining'],
}, // },
}, },
}, },
{ {
...@@ -178,6 +176,12 @@ module.exports = options => ({ ...@@ -178,6 +176,12 @@ module.exports = options => ({
NODE_ENV: 'development', NODE_ENV: 'development',
}), }),
new webpack.ProvidePlugin({
process: nodeLibs.process
}),
new FastRefreshPlugin({
overlay: false
}),
new CopyPlugin([ new CopyPlugin([
{ {
from: path.resolve(process.cwd(), './public'), from: path.resolve(process.cwd(), './public'),
...@@ -212,6 +216,19 @@ module.exports = options => ({ ...@@ -212,6 +216,19 @@ module.exports = options => ({
'@': path.resolve(process.cwd(), './src'), '@': path.resolve(process.cwd(), './src'),
components: path.resolve(process.cwd(), './src/components'), components: path.resolve(process.cwd(), './src/components'),
cesium: path.resolve(process.cwd(), cesiumSource), cesium: path.resolve(process.cwd(), cesiumSource),
react: path.resolve(process.cwd(), './node_modules/react'),
},
fallback: {
...Object.keys(nodeLibs).reduce((memo, key) => {
if (nodeLibs[key]) {
memo[key] = nodeLibs[key];
} else {
memo[key] = false;
}
return memo;
}, {}),
http: false,
https: false,
}, },
}, },
devtool: options.devtool, devtool: options.devtool,
......
...@@ -36,10 +36,10 @@ module.exports = require('./webpack.base.babel')({ ...@@ -36,10 +36,10 @@ module.exports = require('./webpack.base.babel')({
inject: true, // Inject all files that are generated by webpack, e.g. bundle.js inject: true, // Inject all files that are generated by webpack, e.g. bundle.js
template: 'src/index.html', template: 'src/index.html',
}), }),
new CircularDependencyPlugin({ // new CircularDependencyPlugin({
exclude: /a\.js|node_modules/, // exclude node_modules // exclude: /a\.js|node_modules/, // exclude node_modules
failOnError: false, // show a warning when there is a circular dependency // failOnError: false, // show a warning when there is a circular dependency
}), // }),
], ],
devtool: 'cheap-module-source-map', devtool: 'cheap-module-source-map',
node: { node: {
......
...@@ -90,6 +90,9 @@ ...@@ -90,6 +90,9 @@
"@babel/preset-typescript": "^7.12.1", "@babel/preset-typescript": "^7.12.1",
"@babel/runtime": "^7.10.5", "@babel/runtime": "^7.10.5",
"@wisdom-cesium/cesium": "^1.0.29", "@wisdom-cesium/cesium": "^1.0.29",
"@wisdom-map/arcgismap": "^1.0.79-26",
"@esri/arcgis-html-sanitizer": "2.9.1",
"@esri/calcite-colors": "6.0.3",
"ace-builds": "^1.4.12", "ace-builds": "^1.4.12",
"antd-img-crop": "^3.13.2", "antd-img-crop": "^3.13.2",
"bizcharts": "^4.0.15", "bizcharts": "^4.0.15",
...@@ -102,12 +105,10 @@ ...@@ -102,12 +105,10 @@
"express": "4.16.4", "express": "4.16.4",
"fontfaceobserver": "2.1.0", "fontfaceobserver": "2.1.0",
"gojs": "2.1.49", "gojs": "2.1.49",
"react-dnd-html5-backend": "latest",
"react-dnd": "latest",
"immutability-helper": "latest",
"history": "4.9.0", "history": "4.9.0",
"hoist-non-react-statics": "3.3.0", "hoist-non-react-statics": "3.3.0",
"immer": "3.0.0", "immer": "3.0.0",
"immutability-helper": "latest",
"immutable": "^4.0.0-rc.12", "immutable": "^4.0.0-rc.12",
"intl": "1.2.5", "intl": "1.2.5",
"invariant": "2.2.4", "invariant": "2.2.4",
...@@ -118,6 +119,8 @@ ...@@ -118,6 +119,8 @@
"react": "16.14.0", "react": "16.14.0",
"react-ace": "^9.2.0", "react-ace": "^9.2.0",
"react-copy-to-clipboard": "^5.0.4", "react-copy-to-clipboard": "^5.0.4",
"react-dnd": "latest",
"react-dnd-html5-backend": "latest",
"react-dom": "16.14.0", "react-dom": "16.14.0",
"react-grid-layout": "^1.2.5", "react-grid-layout": "^1.2.5",
"react-helmet": "6.0.0-beta", "react-helmet": "6.0.0-beta",
...@@ -144,6 +147,15 @@ ...@@ -144,6 +147,15 @@
"@ant-design/pro-table": "^2.5.3", "@ant-design/pro-table": "^2.5.3",
"@babel/cli": "7.4.3", "@babel/cli": "7.4.3",
"@babel/core": "7.4.3", "@babel/core": "7.4.3",
"@babel/plugin-syntax-top-level-await": "^7.14.5",
"@babel/plugin-proposal-decorators": "^7.17.9",
"@babel/plugin-proposal-export-default-from": "^7.16.7",
"@babel/plugin-proposal-pipeline-operator": "^7.17.6",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
"@babel/plugin-proposal-do-expressions": "^7.16.7",
"@babel/plugin-proposal-function-bind": "^7.16.7",
"@babel/plugin-proposal-logical-assignment-operators": "^7.16.7",
"babel-plugin-react-require": "^3.1.3",
"@babel/plugin-proposal-class-properties": "7.4.0", "@babel/plugin-proposal-class-properties": "7.4.0",
"@babel/plugin-syntax-dynamic-import": "7.2.0", "@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-transform-modules-commonjs": "7.4.3", "@babel/plugin-transform-modules-commonjs": "7.4.3",
...@@ -166,6 +178,8 @@ ...@@ -166,6 +178,8 @@
"babel-plugin-react-intl": "3.0.1", "babel-plugin-react-intl": "3.0.1",
"babel-plugin-styled-components": "1.10.0", "babel-plugin-styled-components": "1.10.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24", "babel-plugin-transform-react-remove-prop-types": "0.4.24",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
"react-refresh": "^0.9.0",
"circular-dependency-plugin": "5.0.2", "circular-dependency-plugin": "5.0.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"compare-versions": "3.4.0", "compare-versions": "3.4.0",
...@@ -189,9 +203,10 @@ ...@@ -189,9 +203,10 @@
"eslint-plugin-redux-saga": "1.0.0", "eslint-plugin-redux-saga": "1.0.0",
"file-loader": "3.0.1", "file-loader": "3.0.1",
"html-loader": "0.5.5", "html-loader": "0.5.5",
"html-webpack-plugin": "3.2.0", "html-webpack-plugin": "^4.4.0",
"http-proxy-middleware": "^1.0.6", "http-proxy-middleware": "^1.0.6",
"husky": "^2.3.0", "husky": "^2.3.0",
"i": "^0.3.7",
"imports-loader": "0.8.0", "imports-loader": "0.8.0",
"jest-cli": "24.7.1", "jest-cli": "24.7.1",
"jest-dom": "3.1.3", "jest-dom": "3.1.3",
...@@ -203,6 +218,7 @@ ...@@ -203,6 +218,7 @@
"moment": "^2.25.3", "moment": "^2.25.3",
"ngrok": "3.1.1", "ngrok": "3.1.1",
"node-plop": "0.18.0", "node-plop": "0.18.0",
"npm": "^8.7.0",
"null-loader": "0.1.1", "null-loader": "0.1.1",
"offline-plugin": "5.0.6", "offline-plugin": "5.0.6",
"patch-package": "^6.4.7", "patch-package": "^6.4.7",
...@@ -238,9 +254,9 @@ ...@@ -238,9 +254,9 @@
"svg-url-loader": "2.3.2", "svg-url-loader": "2.3.2",
"terser-webpack-plugin": "1.2.3", "terser-webpack-plugin": "1.2.3",
"url-loader": "1.1.2", "url-loader": "1.1.2",
"webpack": "4.30.0", "webpack": "5.70.0",
"webpack-cli": "3.3.0", "webpack-cli": "4.2.0",
"webpack-dev-middleware": "3.6.2", "webpack-dev-middleware": "5.3.0",
"webpack-hot-middleware": "2.24.3", "webpack-hot-middleware": "2.24.3",
"webpack-pwa-manifest": "4.0.0", "webpack-pwa-manifest": "4.0.0",
"whatwg-fetch": "3.0.0", "whatwg-fetch": "3.0.0",
......
...@@ -6,9 +6,9 @@ const { addProxyMiddleware } = require('../proxy'); ...@@ -6,9 +6,9 @@ const { addProxyMiddleware } = require('../proxy');
function createWebpackMiddleware(compiler, publicPath) { function createWebpackMiddleware(compiler, publicPath) {
return webpackDevMiddleware(compiler, { return webpackDevMiddleware(compiler, {
logLevel: 'warn', // logLevel: 'warn',
publicPath, publicPath,
silent: true, // silent: true,
stats: 'errors-only', stats: 'errors-only',
}); });
} }
...@@ -25,7 +25,7 @@ module.exports = function addDevMiddlewares(app, webpackConfig) { ...@@ -25,7 +25,7 @@ module.exports = function addDevMiddlewares(app, webpackConfig) {
addProxyMiddleware(app); addProxyMiddleware(app);
// Since webpackDevMiddleware uses memory-fs internally to store build // Since webpackDevMiddleware uses memory-fs internally to store build
// artifacts, we use it instead // artifacts, we use it instead
const fs = middleware.fileSystem; const fs = middleware.context.outputFileSystem;
app.get('*', (_req, res) => { app.get('*', (_req, res) => {
fs.readFile(path.join(compiler.outputPath, 'index.html'), (err, file) => { fs.readFile(path.join(compiler.outputPath, 'index.html'), (err, file) => {
......
/* eslint-disable */
import '!file-loader?name=[name].[ext]!./images/favicon.ico'; import '!file-loader?name=[name].[ext]!./images/favicon.ico';
import './global.less'; import './global.less';
import '@babel/polyfill'; import '@babel/polyfill';
...@@ -7,15 +8,13 @@ import 'sanitize.css/sanitize.css'; ...@@ -7,15 +8,13 @@ import 'sanitize.css/sanitize.css';
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { ArcGISMap as MapComponent } from '@wisdom-map/arcgismap';
import { ConfigProvider } from 'antd'; import { ConfigProvider } from 'antd';
import zhCN from 'antd/es/locale/zh_CN'; import zhCN from 'antd/es/locale/zh_CN';
import { ConnectedRouter } from 'connected-react-router/immutable'; import { ConnectedRouter } from 'connected-react-router/immutable';
import Immutable from 'immutable'; import Immutable from 'immutable';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { PictureWallProvider } from '@/components/Upload/context';
import configureStore from './configureStore'; import configureStore from './configureStore';
import App from './containers/App'; import App from './containers/App';
import config from './routes/config'; import config from './routes/config';
...@@ -26,12 +25,12 @@ const store = configureStore(initialState, history); ...@@ -26,12 +25,12 @@ const store = configureStore(initialState, history);
const MOUNT_NODE = document.getElementById('app'); const MOUNT_NODE = document.getElementById('app');
const render = () => { const render = () => {
ReactDOM.render( ReactDOM.render(
<Provider store={store}> <Provider store = { store }>
<ConnectedRouter history={history}> <ConnectedRouter history = { history }>
<ConfigProvider locale={zhCN}> <ConfigProvider locale = { zhCN } >
{/* <PictureWallProvider> */} { /* <PictureWallProvider> */ }
<App routesConfig={config} /> <App routesConfig = { config }/>
{/* </PictureWallProvider> */} { /* </PictureWallProvider> */ }
</ConfigProvider> </ConfigProvider>
</ConnectedRouter> </ConnectedRouter>
</Provider>, </Provider>,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment