Remove no longer supported import syntax, use CommonJS for tests instead
Using inject-loader requires first transpiling modules to CommonJS. Previously, we were doing this via parametrized imports, but these are no longer supported. Instead, we can fix this by using CommonJS preset in Webpack config. [MAILPOET-5491]
This commit is contained in:
@@ -2,10 +2,7 @@ import { App } from 'newsletter-editor/app';
|
|||||||
import { AutomatedLatestContentBlock } from 'newsletter-editor/blocks/automated-latest-content-layout';
|
import { AutomatedLatestContentBlock } from 'newsletter-editor/blocks/automated-latest-content-layout';
|
||||||
import { ContainerBlock } from 'newsletter-editor/blocks/container';
|
import { ContainerBlock } from 'newsletter-editor/blocks/container';
|
||||||
import { CommunicationComponent } from 'newsletter-editor/components/communication';
|
import { CommunicationComponent } from 'newsletter-editor/components/communication';
|
||||||
|
import AutomatedLatestContentInjector from 'inject-loader!newsletter-editor/blocks/automated-latest-content-layout';
|
||||||
/* (ES6 -> CommonJS transform needed for inject-loader) */
|
|
||||||
/* eslint-disable-next-line max-len */
|
|
||||||
import AutomatedLatestContentInjector from 'inject-loader!babel-loader?plugins[]=@babel/plugin-transform-modules-commonjs!newsletter-editor/blocks/automated-latest-content-layout';
|
|
||||||
|
|
||||||
const expect = global.expect;
|
const expect = global.expect;
|
||||||
const sinon = global.sinon;
|
const sinon = global.sinon;
|
||||||
|
@@ -1,6 +1,4 @@
|
|||||||
/* (ES6 -> CommonJS transform needed for inject-loader) */
|
import CommunicationInjector from 'inject-loader!newsletter-editor/components/communication';
|
||||||
/* eslint-disable-next-line max-len */
|
|
||||||
import CommunicationInjector from 'inject-loader!babel-loader?plugins[]=@babel/plugin-transform-modules-commonjs!newsletter-editor/components/communication';
|
|
||||||
|
|
||||||
const expect = global.expect;
|
const expect = global.expect;
|
||||||
const jQuery = global.jQuery;
|
const jQuery = global.jQuery;
|
||||||
|
@@ -1,10 +1,7 @@
|
|||||||
import { App } from 'newsletter-editor/app';
|
import { App } from 'newsletter-editor/app';
|
||||||
import { SaveComponent } from 'newsletter-editor/components/save';
|
import { SaveComponent } from 'newsletter-editor/components/save';
|
||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
|
import SaveInjector from 'inject-loader!newsletter-editor/components/save';
|
||||||
/* (ES6 -> CommonJS transform needed for inject-loader) */
|
|
||||||
/* eslint-disable-next-line max-len */
|
|
||||||
import SaveInjector from 'inject-loader!babel-loader?plugins[]=@babel/plugin-transform-modules-commonjs!newsletter-editor/components/save';
|
|
||||||
|
|
||||||
const expect = global.expect;
|
const expect = global.expect;
|
||||||
const sinon = global.sinon;
|
const sinon = global.sinon;
|
||||||
|
@@ -295,6 +295,21 @@ const testConfig = {
|
|||||||
'blocks/text.spec.js',
|
'blocks/text.spec.js',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
module: {
|
||||||
|
...baseConfig.module,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.(j|t)sx?$/,
|
||||||
|
exclude: /(node_modules|src\/vendor)/,
|
||||||
|
loader: 'babel-loader',
|
||||||
|
resolve: { fullySpecified: false },
|
||||||
|
options: {
|
||||||
|
presets: [['@babel/preset-env', { modules: 'commonjs' }]],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...baseConfig.module.rules,
|
||||||
|
],
|
||||||
|
},
|
||||||
output: {
|
output: {
|
||||||
path: path.join(
|
path: path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
|
Reference in New Issue
Block a user