Skip to content

Commit

Permalink
Merge pull request #124 from ecosia/esm
Browse files Browse the repository at this point in the history
Migrate to ESM fully
  • Loading branch information
LostCrew authored Oct 17, 2023
2 parents e2c6010 + 9ec9aa6 commit e66374f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 38 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
collectCoverage: true,
transform: {
'^.+\\.js$': ['babel-jest', { rootMode: 'upward' }],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "vue-safe-html",
"version": "2.2.0",
"description": "A Vue directive which renders sanitised HTML dynamically",
"type": "module",
"main": "dist/main.common.js",
"module": "dist/main.esm.js",
"repository": "[email protected]:ecosia/vue-safe-html.git",
Expand Down
76 changes: 39 additions & 37 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
const { resolve } = require('path');
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const dist = resolve(dirname(fileURLToPath(import.meta.url)), 'dist');
// eslint-disable-next-line no-underscore-dangle
const _module = {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
],
resolve: {
fullySpecified: false,
},
}],
};

module.exports = [
{
entry: './src/index.js',
output: {
filename: 'main.common.js',
path: resolve(__dirname, 'dist'),
library: 'VueSafeHTML',
libraryTarget: 'commonjs2',
globalObject: '(typeof self !== \'undefined\' ? self : this)',
},
mode: 'production',
module: _module,
export default [{
entry: './src/index.js',
output: {
filename: 'main.common.js',
path: dist,
library: 'VueSafeHTML',
libraryTarget: 'commonjs2',
globalObject: '(typeof self !== \'undefined\' ? self : this)',
},
{
entry: './src/index.js',
output: {
filename: 'main.esm.js',
path: resolve(__dirname, 'dist'),
libraryTarget: 'module',
globalObject: '(typeof self !== \'undefined\' ? self : this)',
},
mode: 'production',
experiments: {
outputModule: true, // Enable the "experiments.outputModule" option
},
module: _module,
mode: 'production',
module: _module,
},
{
entry: './src/index.js',
output: {
filename: 'main.esm.js',
path: dist,
libraryTarget: 'module',
globalObject: '(typeof self !== \'undefined\' ? self : this)',
},
mode: 'production',
experiments: {
outputModule: true, // Enable the "experiments.outputModule" option
},
];
module: _module,
}];

0 comments on commit e66374f

Please sign in to comment.