fix: lockdown (#3336)
This commit is contained in:
@@ -106,8 +106,8 @@ export const createConfiguration: (
|
|||||||
devtool:
|
devtool:
|
||||||
buildFlags.mode === 'production'
|
buildFlags.mode === 'production'
|
||||||
? buildFlags.distribution === 'desktop'
|
? buildFlags.distribution === 'desktop'
|
||||||
? 'inline-source-map'
|
? 'inline-cheap-source-map'
|
||||||
: 'hidden-nosources-source-map'
|
: 'source-map'
|
||||||
: 'eval-cheap-module-source-map',
|
: 'eval-cheap-module-source-map',
|
||||||
|
|
||||||
resolve: {
|
resolve: {
|
||||||
@@ -199,7 +199,7 @@ export const createConfiguration: (
|
|||||||
type: 'asset/resource',
|
type: 'asset/resource',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(ttf|eot|woff|woff2)$/i,
|
test: /\.(ttf|eot|woff|woff2)$/,
|
||||||
type: 'asset/resource',
|
type: 'asset/resource',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -262,6 +262,7 @@ export const createConfiguration: (
|
|||||||
new VanillaExtractPlugin(),
|
new VanillaExtractPlugin(),
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': JSON.stringify({}),
|
'process.env': JSON.stringify({}),
|
||||||
|
'process.env.COVERAGE': JSON.stringify(!!buildFlags.coverage),
|
||||||
'process.env.NODE_ENV': JSON.stringify(buildFlags.mode),
|
'process.env.NODE_ENV': JSON.stringify(buildFlags.mode),
|
||||||
runtimeConfig: JSON.stringify(runtimeConfig),
|
runtimeConfig: JSON.stringify(runtimeConfig),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -27,6 +27,17 @@ import * as ReactJSXRuntime from 'react/jsx-runtime';
|
|||||||
import * as ReactDom from 'react-dom';
|
import * as ReactDom from 'react-dom';
|
||||||
import * as ReactDomClient from 'react-dom/client';
|
import * as ReactDomClient from 'react-dom/client';
|
||||||
|
|
||||||
|
if (!process.env.COVERAGE) {
|
||||||
|
lockdown({
|
||||||
|
evalTaming: 'unsafeEval',
|
||||||
|
overrideTaming: 'severe',
|
||||||
|
consoleTaming: 'unsafe',
|
||||||
|
errorTaming: 'unsafe',
|
||||||
|
errorTrapping: 'platform',
|
||||||
|
unhandledRejectionTrapping: 'report',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const PluginProvider = ({ children }: PropsWithChildren) =>
|
const PluginProvider = ({ children }: PropsWithChildren) =>
|
||||||
React.createElement(
|
React.createElement(
|
||||||
Provider,
|
Provider,
|
||||||
@@ -36,11 +47,9 @@ const PluginProvider = ({ children }: PropsWithChildren) =>
|
|||||||
children
|
children
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('JotaiUtils', JotaiUtils);
|
|
||||||
|
|
||||||
const customRequire = (id: string) => {
|
const customRequire = (id: string) => {
|
||||||
if (id === '@toeverything/plugin-infra/manager') {
|
if (id === '@toeverything/plugin-infra/manager') {
|
||||||
return harden(Manager);
|
return Manager;
|
||||||
}
|
}
|
||||||
if (id === 'react') {
|
if (id === 'react') {
|
||||||
return React;
|
return React;
|
||||||
@@ -55,22 +64,22 @@ const customRequire = (id: string) => {
|
|||||||
return ReactDomClient;
|
return ReactDomClient;
|
||||||
}
|
}
|
||||||
if (id === '@blocksuite/icons') {
|
if (id === '@blocksuite/icons') {
|
||||||
return harden(Icons);
|
return Icons;
|
||||||
}
|
}
|
||||||
if (id === '@affine/component') {
|
if (id === '@affine/component') {
|
||||||
return harden(AFFiNEComponent);
|
return AFFiNEComponent;
|
||||||
}
|
}
|
||||||
if (id === '@blocksuite/blocks/std') {
|
if (id === '@blocksuite/blocks/std') {
|
||||||
return harden(BlockSuiteBlocksStd);
|
return BlockSuiteBlocksStd;
|
||||||
}
|
}
|
||||||
if (id === '@blocksuite/global/utils') {
|
if (id === '@blocksuite/global/utils') {
|
||||||
return harden(BlockSuiteGlobalUtils);
|
return BlockSuiteGlobalUtils;
|
||||||
}
|
}
|
||||||
if (id === 'jotai') {
|
if (id === 'jotai') {
|
||||||
return harden(Jotai);
|
return Jotai;
|
||||||
}
|
}
|
||||||
if (id === 'jotai/utils') {
|
if (id === 'jotai/utils') {
|
||||||
return harden(JotaiUtils);
|
return JotaiUtils;
|
||||||
}
|
}
|
||||||
if (id === '../plugin.js') {
|
if (id === '../plugin.js') {
|
||||||
return entryCompartment.evaluate('exports');
|
return entryCompartment.evaluate('exports');
|
||||||
@@ -80,7 +89,7 @@ const customRequire = (id: string) => {
|
|||||||
|
|
||||||
const createGlobalThis = () => {
|
const createGlobalThis = () => {
|
||||||
return {
|
return {
|
||||||
process: harden({
|
process: Object.freeze({
|
||||||
env: {
|
env: {
|
||||||
NODE_ENV: process.env.NODE_ENV,
|
NODE_ENV: process.env.NODE_ENV,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user